前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >备战CKA每日一题~第13天 | 真题~静态Pod创建方法与注意点

备战CKA每日一题~第13天 | 真题~静态Pod创建方法与注意点

作者头像
我的小碗汤
发布2019-12-10 17:52:24
9760
发布2019-12-10 17:52:24
举报
文章被收录于专栏:我的小碗汤我的小碗汤

昨日考题

代码语言:javascript
复制
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

请给出操作步骤。

昨日答案

切换至wk8s上下文:

代码语言:javascript
复制
kubectl config use-context wk8s

查看有labelname=wk8s-node-1的node的信息

代码语言:javascript
复制
kubectl get nodes -l name=wk8s-node-1 -o wide

登录指定的机器,并获得操作权限。

代码语言:javascript
复制
ssh wk8s-node-0
sudo -i

查看kubelet服务启动参数--config

代码语言:javascript
复制
systemctl status kubelet -l

在--config指定的文件中,找到staticPodPath文件目录

代码语言:javascript
复制
# cat /var/lib/kubelet/config.yaml|grep staticPodPath
staticPodPath: /etc/kubernetes/manifests

在静态pod目录下创建yaml,使用下面命令生成符合要求的myservice.yaml,等待kubelet自动拉起静态pod

代码语言:javascript
复制
kubectl run myservice --image=nginx --generator=run-pod/v1 --dry-run -o yaml > myservice.yaml

昨日解析

context相关操作官方命令指南: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#config

Create static Pods官网说明: https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/

本题主要考kubelet的配置,以及Static Pod的创建。

可以通过systemctl status kubelet -l查看kubelet进程的配置文件路径。

在这里插入图片描述 以及通过配置文件config.yaml找到staticPodPath

在这里插入图片描述 有时候,情况可能会不一样,systemctl status kubelet -l查到的10-kubeadm.conf中没有config.yaml配置:

在这里插入图片描述 而是将其直接用--pod-manifest-path传入,所以这种情况就需要修改10-kubeadm.conf中的配置路径(如果路径不是期望路径)

代码语言:javascript
复制
--pod-manifest-path=/etc/kubernetes/manifests

修改后需要重启kubelet:

代码语言:javascript
复制
systemctl start kubelet

今日考题

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;

• end •

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-12-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 进击云原生 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 昨日考题
  • 昨日答案
  • 昨日解析
  • 今日考题
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档