Preparing for a title CKA Daily - Day 13 | Exams static creation methods Pod, Pod DNS test questions

This event was held on the public micro-channel number [my] little bowl of soup, there are activities to send the book! Here the answer can not participate in the activities involved in delivering books Oh!

Yesterday exam

Set configuration context $ kubectl config use-context wk8s

configure the kubelet systemed managed service, on the node labelled with name=wk8s-node-1,to launch a pod containing a single container of image nginx named myservice automatically.

Any spec file requried should be placed in the /etc/kuberneteds/mainfests directory on the node

Hints:

You can ssh to the failed node using $ ssh wk8s-node-0

You can assume elevated privileges on the node with the following command $ sudo -i

Give steps.

Yesterday's answer

Context switching to wk8s:

kubectl config use-context wk8s

Access to the label name=wk8s-node-1information of the node

kubectl get nodes -l name=wk8s-node-1 -o wide

Login specified machine and obtain operating authority.

ssh wk8s-node-0
sudo -i

View kubelet service startup parameters -config

systemctl status kubelet -l

In -config specified file, locate the file directory staticPodPath

# cat /var/lib/kubelet/config.yaml|grep staticPodPath
staticPodPath: /etc/kubernetes/manifests

Yaml created in static pod directory, use the following command to generate to meet the requirements of myservice.yaml, wait kubelet automatically pull up a static pod

kubectl run myservice --image=nginx --generator=run-pod/v1 --dry-run -o yaml > myservice.yaml

Yesterday analysis

context related operations command official guide:
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#config

Create static Pods official website Description:
https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/

The main question kubelet test configuration, as well as the creation Static Pod.

You can systemctl status kubelet -lview the profile path kubelet process.
Here Insert Picture Description
And through configuration files config.yamlfound staticPodPath.
Here Insert Picture Description
Sometimes, the situation may be different, systemctl status kubelet -lfound in 10-kubeadm.confno config.yamlconfigurations:
Here Insert Picture Description
but be directly --pod-manifest-pathpassed, so this will need to modify 10-kubeadm.confthe configuration path (if the path is not the desired path)

--pod-manifest-path=/etc/kubernetes/manifests

After modifications need to restart kubelet:

systemctl start kubelet

Exam today

Set configuration context $ kubectl config use-context k8s;

Create a deployment as follows;

Name: nginx-dns;

Exposed via a service: nginx-dns;

Ensure that the service & pod are accessible via their respective DNS records;

The container(s) within any pod(s) running as a part of this deployment should use the nginx image;

Next,use the utiliity nslookup to look up the DNS records of the service & pod and write the output to /opt/service.dns and /opt/pod.dns respectively;

Ensure you use the busybox:1.28 image (or earliser) for any testing, an the latest release has an unpstream bug which impacts the use of nslookup;

作者简介

作者:小碗汤,一位热爱、认真写作的小伙,目前维护原创公众号:『我的小碗汤』,专注于写linux、golang、docker、kubernetes等知识等提升硬实力的文章,期待你的关注。转载说明:务必注明来源(注明:来源于公众号:我的小碗汤, 作者:小碗汤)

发布了125 篇原创文章 · 获赞 8 · 访问量 2万+

Guess you like

Origin blog.csdn.net/ll837448792/article/details/103417876