How do you create pod pod1 of image nginx in namespace ns1 that will have the container name c1?

Experience Level: Medior
Tags: Kubernetes

Answer

Run the following command to generate pod manifest:

kubectl run pod1 --image=nginx --dry-run=client -o yaml > pod.yaml

Then run the following to edit the file:

nano pod.yaml

Add namespace to metadata section, find the container name pod1 under containers section and change it to c1:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: pod1
  name: pod1
  namespace: ns1 #add this line
spec:
  containers:
  - image: nginx
    name: pod1 #change this line to c1
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always

Then save the file and create the pod by running the following:

kubectl apply -f pod.yaml

Kubernetes Certified Application Developer (CKAD) preparation
Kubernetes Certified Application Developer (CKAD) preparation

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself
Kubernetes
Kubernetes

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself
Kubernetes Certified Administrator (CKA) preparation
Kubernetes Certified Administrator (CKA) preparation

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself

Chat

Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.

Comments

Anonymous
Καλησπέρα.
Anonymous
the infinteis -3/15 so 1triition / infinet
Anonymous
e
Anonymous
<a href="https://inspirum.pl "
Anonymous
[url]https://inspirum.pl[/url]
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e