Thursday, August 3, 2023

Create a pod


Create a pod

 

Create a pod named pod-httpd using httpd image with latest tag only and remember to mention the tag i.e httpd:latest.

Labels app should be set to httpd_app, also container should be named as httpd-container.


To create the specified pod named "pod-httpd" with the httpd image and set the required labels and container name, you can use the following YAML configuration:


yaml 

apiVersion: v1

kind: Pod

metadata:

  name: pod-httpd

  labels:

    app: httpd_app

spec:

  containers:

    - name: httpd-container

      image: httpd:latest


Save the above configuration in a file, e.g., "pod-httpd.yaml," and then use the kubectl command to create the pod:


bash

# kubectl create -f pod-httpd.yaml

Ensure that you have the necessary permissions to create pods on the Kubernetes cluster. After running the command, the "pod-httpd" pod will be created, using the httpd image with the latest tag, and it will have the "app=httpd_app" label, and the container inside the pod will be named "httpd-container."


Please make sure that you are using the correct kubectl context to interact with the desired Kubernetes cluster.


To verify that the pod was created successfully, you can run the following command:

# kubectl get pods


No comments:

Post a Comment

Troubleshoot issue with Pods - Part 2

  Troubleshoot issue with Pods - Part 2 To verify if there are any port conflicts between the containers and ensure that the container ports...