
An image contains the code used to create a deployment. Then, a deployment can be created from an image, which should then create a replica set (which is the number of pods that should be created), and then the pods should be created.
A JSON or YAML file that contains key value pairs used to create an object, such as a config map, deployment, a project, a pod, a route, a secret, a service, et cetera. These files are known as templates. The oc explain command can be used to get the list of keys that can be used in the JSON or YAML template file.
oc explain pod
And then more details on each key can be displayed.
oc explain pod.spec
For example, let's say you have a YAML file named pod.yml that contains the following markup. In this example, a pod named "my-pod" will be created in the project/namespace named "foo" using the "hello-world" image.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: foo
spec:
containers:
- name: helloworld
image: hello-world
The oc apply or oc create command with the -f or --filename option can be used to create the pod using the template JSON or YAML file.
The oc replace command can be used to replace a pod using a new or updated template JSON or YAML file.
The oc edit command can be used to update a pods template YAML file.
~]$ oc create --filename pod.yml
pod/my-pod created
The oc get pods command can then be used to determine if the pod is up and running.
~]$ oc get pods
NAME READY STATUS RESTARTS AGE
hello-world 1/1 Running 0 23s
Optionally, the pod can be created on a specific node by including the nodeName key.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: foo
spec:
containers:
- name: helloworld
image: hello-world
nodeName: worker-4k6z9
And then the oc get pods command with the --output wide option can be used to confirm the pod was created on the specified node.
~]$ oc get pods --output wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATE
hello-world 1/1 Running 0 23s 10.152.44.15 worker-4k6z9 <none> <none>
Did you find this article helpful?
If so, consider buying me a coffee over at