Lab Information
The Nautilus DevOps team is working on to setup some pre-requisites for an application that will send the greetings to different users. There is a sample deployment, that needs to be tested. Below is a scenario which needs to be configured on Kubernetes cluster. Please find below more details about it.
Create a pod named print-envars-greeting.
Configure spec as, the container name should be print-env-container and use bash image.
Create three environment variables:
a. GREETING and its value should be Welcome to
b. COMPANY and its value should be DevOps
c. GROUP and its value should be Datacenter
Use command ["/bin/sh", "-c", 'echo "$(GREETING) $(COMPANY) $(GROUP)"'] (please use this exact command), also set its restartPolicy policy to Never to avoid crash loop back.
You can check the output using kubectl logs -f print-envars-greeting command.
Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.
Lab Solutions
Step 1: Create the Pod YAML configuration
Create a file named print-envars-greeting.yaml:
cat > print-envars-greeting.yaml << 'EOF'
apiVersion: v1
kind: Pod
metadata:
name: print-envars-greeting
spec:
containers:
- name: print-env-container
image: bash
command: ["/bin/sh", "-c", 'echo "$GREETING $COMPANY $GROUP"']
env:
- name: GREETING
value: "Welcome to"
- name: COMPANY
value: "DevOps"
- name: GROUP
value: "Datacenter"
restartPolicy: Never
EOF
Step 2: Create the Pod
Apply the configuration to create the pod:
kubectl apply -f print-envars-greeting.yaml
Step 3: Check the Pod Status
Monitor the pod status to see when it completes:
kubectl get pod print-envars-greeting
You'll see the status change from Pending → Running → Completed (or Succeeded).
Step 4: View the Output
Check the logs to see the output of the command:
kubectl logs print-envars-greeting



Top comments (0)