Kubernetes CKA sample exam question 89 with answer

Question
In Namespace lion there is one existing Pod which requests 1Gi of memory resources.
That Pod has a specific priority because of its PriorityClass.
Create new Pod named important of image nginx:1.21.6-alpine in the same Namespace. It should request 1Gi memory resources.
Assign a higher priority to the new Pod so it's scheduled instead of the existing one.
Both Pods won't fit in the cluster.

Answer
Check for existing pod:

kubectl -n lion get po
kubectl -n lion get pod -oyaml | grep priority
Check for existing PriorityClasses:
kubectl get priorityclass
current priority class is level2, so will use level3 for the future.
Generate the manifest for new Pod:
kubectl -n lion run important --image=nginx:1.21.6-alpine -oyaml --dry-run=client
Then change it:
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: important
  name: important
  namespace: lion
spec:
  priorityClassName: level3
  containers:
  - image: nginx:1.21.6-alpine
    name: important
    resources:
      requests:
        memory: 1Gi
Apply:
kubectl apply -f po.yaml
Now there should only be the new Pod running:
kubectl -n lion get pod
We can also see logs about this procedure like:
kubectl get events -A --sort-by='{.metadata.creationTimestamp}'
The output whould be the following:
Preempted by lion/important on node controlplane