← Back to Drills Elapsed 00:00
  1. Create a namespace called exercise-01

    Solution
    kubectl create namespace exercise-01

    Creates the namespace. All subsequent commands target this namespace with -n exercise-01. Reference lesson.

  2. Create pod web in namespace exercise-01 with image nginx:1.28, labels app=web,tier=frontend, requests cpu=100m,memory=64Mi, limits cpu=250m,memory=128Mi

    Solution

    Generate a base manifest quickly:

    kubectl run web -n exercise-01 --image=nginx:1.28 --labels=app=web,tier=frontend --dry-run=client -o yaml > pod.yaml

    Then edit pod.yaml so it matches this final manifest:

    apiVersion: v1
    kind: Pod
    metadata:
      labels:
        app: web
        tier: frontend
      name: web
      namespace: exercise-01
    spec:
      containers:
        - image: nginx:1.28
          name: web
          resources:
            limits:
              cpu: 250m
              memory: 128Mi
            requests:
              cpu: 100m
              memory: 64Mi
    kubectl apply -f pod.yaml

    This step creates the pod with the expected metadata and resource constraints. Reference lesson.

  3. Add label version=v1 and remove label tier from pod web

    Solution
    kubectl label pod web -n exercise-01 version=v1
    kubectl label pod web -n exercise-01 tier-

    Labels are mutable metadata, no pod restart is required. Reference lesson.

  4. Optional clean up, delete the namespace

    Solution
    kubectl delete namespace exercise-01

    Deletes the namespace and everything inside it in one command.

Loading terminal…

Contact us