The Nautilus Devops team is diving into Kubernetes for application management. One team member has a task to create a pod according to the details below:
Create a pod named pod-httpd
using the httpd
image with the latest
tag. Ensure to specify the tag as httpd:latest
.
- Set the
app
label tohttpd_app
, and name the container ashttpd-container
.
Note
: The kubectl
utility on jump_host
is configured to operate with the Kubernetes cluster.
vi pos-httpd.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-httpd
labels:
app: httpd_app
spec:
containers:
- name: httpd-container
image: httpd:latest
esc
:wq
kubectl apply -f pod-httpd.yaml
pod/pod-httpd created
kubectl get pod pod-httpd --show-labels
NAME READY STATUS RESTARTS AGE LABELS
pod-httpd 1/1 Running 0 73s app=httpd_app
Can also be ran as a one liner - needed ChatGPT to figure it out:
kubectl run pod-httpd \
--image=httpd:latest \
--restart=Never \
--labels=app=httpd_app \
--overrides='
{
"apiVersion": "v1",
"spec": {
"containers": [
{
"name": "httpd-container",
"image": "httpd:latest"
}
]
}
}'