-
Explain the role of a Kubernetes Pod when deploying an Nginx web server.
Answer: A Kubernetes Pod is the smallest deployable unit and represents a single instance of a running process. When deploying Nginx, a Pod encapsulates the Nginx container along with shared networking and storage resources.
-
What is the purpose of using a Kubernetes Service when deploying Nginx?
Answer: A Kubernetes Service provides a stable network endpoint for accessing Nginx Pods. It enables load balancing, service discovery, and ensures availability even if Pods are rescheduled or scaled.
-
How does a Kubernetes Deployment enhance the deployment of an Nginx application?
Answer: A Kubernetes Deployment manages the lifecycle of Nginx Pods. It enables declarative updates, scaling, and self-healing by maintaining a desired number of replica Pods based on a defined configuration.
-
Why would you use a Namespace when deploying Nginx and related resources?
Answer: A Namespace provides a virtual cluster environment within a physical cluster. It helps in organizing and isolating resources, making it easier to manage and monitor Nginx-related components separately.
-
Nginx Pod Manifest in "nginx" Namespace:
apiVersion: v1 kind: Pod metadata: name: nginx-pod namespace: nginx spec: containers: - name: nginx-container image: nginx:latest
-
Nginx Service Manifest in "nginx" Namespace:
apiVersion: v1 kind: Service metadata: name: nginx-service namespace: nginx spec: selector: app: nginx-app ports: - protocol: TCP port: 80 targetPort: 80
-
Nginx Deployment Manifest in "nginx" Namespace:
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment namespace: nginx spec: replicas: 3 selector: matchLabels: app: nginx-app template: metadata: labels: app: nginx-app spec: containers: - name: nginx-container image: nginx:latest
-
Create the "nginx" Namespace:
kubectl create namespace nginx
-
Apply the Nginx Pod, Service, and Deployment YAMLs within the "nginx" Namespace:
kubectl apply -f nginx-pod.yaml -n nginx kubectl apply -f nginx-service.yaml -n nginx kubectl apply -f nginx-deployment.yaml -n nginx