Certified Kubernetes Administrator (CKA) Practice Test

Access More Questions
How do you create a network policy in Kubernetes?
Correct Answer:
By writing a YAML manifest
Explanation:
Creating a network policy in Kubernetes typically involves writing a YAML manifest. This is because Kubernetes resources are defined using YAML files, which allow for clear and precise configuration of various settings, including network policies. Each network policy specifies the ingress and egress rules that control the communication to and from a pod or group of pods. By defining a network policy in a YAML manifest, you can specify various attributes, such as the pod selectors that define which pods the policy applies to, as well as the rules that dictate the allowed traffic based on labels or namespaces. Once the YAML manifest is completed, it can be applied to the Kubernetes cluster using the `kubectl apply -f .yaml` command. The command line interface is useful for applying the manifest, but it is the YAML configuration that defines the policy itself. Web-based dashboards and graphical configuration tools may provide user-friendly interfaces for managing Kubernetes resources, but they typically still generate and apply YAML manifests behind the scenes. Therefore, writing a YAML manifest is the fundamental method for creating network policies in Kubernetes.

Access more questions from this quiz

Continue to Certified Kubernetes Administrator (CKA) Practice Test for more practice questions and the full quiz experience.

Access More Questions