Task 1: Create a Persistent Volume
The first task is to create a persistent volume named log-volume with the following specifications:- Storage Class: manual
- Access Mode: ReadWriteMany (RWX)
- Capacity: 1Gi
- Host Path: /opt/volume/nginx
Task 2: Create a Persistent Volume Claim
Next, create a persistent volume claim (PVC) named log-claim with these requirements:- Access Mode: ReadWriteMany
- Storage Request: 8Gi of storage
- Storage Class: manual
log-claim.yaml and apply it:
Task 3: Mount the Volume in a Pod
Now, mount the PVC into a pod named logger at the mount path /var/www/nginx. This pod will run a container using thenginx:alpine image.
Step 1: Generate the Initial Pod YAML
Create the pod configuration using a dry-run:Step 2: Edit the YAML to Add Volumes and Volume Mounts
Modifylogger.yaml to include:
- A volumes section to reference the PVC.
- A volumeMounts section under the container to specify the mount path.
spec:
persistentVolumeClaim with an “s”), apply the updated configuration:
Ensure that the field name
persistentVolumeClaim is spelled correctly and that you have saved the file appropriately before re-applying.Task 4: Troubleshoot Network Connectivity for Secure Pod
A pod named secure-pod and a service named secure-service are deployed. However, incoming and outgoing connections to the secure pod are currently failing, and traffic from the webapp-color pod using secure-service is not working.Step 1: Verify Pods and Service
Check the pods:Step 2: Test Connectivity from the webapp-color Pod
Enter the pod shell:Step 3: Check the Existing Network Policy
Run:Step 4: Identify Pod Labels
Determine the pod labels with:Step 5: Create a Network Policy
Create a network policy YAML (netpol.yaml) to allow ingress traffic from pods labeled name=webapp-color to the pod labeled run=secure-pod on port 80:
Step 6: Retest Connectivity
From the webapp-color pod, execute:Task 5: Create a Time-Check Pod Using a ConfigMap
In this task, we create a pod that periodically checks the system time. This pod is deployed in a new namespace (for example,dv11987).
Step 1: Create the Namespace
If the namespace doesn’t already exist, create it:Step 2: Create the ConfigMap
Create a ConfigMap named time-config with the key-value pairTIME_FREQ=10:
Step 3: Generate the Pod YAML
Generate a pod configuration for time-check using thebusybox image:
Step 4: Edit the Pod Configuration
Updatetime-check.yaml to include the environment variable from the ConfigMap, a command that logs the current date, and a volume mounted at /opt/time using emptyDir:
dv11987 namespace:
Task 6: Create and Upgrade an Nginx Deployment
Create a deployment named nginx-deploy with the following requirements:- Image: nginx:1.16 initially
- Replicas: 4
- Rolling Update Strategy:
- maxSurge: 1
- maxUnavailable: 2
Step 1: Generate the Deployment YAML
Generate the deployment using a dry-run:Step 2: Edit the Deployment for Rolling Updates
Modifynginx-deploy.yaml to add the rolling update strategy:
Step 3: Upgrade the Deployment
Upgrade the deployment to usenginx:1.17:
Step 4: Rollback the Deployment
After the upgrade, rollback to the previous version if needed:Task 7: Create a Redis Deployment with Resource Limits and Volume Mounts
Finally, create a deployment named redis with these parameters:- Image: redis:alpine
- Replicas: 1
- Resource Request: 0.2 CPU
- Label: app=redis
- Volumes:
- data: Use
emptyDirmounted at/redis-master-data - redis-config: Use a ConfigMap (named redis-config) mounted at
/redis-master
- data: Use
- Exposed Port: 6379
Step 1: Generate the Deployment YAML
Generate the initial deployment:Step 2: Edit the Deployment File
Updateredis.yaml with the correct resource requests, volumes, and volume mounts:
After completing all the tasks, validate your configurations with the appropriate
kubectl get commands to ensure that all pods, deployments, and services are running as expected.
Happy deploying!