About Me

My photo
I am MCSE in Data Management and Analytics with specialization in MS SQL Server and MCP in Azure. I have over 13+ years of experience in IT industry with expertise in data management, Azure Cloud, Data-Canter Migration, Infrastructure Architecture planning and Virtualization and automation. Contact me if you are looking for any sort of guidance in getting your Infrastructure provisioning automated through Terraform. I sometime write for a place to store my own experiences for future search and read by own blog but can hopefully help others along the way. Thanks.

Create a init containers with example.

 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: