所有命令都验证过,有更好的方式,欢迎留言~~~
CKA 习题和真题汇总
CKA考试经验:报考和考纲
CKA :2019年12月英文原题和分值
CKA考试习题:K8S基础概念--API 对象 CKA考试习题:调度管理- nodeAffinity、podAffinity、Taints CKA考试习题:K8S日志、监控与应用管理 CKA考试习题:网络管理-Pod网络、Ingress、DNS CKA考试习题:存储管理-普通卷、PV、PVC CKA考试习题:安全管理--Network Policy、serviceaccount、clusterrole CKA考试习题:k8s故障排查 CKA真题:题目和解析-1 CKA真题:题目和解析-2 CKA真题:题目和解析-3 CKA真题:题目和解析-4 CKA真题:题目和解析-5 CKA真题:题目和解析-6CKA真题:手动配置TLS BootStrap
更多CKA资料或交流:可加 wei xin :wyf19910905
存储管理 大 纲• 为何需要存储卷?
• 普通存储卷
• 应用中使用普通卷
• 持久化存储卷( PV)
• 持久化存储卷申明( PVC)
• 应用中使用持久化卷
容器部署过程中一般有以下三种数据:
- 启动时需要的初始数据,可以是配置文件
- 启动过程中产生的临时数据,该临时数据需要多个容器间共享
- 启动过程中产生的持久化数据
1. 部署一个deployment应用,使用secret普通卷,该应用启动依赖此secret。
– Deployment的名称为
– 将所用命令、创建的Deployment及secret完整yaml截图上传,注意需要体现依赖特性,如secret删
除后,应用无法启动
# 创建Secrect apiVersion: v1 kind: Secret metadata: name: mysecret type: Opaque data: username: YWRtaW4= password: MWYyZDFlMmU2N2Rm # 创建Deployment apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: run: hwcka-005-1-fly name: hwcka-005-1-fly spec: replicas: 1 selector: matchLabels: run: hwcka-005-1-fly strategy: {} template: metadata: creationTimestamp: null labels: run: hwcka-005-1-fly spec: containers: - image: nginx name: hwcka-005-1-fly volumeMounts: - mountPath: /fly name: fly-volume readOnly: true resources: {} volumes: - secret: secretName: mysecret name: fly-volume status: {}
2. 部署一个statefulset应用,使用持久化卷,通过pvc声明所需的存储大小10G及访问
模式为RWX。
– statefulset的名称为
– 将所用命令、创建的statefulset及pvc完整yaml和证明该应用有在存储中写内容的截图上传# 创建pv apiVersion: v1 kind: PersistentVolume metadata: name: task-pv-volume labels: type: local spec: storageClassName: manual capacity: storage: 10Gi accessModes: - ReadWriteMany hostPath: path: "/home" # 创建PVC apiVersion: v1 kind: PersistentVolumeClaim metadata: name: task-pv-claim spec: storageClassName: manual accessModes: - ReadWriteMany resources: requests: storage: 10Gi # 创建StatefulSet apiVersion: v1 kind: Service metadata: name: hwcka-005-2-fly labels: app: nginx spec: ports: - port: 80 name: web clusterIP: None selector: app: nginx --- apiVersion: apps/v1 kind: StatefulSet metadata: name: web spec: selector: matchLabels: app: nginx # has to match .spec.template.metadata.labels serviceName: "nginx" replicas: 3 # by default is 1 template: metadata: labels: app: nginx # has to match .spec.selector.matchLabels spec: terminationGracePeriodSeconds: 10 containers: - name: nginx image: nginx ports: - containerPort: 80 name: web volumeMounts: - name: www mountPath: /usr/share/nginx/html volumes: - name: www persistentVolumeClaim: claimName: task-pv-claim
作者:琦彦