You are deploying a microservices application in Kubernetes. Each microservice has its own deployment and service. How can you enforce network policy rules to restrict communication between these microservices, allowing only authorized communication?
Correct Answer: D
The most effective way to enforce network policy rules for microservices in Kubernetes is to use network policies. Network policies allow you to define specific rules for communication between pods or groups of pods. By creating network policies, you can specify which pods are allowed to communicate with each other, based on their labels, namespaces, or other criteria. This allows you to restrict communication between microservices, ensuring that only authorized communication is allowed. While namespaces can help to isolate microservices logically, they do not provide granular network control. Configuring ports and services can restrict access to specific services, but it does not provide the level of control needed to enforce communication rules between microservices.
KCNA Exam Question 47
You are running a Kubernetes cluster with three nodes. One node experiences a hardware failure. Which of the following Kubernetes features ensures that your application remains available and running?
Correct Answer: D
Kubernetes' self-healing capabilities ensure that your application remains available even when a node fails. It automatically detects and restarts failed Pods on healthy nodes, maintaining the desired number of replicas.
KCNA Exam Question 48
Consider a scenario where you need to configure a Kubernetes storage class with a specific storage provisioner and access modes. How would you achieve this using a YAML configuration?
Correct Answer: A
Option A correctly defines a StorageClass named "my-storage-class" with the provisioner "kubernetes.io/gce-pd" and an access mode "ReadWriteOnce". StorageClasses define how volumes should be provisioned, specifying the storage provisioner and other attributes. Option B defines a PersistentVolume, not a StorageClass. Option C defines a Deployment, not a StorageClass. Option D defines a PersistentVolumeClaim, not a StorageClass. Option E defines a StorageClass, but does not include the accessModes property.
KCNA Exam Question 49
Describe the different ways to manage persistent volumes in Kubernetes, including the concepts of static provisioning and dynamic provisioning. Provide examples for each approach.
Correct Answer: A
In static provisioning, you manually create PersistentVolumes (PVs) before deploying your application This gives you more control over storage allocation, but it can be more complex for large deployments- In dynamic provisioning, you use a StorageClass to define storage characteristics, and the cluster automatically provisions PVs as needed- Dynamic provisioning simplifies storage management and allows for more scalable deployments. The YAML examples in option A demonstrate both approaches. The first example defines a static provisioned PV with a hostPath volume. The second example defines a dynamic provisioned StorageClass using the provisioner "kubernetes.io/gce- pd".
KCNA Exam Question 50
You are running a stateless application on Kubernetes and want to avoid persistent storage. Which of the following options is suitable?
Correct Answer: C
For stateless applications, an emptyDir volume is the most suitable choice as it provides a temporary directory within the pod, which is discarded when the pod is terminated. PersistentVolumeClaim, HostPath volumes, and Local Persistent Volumes are designed for persistent storage, unsuitable for stateless applications. ConfigMaps store application configuration data, not application data itself.