备战CKA,每日一题 | 第2天
- 2019 年 11 月 25 日
- 筆記
从昨天开始,正式开始备战CKA考试。看了看昨天考题留言,答题的有十多个,只有2个答对了。

昨日考题
以下 Daemonset yaml 中,哪些是正确的?(多选)
A. apiVersion: apps/v1 kind: DaemonSet metadata: name: fluentd-elasticsearch namespace: default labels: k8s-app: fluentd-logging spec: selector: matchLabels: name: fluentd-elasticsearch template: metadata: labels: name: fluentd-elasticsearch spec: containers: - name: fluentd-elasticsearch image: gcr.io/fluentd-elasticsearch/fluentd:v2.5.1 restartPolicy: NeverB. apiVersion: apps/v1 kind: DaemonSet metadata: name: fluentd-elasticsearch namespace: default labels: k8s-app: fluentd-logging spec: selector: matchLabels: name: fluentd-elasticsearch template: metadata: labels: name: fluentd-elasticsearch spec: containers: - name: fluentd-elasticsearch image: gcr.io/fluentd-elasticsearch/fluentd:v2.5.1 restartPolicy: OnfailureC. apiVersion: apps/v1 kind: DaemonSet metadata: name: fluentd-elasticsearch namespace: default labels: k8s-app: fluentd-logging spec: selector: matchLabels: name: fluentd-elasticsearch template: metadata: labels: name: fluentd-elasticsearch spec: containers: - name: fluentd-elasticsearch image: gcr.io/fluentd-elasticsearch/fluentd:v2.5.1 restartPolicy: AlwaysD. apiVersion: apps/v1 kind: DaemonSet metadata: name: fluentd-elasticsearch namespace: default labels: k8s-app: fluentd-logging spec: selector: matchLabels: name: fluentd-elasticsearch template: metadata: labels: name: fluentd-elasticsearch spec: containers: - name: fluentd-elasticsearch image: gcr.io/fluentd-elasticsearch/fluentd:v2.5.1
昨日答案
CD
昨日解析
在考试时,只允许有考试网站和k8s官网两个标签页。所以平常学习时,尽可能去找官网文档去学习,官网才是最权威的。也可以用书签记录下有用的k8s文档网站https://kubernetes.io/
看到这个问题,如果不确定,直接打开daemonset的官网说明文档,见以下链接:
https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/

A Pod Template in a DaemonSet must have a RestartPolicy equal to Always, or be unspecified, which defaults to Always. Daemonset里的pod Template下必须有RestartPolicy,如果没指定,会默认为Always
restartPolicy 字段,可选值为 Always、OnFailure 和 Never。默认为 Always。一个Pod中可以有多个容器,restartPolicy适用于Pod 中的所有容器。restartPolicy作用是,让kubelet重启失败的容器。
另外Deployment、Statefulset的restartPolicy也必须为Always,保证pod异常退出,或者健康检查 livenessProbe失败后由kubelet重启容器。https://kubernetes.io/zh/docs/concepts/workloads/controllers/deployment
Job和CronJob是运行一次的pod,restartPolicy只能为OnFailure或Never,确保容器执行完成后不再重启。https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
今日考题
在Kubernetes PVC+PV体系下通过CSI实现的volume plugins动态创建pv到pv可被pod使用有哪些组件需要参与?
A. PersistentVolumeController + CSI-Provisoner + CSI controller pluginB. AttachDetachController + CSI-Attacher + CSI controller pluginC. Kubelet + CSI node plugin