【CKA模拟题】边车容器Shared-Volume的具体用法

在这里插入图片描述
Useful Resources: Persistent Volumes Claim , Pod to Use a PV

题干

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

An existing nginx pod, my-pod-cka and Persistent Volume Claim (PVC) named my-pvc-cka are available. Your task is to implement the following modifications:

  • NOTE:- PVC to PV binding and my-pod-cka pods sometimes takes around 2Mins to Up & Running So Please wait
  • Update the pod to include a sidecar container that uses the busybox image. Ensure that this sidecar container remains operational by including an appropriate command “tail -f /dev/null” .
  • Share the shared-storage volume between the main application and the sidecar container, mounting it at the path /var/www/shared . Additionally, ensure that the sidecar container has read-only access to this shared volume.

现有的nginx pod、my-pod-cka和名为my-pvc-cka的持久卷声明(PVC)是可用的。你的任务是实现以下修改。

  • 注意:PVC到PV绑定和my-pod-cka pods有时需要大约2分钟的时间来启动和运行,所以请等待
  • 更新pod以包含一个使用busybox镜像的sidecar容器。通过添加适当的命令“tail -f /dev/null”来确保sidecar容器保持正常运行。
  • 在主应用程序和sidecar容器之间共享共享存储卷,将它挂载到路径/var/www/shared。另外,确保sidecar容器对这个共享卷具有只读访问权限。

解题思路

  1. 切换集群环境
kubectl config use-context kubernetes-admin@kubernetes
  1. 按照题目的要求修改Pod的资源清单。内容如下
apiVersion: v1
kind: Pod
metadata:
  name: my-pod-cka
spec:
  containers:
    - name: nginx-container
      image: nginx:latest
      ports:
        - containerPort: 80
      volumeMounts:
        - name: shared-storage
          mountPath: /var/www/html
    - name: sidecar-container
      image: busybox:latest
      command: ["tail", "-f", "/dev/null"]
      volumeMounts:
        - name: shared-storage
          mountPath: /var/www/shared
          readOnly: true
  volumes:
    - name: shared-storage
      persistentVolumeClaim:
        claimName: my-pvc-cka

相关推荐

  1. 多态具体

    2024-04-12 20:56:03       36 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-12 20:56:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-12 20:56:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-12 20:56:03       87 阅读
  4. Python语言-面向对象

    2024-04-12 20:56:03       96 阅读

热门阅读

  1. docker版postgresql数据库主从配置

    2024-04-12 20:56:03       46 阅读
  2. LeetCode hoot100-22

    2024-04-12 20:56:03       37 阅读
  3. 汽车的基本结构有哪些?

    2024-04-12 20:56:03       78 阅读
  4. Centos7 部署Zabbix6.0 LTS

    2024-04-12 20:56:03       40 阅读
  5. 4.8作业

    4.8作业

    2024-04-12 20:56:03      47 阅读
  6. 前端小白学习Vue框架(二)

    2024-04-12 20:56:03       41 阅读
  7. qt 系列教程(3) 对话框

    2024-04-12 20:56:03       50 阅读
  8. AcWing 790. 数的三次方根

    2024-04-12 20:56:03       39 阅读
  9. 登录加载动画

    2024-04-12 20:56:03       69 阅读
  10. Sed 命令深度解析:Linux 文本处理的利刃

    2024-04-12 20:56:03       46 阅读
  11. WebKit结构简介

    2024-04-12 20:56:03       49 阅读
  12. [深度学习] 无人车避开赛道边的障碍物

    2024-04-12 20:56:03       52 阅读