Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

CKA Practice Exam: Part 2

Managing storage is a challenge for most organizations. Kubernetes allows you to create persistent storage so the data is not lost when a pod is moved or deleted. In this portion of the practice exam, you will demonstrate your knowledge of `PersistentVolumes` and `PersistentVolumeClaims` in order to ensure data integrity. This will simulate a question you may see on the Certified Kubernetes Administrator (CKA) exam.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 1h 0m
Published
Clock icon Mar 31, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create the `PersistentVolumeClaim`.

    1. Use the following command to check if there is already a 'web' namespace:
    kubectl get ns
    kubectl get pv
    
    1. Use the following command to create a PersistentVolumeClaim work from scratch or use a Kubernetes template file. Search the documentation :
    vi data-pvc.yaml #copy and paste from docs
    
    1. Update the file data-pvc.yaml with the following details:
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: data-pvc
      namespace: web
    spec:
      storageClassName: local-storage
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 256Mi
    
    1. Use the following command to create the PVC:
    kubectl apply -f data-pvc.yaml
    
  2. Challenge

    Create a pod mounting the volume and write data to the volume.

    1. Use the following command to create the YAML for a busybox pod:
    kubectl run data-pod --image=busybox:1.28 --restart=Never -o yaml --dry-run -- /bin/sh -c 'sleep 3600' > data-pod.yaml
    
    1. Use the following command to edit the data-pod.yaml file:
    vi data-pod.yaml
    
    1. Update the data-pod.yaml file as below:
    apiVersion: v1
    kind: Pod
    metadata:
      name: data-pod
      namespace: web
    spec:
      containers:
      - args:
        - /bin/sh
        - -c
        - sleep 3600
        image: busybox:1.28
        name: data-pod
        resources: {}
        volumeMounts: 
        - name: temp-data
          mountPath: /tmp/data
      dnsPolicy: ClusterFirst
      restartPolicy: Never
      volumes: 
      - name: temp-data
        persistentVolumeClaim:
          claimName: data-pvc
    
    1. Use the following command to create the pod:
    kubectl apply -f data-pod.yaml
    
    1. Use the following command to connect to the pod:
    kubectl exec -it data-pod -n web -- sh
    
    1. Use the following commands to confirm the environmant and to copy the contents of the etc/passwd file to /tmp/data:
    # ls -la /etc/passwd
    # ls -la /tmp/data/
    # cp /etc/passwd /tmp/data/passwd
    
    1. Use the following command to list the contents of /tmp/data:
    # ls /tmp/data/
    
  3. Challenge

    Delete the pod and create a new pod and view volume data.

    1. Use the following command to delete the pod:

      kubectl delete po data-pod -n web
      
    2. Use the following command to modify the pod YAML:

      vi data-pod.yaml
      
    3. Change the following line in the data-pod.yaml file:

      name: data-pod2
      
    4. Use the following command to create a new pod:

      kubectl apply -f data-pod.yaml
      
    5. Use the following command to connect to the pod and view the contents of the volume:

      kubectl exec -it data-pod2 -n web -- sh
      
      # ls /tmp/data
      

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans