【CKA模拟题】StorageClass实战案例分析

在这里插入图片描述

Useful Resources: Storage Classes , Persistent Volumes Claim , Pods

题干

For this question, please set this context (In exam, diff cluster name)
kubectl config use-context kubernetes-admin@kubernetes

  • Create a Storage Class named fast-storage with a provisioner of kubernetes.io/no-provisioner and a volumeBindingMode of Immediate .
  • Create a Persistent Volume (PV) named fast-pv-cka with a storage capacity of 50Mi using the fast-storage Storage Class with ReadWriteOnce permission and host path /tmp/fast-data .
  • Create a Persistent Volume Claim (PVC) named fast-pvc-cka that requests 30Mi of storage from the fast-pv-cka PV(using the fast-storage Storage Class).
  • Create a Pod named fast-pod-cka with nginx:latest image that uses the fast-pvc-cka PVC and mounts the volume at the path /app/data .
  • 使用kubernetes.io/no-provision提供程序创建一个名为fast-storage的存储类。volumeBindingModeImmediate
  • 创建一个名为fast-pv-cka的持久卷,存储容量为50Mi,使用fast-storage存储类,具有 ReadWriteOnce权限,主机路径为/tmp/fast-data
  • 创建一个名为fast-pvc-cka的持久卷声明(PVC),它从fast-pv-cka PV请求30Mi的存储空间(使用fast-storage存储类)。
  • 使用nginx:latest 镜像创建一个名为fast-pod-cka的Pod,使用fast-pvc-cka PVC并将卷挂载到/app/data路径。

解题思路

  1. 创建一个名为 fast-storage的Storage CLass。资源清单如下:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast-storage
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
allowVolumeExpansion: true
volumeBindingMode: Immediate
  1. 提交fast-storage.yaml资源清单,如下
controlplane $ k apply  -f fast-storage.yaml 
storageclass.storage.k8s.io/fast-storage created
  1. 创建一个名为fast-pv-cka的PV,资源清单如下:
apiVersion: v1
kind: PersistentVolume
metadata:
  name: fast-pv-cka
spec:
  storageClassName: fast-storage
  capacity:
    storage: 50Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/tmp/fast-data"
  1. 提交fast-pv-cka.yaml资源清单,如下
controlplane $ k apply -f fast-pv-cka.yaml 
persistentvolume/fast-pv-cka created
  1. 创建一个名为fast-pvc-cka的PV,资源清单如下:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: fast-pvc-cka
spec:
  storageClassName: fast-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 30Mi
  1. 提交fast-pvc-cka.yaml资源清单,如下
controlplane $ k apply -f fast-pvc-cka.yaml 
persistentvolumeclaim/fast-pvc-cka created
  1. 创建一个名为fast-pod-cka的pod,资源清单如下:
apiVersion: v1
kind: Pod
metadata:
  name: fast-pod-cka
spec:
  volumes:
    - name: pv-storage
      persistentVolumeClaim:
        claimName: fast-pvc-cka
  containers:
    - name: nginx-container
      image: nginx:latest
      volumeMounts:
        - mountPath: "/app/data"
          name: pv-storage
  1. 提交fast-pod-cka.yaml资源清单,如下
controlplane $ k apply -f fast-pod-cka.yaml 
pod/fast-pod-cka created
  1. 验证结果
controlplane $ k get pod
NAME           READY   STATUS    RESTARTS   AGE
fast-pod-cka   1/1     Running   0          38s

相关推荐

  1. 模拟CAS算法案例

    2024-04-04 23:28:03       6 阅读
  2. 团队建设与管理案例分析

    2024-04-04 23:28:03       20 阅读
  3. IT服务监督管理案例分析

    2024-04-04 23:28:03       18 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-04 23:28:03       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-04 23:28:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-04 23:28:03       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-04 23:28:03       20 阅读

热门阅读

  1. 蓝桥杯备考随手记: practise04

    2024-04-04 23:28:03       18 阅读
  2. 文心一言 vs GPT-4 -- 全面横向比较

    2024-04-04 23:28:03       15 阅读
  3. Universal_Robots_ROS2_Driver 安装问题详解(humble)

    2024-04-04 23:28:03       14 阅读
  4. webpack 热更新的实现原理

    2024-04-04 23:28:03       16 阅读
  5. 开发人员小张出场

    2024-04-04 23:28:03       14 阅读
  6. DAY01

    2024-04-04 23:28:03       21 阅读
  7. 010 Editor常用语法

    2024-04-04 23:28:03       15 阅读