Valid CKS Dumps shared by ExamDiscuss.com for Helping Passing CKS Exam! ExamDiscuss.com now offer the newest CKS exam dumps, the ExamDiscuss.com CKS exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com CKS dumps with Test Engine here:
Cluster: qa-cluster Master node: master Worker node: worker1 You can switch the cluster/configuration context using the following command: [desk@cli] $ kubectl config use-context qa-cluster Task: Create a NetworkPolicy named restricted-policy to restrict access to Pod product running in namespace dev. Only allow the following Pods to connect to Pod products-service: 1. Pods in the namespace qa 2. Pods with label environment: stage, in any namespace
Correct Answer:
$ k get ns qa --show-labels NAME STATUS AGE LABELS qa Active 47m env=stage $ k get pods -n dev --show-labels NAME READY STATUS RESTARTS AGE LABELS product 1/1 Running 0 3s env=dev-team apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: restricted-policy namespace: dev spec: podSelector: matchLabels: env: dev-team policyTypes: - Ingress ingress: - from: - namespaceSelector: matchLabels: env: stage - podSelector: matchLabels: env: stage [desk@cli] $ k get ns qa --show-labels NAME STATUS AGE LABELS qa Active 47m env=stage [desk@cli] $ k get pods -n dev --show-labels NAME READY STATUS RESTARTS AGE LABELS product 1/1 Running 0 3s env=dev-team [desk@cli] $ vim netpol2.yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: restricted-policy namespace: dev spec: podSelector: matchLabels: env: dev-team policyTypes: - Ingress ingress: - from: - namespaceSelector: matchLabels: env: stage - podSelector: matchLabels: env: stage [desk@cli] $ k apply -f netpol2.yaml Reference: https://kubernetes.io/docs/concepts/services-networking/network-policies/ [desk@cli] $ k apply -f netpol2.yaml Reference: https://kubernetes.io/docs/concepts/services-networking/network-policies/