Can you give an example where I would specify the pod name and an example where I would specify the container name?
Hello @rasivasu,
The sample below is a manifest for a simple Job with a template
that starts one container. The container in that Pod prints a message then pauses.
apiVersion: batch/v1
kind: Job
metadata:
name: hello
spec:
template:
# This is the pod template
spec:
containers:
- name: hello
image: busybox
command: ['sh', '-c', 'echo "Hello, Kubernetes!" && sleep 3600']
restartPolicy: OnFailure
# The pod template ends here
1 Like
apiVersion: v1
kind: Pod
metadata:
name: <pod-name>
spec:
containers:
- name: <container-name>
image:
1 Like
Thank you KodeKloud and player001. My question is slightly different.
In the example given below, I see that the labels “name: voting-app-pod” and “app: demo-voting-app” are very important for the configuration to work. At the same time, I am not able to see the purpose that the deployment name “voting-app-deploy-name” and the pod name “voting-app-pod-name” are serving. So my questions are:
- Are they only for documentation?
- If they indeed have a purpose, can you provide an example where these two names will be referenced?
apiVersion: apps/v1 kind: Deployment metadata: name: voting-app-deploy-name labels: name: voting-app-deploy app: demo-voting-app spec: replicas: 1 selector: matchLabels: name: voting-app-pod app: demo-voting-app template: metadata: name: voting-app-pod-name labels: name: voting-app-pod app: demo-voting-app spec: containers: - name: voting-app image: kodekloud/examplevotingapp_vote:v1 ports: - containerPort: 80
Never mind. I just realized that these two names appear in the output of kubectl get all
.