Yesterday's examination questions
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
Please give the operation steps.
Yesterday's answer
Switch to wk8s context:
kubectl config use-context wk8s
View the information of nodes with labelname=wk8s-node-1
kubectl get nodes -l name=wk8s-node-1 -o wide
Log in to the specified machine and obtain operation permission.
ssh wk8s-node-0 sudo -i
View kubelet service startup parameters -- config
systemctl status kubelet -l
In the file specified by -- config, locate the staticPodPath file directory
# cat /var/lib/kubelet/config.yaml|grep staticPodPath staticPodPath: /etc/kubernetes/manifests
Create yaml in the static pod directory, use the following command to generate the required myservice.yaml, and wait for kubelet to automatically pull up the static pod
kubectl run myservice --image=nginx --generator=run-pod/v1 --dry-run -o yaml > myservice.yaml
Yesterday's analysis
Official command guide for context related operations: 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/
This paper mainly tests the configuration of kubelet and the creation of Static Pod.
You can view the configuration file path of the kubelet process through systemctl status kubelet - L. And find staticPodPath through the configuration file config.yaml. Sometimes, the situation may be different. There is no config.yaml configuration in the 10-kubeadm.conf found in systemctl status kubelet - L: Instead, it is passed in directly with -- pod manifest path, so in this case, you need to modify the configuration path in 10-kubeadm.conf (if the path is not the expected path)
--pod-manifest-path=/etc/kubernetes/manifests
After modification, you need to restart kubelet:
systemctl start kubelet
Today's exam questions
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;
Author brief introduction
Author: small bowl soup, a love and serious writing guy, now maintain the original official account: "my little bowl soup", focus on writing linux, golang, docker, kubernetes and other knowledge to enhance hard power articles, and expect your attention. Reprint: Please specify the source (Note: from the official account: my small bowl soup, the author: small bowl soup)
Author concise
Author: small bowl soup, a love and serious writing guy, now maintains the original official account: "my little bowl soup", focuses on writing go, docker, kubernetes, java and other development, operation and maintenance knowledge and other articles to enhance hard power, and expects your attention. Reprint: Please specify the source (Note: from the official account: my small bowl soup, the author: small bowl soup)