Set Up Time Check Pod in Kubernetes
How to Efficiently Set Up a Time Check Pod in Kubernetes

Infosec Poet and CAP-certified DevOps/SecOps Engineer, passionate about security, creativity, and continuous learning.
Tasks
Create a pod called
time-checkin thedevopsnamespace. The pod should have a container namedtime-check, using thebusyboximage with thelatesttag (busybox:latest).Create a config map named
time-configwith the dataTIME_FREQ=12in the same namespace.Configure the
time-checkcontainer to run the command:while true; do date; sleep $TIME_FREQ; done. Ensure the output is written to/opt/sysops/time/time-check.log. Add an environment variableTIME_FREQin the container, getting its value from the config mapTIME_FREQkey.Create a volume
log-volumeand mount it at/opt/sysops/timewithin the container.
Steps
Create a manifest file
time-check.yaml.apiVersion: v1 kind: Namespace metadata: name: devops --- apiVersion: v1 kind: ConfigMap metadata: name: time-config namespace: devops data: TIME_FREQ: "12" --- apiVersion: v1 kind: Pod metadata: name: time-check namespace: devops spec: containers: - name: time-check image: busybox:latest command: ["sh", "-c", "while true; do date >> /opt/sysops/time/time-check.log; sleep $TIME_FREQ; done"] env: - name: TIME_FREQ valueFrom: configMapKeyRef: name: time-config key: TIME_FREQ volumeMounts: - name: log-volume mountPath: /opt/sysops/time volumes: - name: log-volume emptyDir: {}cat << EOF > time-check.yaml apiVersion: v1 kind: Namespace metadata: name: devops --- apiVersion: v1 kind: ConfigMap metadata: name: time-config namespace: devops data: TIME_FREQ: "12" --- apiVersion: v1 kind: Pod metadata: name: time-check namespace: devops spec: containers: - name: time-check image: busybox:latest command: ["sh", "-c", "while true; do date >> /opt/sysops/time/time-check.log; sleep \$TIME_FREQ; done"] env: - name: TIME_FREQ valueFrom: configMapKeyRef: name: time-config key: TIME_FREQ volumeMounts: - name: log-volume mountPath: /opt/sysops/time volumes: - name: log-volume emptyDir: {} EOF
Now apply
kubectl apply -f time-check.yaml
ss





