Question: -
Create a YAML manifest for a pod named complex-pod. The main application container named app should use the image nginx and expose the container port 80. Modify the YAML manifest so that the pod defines an init container named setup that uses the image busybox. The init container runs the command wget -O- google.com
Answer: -
you can start by generating the yaml manifest in dry-run mode. the resulting manifest will setup the main application container:
kubectl run complex-pod --image=nginx --port=80 --dry-run=client -o yaml >complex-pod.yaml
then update the manifest accordingly.
1. Add the init container and changing some of the default settings that have been generated. The finalized manifest could look as below.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: complex-pod
name: complex-pod
spec:
initContainers:
- name: setup
image: busybox
command: ['sh' , '-c' , 'wget -O- google.com']
containers:
- image: nginx
name: complex-pod
ports:
- containerPort: 80
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
No comments:
Post a Comment