Creating a Kubernetes Pod
To create a Kubernetes Pod, you need to define a Pod specification in a YAML file. A Pod is the smallest and simplest Kubernetes object, and it represents a running process in your cluster.
Here's an example of a YAML file that defines a simple Pod:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: nginx:latest
ports:
- containerPort: 80
In this example, the Pod has a single container that runs the latest version of the Nginx web server. The metadata
section specifies the name of the Pod, and the spec
section defines the container(s) that will run inside the Pod.
To create this Pod in your Kubernetes cluster, you can use the kubectl
command-line tool:
kubectl create -f pod.yaml
This will create the Pod in your cluster, and you can use the following commands to examine its components: