About Me

My photo
I am an MCSE in Data Management and Analytics, specializing in MS SQL Server, and an MCP in Azure. With over 19+ years of experience in the IT industry, I bring expertise in data management, Azure Cloud, Data Center Migration, Infrastructure Architecture planning, as well as Virtualization and automation. I have a deep passion for driving innovation through infrastructure automation, particularly using Terraform for efficient provisioning. If you're looking for guidance on automating your infrastructure or have questions about Azure, SQL Server, or cloud migration, feel free to reach out. I often write to capture my own experiences and insights for future reference, but I hope that sharing these experiences through my blog will help others on their journey as well. Thank you for reading!

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: