Skip to content

Latest commit

 

History

History
164 lines (132 loc) · 3.26 KB

06-CKA-MockExam-3-Solution.md

File metadata and controls

164 lines (132 loc) · 3.26 KB

Mock Exam 3 Solution

Is it tough? Want to see the solution ?

  1. Run the below Command for Solution

    kubectl create serviceaccount pvviewer
    kubectl create clusterrole pvviewer-role --resource=persistentvolumes --verb=list
    kubectl create clusterrolebinding pvviewer-role-binding --clusterrole=pvviewer-role --serviceaccount=default:pvviewer
    
    apiVersion: v1
    kind: Pod
    metadata:
      creationTimestamp: null
      labels:
        run: pvviewer
      name: pvviewer
    spec:
      containers:
      - image: redis
        name: pvviewer
        resources: {}
      serviceAccountName: pvviewer
    
  2. Run the below Command for Solution

    kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}' > /root/node_ips
    
  3. Run the below Command for Solution

    apiVersion: v1
    kind: Pod
    metadata:
      name: multi-pod
    spec:
      containers:
      - image: nginx
        name: alpha
        env:
        - name: name
          value: alpha
      - image: busybox
        name: beta
        command: ["sleep", "4800"]
        env:
        - name: name
          value: beta
    status: {}
    
  4. Run the below Command for Solution

    apiVersion: v1
    kind: Pod
    metadata:
      name: non-root-pod
    spec:
      securityContext:
        runAsUser: 1000
        fsGroup: 2000
      containers:
      - name: non-root-pod
        image: redis:alpine
    
  5. Run the below Command for Solution

    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: ingress-to-nptest
      namespace: default
    spec:
      podSelector:
        matchLabels:
          role: np-test-1
      policyTypes:
      - Ingress
      ingress:
      - ports:
        - protocol: TCP
          port: 80
    
  6. Run the below Command for Solution

    kubectl taint node node01 env_type=production:NoSchedule
    
    apiVersion: v1
    kind: Pod
    metadata:
      name: prod-redis
    spec:
      containers:
      - name: prod-redis
        image: redis:alpine
      tolerations:
      - effect: Noschedule
        key: env_type
        operator: Equal
        value: prodcution     
    
  7. Run the below Command for Solution

    kubectl create namespace hr
    kubectl run hr-pod --image=redis:alpine --namespace=hr --labels=environment=production,tier=frontend
    
  8. Run the below Command for Solution

    vi /root/super.kubeconfig
    
    Change the 2379 port to 6443 and run the below command to verify
    
    kubectl cluster-info --kubeconfig=/root/super.kubeconfig     
    
  9. Run the below Command for Solution

    sed -i 's/kube-contro1ler-manager/kube-controller-manager/g' kube-controller-manager.yaml