1. Core Concepts (13%)
Creating a Pod and Inspecting it
Create the namespace
ckad-prep.In the namespace
ckad-prepcreate a new Pod namedmypodwith the imagenginx:2.3.5. Expose the port80.Identify the issue with creating the container. Write down the root cause of issue in a file named
pod-error.txt.Change the image of the Pod to
nginx:1.15.12.List the Pod and ensure that the container is running.
Log into the container and run the
lscommand. Write down the output. Log out of the container.Retrieve the IP address of the Pod
mypod.Run a temporary Pod using the image
busybox, shell into it and run awgetcommand against the nginx Pod using port 80.Render the logs of Pod
mypod.Delete the Pod and the namespace.
First, create the namespace.
$ kubectl create namespace ckad-prepNext, create the Pod in the new namespace.
$ kubectl run mypod --image=nginx:2.3.5 --restart=Never --port=80 --namespace=ckad-prep
pod/mypod createdYou will see that the image cannot be pulled as it doesn’t exist with this tag.
The list of events can give you a deeper insight.
Go ahead and edit the existing Pod. Alternatively, you could also just use the kubectl set image pod mypod mypod=nginx --namespace=ckad-prep command.
After setting an image that does exist, the Pod should render the status Running.
You can shell into the container and run the ls command.
Retrieve the IP address of the Pod with the -o wide command line option.
Remember to use the --rm to create a temporary Pod.
If you don’t see a command prompt, try pressing enter.
The logs of the Pod should show a single line indicating our request.
Delete the Pod and namespace after you are done.
最后更新于