06--kubernetes.pod管理与投射数据卷

打印 上一主题 下一主题

主题 554|帖子 554|积分 1662

前言:上一章记录了摆设k8s常用的两个方式,这一章就简单一些,整理一下k8s资源对象的设置和管理命令。
1、集群状态查抄

前天搭建的环境,然后关机了两天今天开启后第一时间需要查抄集群环境是否正常
  1. [root@k8s-master1 ~]# kubectl get node
  2. NAME          STATUS   ROLES    AGE     VERSION
  3. k8s-master1   Ready    master   2d17h   v1.19.1
  4. k8s-node1     Ready    <none>   2d17h   v1.19.1
  5. k8s-node2     Ready    <none>   2d17h   v1.19.1
  6. [root@k8s-master1 ~]# kubectl get pod -n kube-system
  7. NAME                                  READY   STATUS    RESTARTS   AGE
  8. coredns-f9fd979d6-f8rxv               1/1     Running   1          2d17h
  9. coredns-f9fd979d6-frrvc               1/1     Running   1          2d17h
  10. etcd-k8s-master1                      1/1     Running   1          2d17h
  11. kube-apiserver-k8s-master1            1/1     Running   1          2d17h
  12. kube-controller-manager-k8s-master1   1/1     Running   1          2d17h
  13. kube-flannel-ds-c576q                 1/1     Running   1          2d17h
  14. kube-flannel-ds-hxkww                 1/1     Running   2          2d17h
  15. kube-flannel-ds-nm9b2                 1/1     Running   2          2d17h
  16. kube-proxy-96cnh                      1/1     Running   1          2d17h
  17. kube-proxy-j5gbf                      1/1     Running   1          2d17h
  18. kube-proxy-pz2l2                      1/1     Running   1          2d17h
  19. kube-scheduler-k8s-master1            1/1     Running   1          2d17h
复制代码
集群状态正常继续今天的操纵
常用查抄命令
  1. 查看service的信息:
  2. [root@k8s-master1 ~]# kubectl get service
  3. 在不同的namespace里面查看service:
  4. [root@k8s-master1 ~]# kubectl get service -n kube-system
  5. -n:namespace名称空间
  6. 查看所有名称空间内的pod:
  7. [root@k8s-master1 ~]# kubectl get pods --all-namespaces
  8. 同时查看多种资源对象的信息:
  9. [root@k8s-master1 ~]# kubectl get pod,service -n kube-system
  10. 查看主节点:
  11. [root@k8s-master1 ~]# kubectl cluster-info
  12. api查询:(写yaml要用)
  13. [root@k8s-master1 ~]# kubectl api-versions
  14. 也可以查看pod的信息
  15. [root@k8s-master1 ~]# kubectl describe node k8s-node1
复制代码
2、命名空间管理

在 Kubernetes(K8s)中,Namespace(命名空间)就像是一个虚拟的隔间,用于将集群中的资源举行逻辑上的分区。通过创建不同的 Namespace,可以有效地管理和隔离资源,实现更高效的资源管理和权限控制。
Namespace 的作用可以形象地比喻为以下几种场景:

  • 资源隔离:想象一下一个大型办公楼,每个部分都有自己的独立办公室。不同的部分(Namespace)在自己的办公室(Namespace)里工作,互不干扰。如许,不同部分的资源(如服务、Pod)就不会相互碰撞或冲突,保持清晰和有序。
  • 资源管理:在办公楼中,全部财政部分的文件、设备和职员都会集在一个区域。类似地,将相干的资源(如应用程序、数据库)放在同一个 Namespace 中,使管理和监控变得更加简单和高效。
  • 权限控制:在办公楼中,门禁系统可以限制哪些人可以进入哪些区域。通过 Kubernetes 的 RBAC(基于角色的访问控制),你可以设置不同的权限,让只有特定角色的人能够访问或管理特定的 Namespace,就像门禁系统控制访问一样。
  • 环境隔离:办公楼的不同楼层可能被筹划成不同的用途:一层用于开发,二层用于测试,三层用于生产。类似地,Kubernetes 中可以创建不同的 Namespace 来分别摆设开发、测试和生产环境,确保各个环境之间相互隔离,提拔安全性和稳固性。
检察命名空间
  1. [root@k8s-master1 ~]# kubectl get namespace
  2. NAME              STATUS   AGE
  3. default           Active   2d17h
  4. kube-flannel      Active   2d17h
  5. kube-node-lease   Active   2d17h
  6. kube-public       Active   2d17h
  7. kube-system       Active   2d17h
  8. [root@k8s-master1 ~]# kubectl get ns
  9. NAME              STATUS   AGE
  10. default           Active   2d17h
  11. kube-flannel      Active   2d17h
  12. kube-node-lease   Active   2d17h
  13. kube-public       Active   2d17h
  14. kube-system       Active   2d17h
复制代码
创建命名空间
  1. 使用yaml文件创建ns
  2. [root@k8s-master1 ~]# mkdir namespace.yaml.d
  3. [root@k8s-master1 ~]# cd namespace.yaml.d/
  4. [root@k8s-master1 namespace.yaml.d]# vim namespace1.yaml
  5. [root@k8s-master1 namespace.yaml.d]# cat namespace1.yaml
  6. ---
  7. apiVersion: v1
  8. kind: Namespace #设定创建资源对象类型
  9. metadata: #元数据
  10.   name: ns-example #ns名字
  11.   labels:
  12.     this_ns_name: name_is_ns-example #标签
  13. 创建ns
  14. [root@k8s-master1 namespace.yaml.d]# kubectl apply -f namespace1.yaml
  15. namespace/ns-example created
  16. 查看ns
  17. [root@k8s-master1 namespace.yaml.d]# kubectl get ns
  18. NAME              STATUS   AGE
  19. default           Active   2d18h
  20. kube-flannel      Active   2d17h
  21. kube-node-lease   Active   2d18h
  22. kube-public       Active   2d18h
  23. kube-system       Active   2d18h
  24. ns-example        Active   15s
  25. [root@k8s-master1 namespace.yaml.d]# kubectl get ns ns-example
  26. NAME         STATUS   AGE
  27. ns-example   Active   46s
  28. [root@k8s-master1 namespace.yaml.d]# kubectl describe namespace ns-example
  29. Name:         ns-example
  30. Labels:       this_ns_name=name_is_ns-example
  31. Annotations:  <none>
  32. Status:       Active
  33. No resource quota.
  34. No LimitRange resource.
  35. 删除ns
  36. [root@k8s-master1 namespace.yaml.d]# kubectl delete -f namespace1.yaml
  37. [root@k8s-master prome]# kubectl delete namespace ns-example
复制代码
一个yaml/yml内可以写两个资源对象
  1. [root@k8s-master1 namespace.yaml.d]# vim namespace2.yml
  2. [root@k8s-master1 namespace.yaml.d]# cat namespace2.yml
  3. ---
  4. apiVersion: v1
  5. kind: Namespace
  6. metadata:
  7.   name: ns-example
  8.   labels:
  9.     this_ns_name: name_is_ns-example
  10. ---
  11. apiVersion: v1
  12. kind: Namespace
  13. metadata:
  14.   name: ns-example2
  15.   labels:
  16.     this_ns_name2: name_is_ns-example
  17. [root@k8s-master1 namespace.yaml.d]# kubectl apply -f namespace2.yml
  18. namespace/ns-example created
  19. namespace/ns-example2 created
  20. [root@k8s-master1 namespace.yaml.d]# kubectl get ns
  21. NAME              STATUS   AGE
  22. default           Active   2d18h
  23. kube-flannel      Active   2d18h
  24. kube-node-lease   Active   2d18h
  25. kube-public       Active   2d18h
  26. kube-system       Active   2d18h
  27. ns-example        Active   6s
  28. ns-example2       Active   6s
复制代码
3、pod管理

3.1、创建pod

任务:发布第一个容器化应用

  • 制作镜像:作为应用开发者,你首先需要制作容器镜像。
  • 组织镜像:将镜像按 Kubernetes 的规范整理,并提交上去。
Kubernetes 项目能"认识"的方式
Kubernetes 不保举直接利用命令行运行容器,而是利用 YAML 或 JSON 设置文件来定义和管理容器。你需要将容器的定义、参数和设置记录在 YAML 文件中,然后利用以下指令运行:
  1. # kubectl create -f 配置文件
复制代码
好处


  • 文件记录了 Kubernetes 运行了什么,便于后续检察。
利用 YAML 创建 Pod
YAML 文件在 Kubernetes 中对应 API 对象。填写字段并提交,Kubernetes 会根据定义创建容器或其他 API 资源。
  1. 编写yaml
  2. [root@k8s-master1 pod.yaml.d]# vim pod1.yml
  3. [root@k8s-master1 pod.yaml.d]# cat pod1.yml
  4. ---
  5. apiVersion: v1
  6. kind: Pod
  7. metadata:
  8.   name: websit
  9.   labels:
  10.     this-pod-name: this-is-websit
  11. spec:
  12.   containers:
  13.     - name: name-of-websit-nginx
  14.       image: linuxserver/nginx
  15.       ports:
  16.         - containerPort: 80
  17.    
  18. #############注意事项#########
  19. 自定义字段命名规则( DNS-1123 标签):
  20.     必须只包含小写字母(a-z)、数字(0-9)和连字符(-)。
  21.     必须以字母或数字开头和结尾。
  22.     不能包含大写字母或其他字符。
复制代码
创建pod
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f pod1.yml
  2. pod/websit created
  3. [root@k8s-master1 pod.yaml.d]# kubectl get pod
  4. NAME     READY   STATUS    RESTARTS   AGE
  5. websit   1/1     Running   0          9s
复制代码
这里有一个需要了解的点:
pod的准备状况指的是Pod是否准备就绪以接收请求,Pod的准备状况取决于容器,即全部容器都准备就绪了,Pod才准备就绪。这时间kubernetes的代理服务才会添加Pod作为后端,而一旦Pod的准备状况变为false(至少一个容器的准备状况为false),kubernetes会将Pod从代理服务的分发后端移除,即不会分发请求给该Pod。
一个pod刚被创建的时间是不会被调度的,由于没有任何节点被选择用来运行这个pod。调度的过程发生在创建完成之后,但是这个过程一样寻常很快,所以通常看不到pod是处于unscheduler状态的除非创建的过程遇到了问题。
pod被调度之后,分配到指定的节点上运行,这时间,如果该节点没有所需要的image,那么将会主动从默认的Docker Hub上pull指定的image,一切就绪之后,看到pod是处于running状态了
3.2、pod管理

检察pod
  1. [root@k8s-master1 pod.yaml.d]# kubectl get pod -o wide
  2. NAME     READY   STATUS    RESTARTS   AGE    IP           NODE        NOMINATED NODE   READINESS GATES
  3. websit   1/1     Running   0          4m5s   10.244.1.2   k8s-node1   <none>           <none>
  4. #在k8s看来创建了一个pod,在node1上使用docker ps可以看到新建的容器
  5. #这里能看到pod的ip,可以尝试访问
复制代码
检察pod的具体信息
  1. [root@k8s-master1 pod.yaml.d]# kubectl describe pod websit -n 命名空间
复制代码

也可以利用yaml导出 
  1. [root@k8s-master1 pod.yaml.d]# kubectl get pod websit -o yaml -n default
复制代码

进入pod
  1. [root@k8s-master1 pod.yaml.d]# kubectl exec -it websit /bin/sh
复制代码
 删除pod
  1. [root@k8s-master1 pod.yaml.d]# kubectl delete pod website
  2. [root@k8s-master1 pod.yaml.d]# kubectl delete -f pod1.yml
  3. 批量删除用法
  4. [root@k8s-master1 pod.yaml.d]# kubectl delete pod --all
  5. [root@k8s-master1 pod.yaml.d]# kubectl delete pod pod名1 pod名2
复制代码
增补:
  1. kubectl create 和 kubectl apply 是两个用于管理 Kubernetes 资源的命令,但它们在处理资源的方式上有一些关键区别。
  2. kubectl create
  3.     功能:用于创建新的资源对象。
  4.     用法:kubectl create -f <file.yaml>
  5.     行为:
  6.         只适用于创建资源。它不会对已经存在的资源进行更新。
  7.         如果你需要更新资源,你必须首先删除现有资源,然后重新创建。例如,如果你修改了 YAML 文件中的配置,你需要先使用 kubectl delete -f <file.yaml> 删除现有的资源,然后使用 kubectl create -f <file.yaml> 重新创建。
  8. kubectl apply
  9.     功能:用于创建或更新资源对象。
  10.     用法:kubectl apply -f <file.yaml>
  11.     行为:
  12.         创建:如果资源不存在,apply 会创建它。
  13.         更新:如果资源已经存在,apply 会自动检测到 YAML 文件中的更改,并更新现有资源。这意味着你可以修改 YAML 文件,然后再次运行 kubectl apply -f <file.yaml>,Kubernetes 会处理更新,无需删除资源。
复制代码
pod的hosts解析
临时创建,删除容器后重新创建失效
操纵方式:进入pod内部编辑hosts文件
永久创建:修改yaml/yml文件
操纵方式如下
  1. [root@k8s-master1 pod.yaml.d]# kubectl delete -f pod1.yml
  2. pod "websit" deleted
  3. [root@k8s-master1 pod.yaml.d]# vim pod1.yml
  4. [root@k8s-master1 pod.yaml.d]# cat pod1.yml
  5. ---
  6. apiVersion: v1
  7. kind: Pod
  8. metadata:
  9.   name: websit
  10.   labels:
  11.     this-pod-name: this-is-websit
  12. spec:
  13.   containers:
  14.     - name: name-of-websit-nginx
  15.       image: linuxserver/nginx
  16.       ports:
  17.         - containerPort: 80
  18.   hostAliases:
  19.   - ip: "192.168.188.101"
  20.     hostnames:
  21.     - "k8s-master"
  22.     - "su-zhu-ji"
  23.     - "www.master.com"
  24.   - ip: "192.168.188.102"
  25.     hostnames:
  26.     - "k8s-node1"
  27.     - "node-node-1"
  28.     - "www.node1.com"
复制代码
 根据此文件创建pod,完成后进入容器,效果如下
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f pod1.yml
  2. pod/websit created
  3. [root@k8s-master1 pod.yaml.d]# kubectl exec -it websit /bin/sh
  4. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  5. root@websit:/# cat /etc/hosts
  6. # Kubernetes-managed hosts file.
  7. 127.0.0.1        localhost
  8. ::1        localhost ip6-localhost ip6-loopback
  9. fe00::0        ip6-localnet
  10. fe00::0        ip6-mcastprefix
  11. fe00::1        ip6-allnodes
  12. fe00::2        ip6-allrouters
  13. 10.244.1.5        websit
  14. # Entries added by HostAliases.
  15. 192.168.188.101        k8s-master        su-zhu-ji        www.master.com
  16. 192.168.188.102        k8s-node1        node-node-1        www.node1.com
  17. root@websit:/# ping www.master.com
  18. PING www.master.com (192.168.188.101): 56 data bytes
  19. 64 bytes from 192.168.188.101: seq=0 ttl=63 time=0.304 ms
  20. 64 bytes from 192.168.188.101: seq=1 ttl=63 time=0.387 ms
  21. 64 bytes from 192.168.188.101: seq=2 ttl=63 time=0.269 ms
  22. ^C
  23. --- www.master.com ping statistics ---
  24. 3 packets transmitted, 3 packets received, 0% packet loss
  25. round-trip min/avg/max = 0.269/0.320/0.387 ms
  26. root@websit:/#
复制代码
3.3、pod生命周期

常见状态:


  • Pending:此状态表示Pod 的 YAML 文件已经提交给了 Kubernetes,API 对象已经被创建并生存在 Etcd 当中(准备状态)。但这个 Pod 里有些容器由于某种原因而不能被顺利创建。比如,调度不乐成。
  • Running:此状态表示Pod 已经调度乐成,跟一个具体的节点绑定。它包罗的容器都已经创建乐成,而且至少有一个正在运行中。(只有这个状态是正常的)
  • Succeeded:此状态表示 Pod 里的全部容器都正常运行完毕,而且已经退出了。这种环境在运行一次性任务时最为常见。
  • Failed:此状态表示 Pod 里至少有一个容器以不正常的状态(非 0 的返回码)退出。这个状态的出现,意味着你得想办法 Debug 这个容器的应用,比如检察 Pod 的 Events 和日记。
  • Unknown:这是一个异常状态(未知状态),表示 Pod 的状态不能一连地被 kubelet 汇报给 kube-apiserver这很有可能是主从节点(Master 和 Kubelet)间的通信出现了问题
其他状态:
CrashLoopBackOff: 容器退出,kubelet正在将它重启
InvalidImageName: 无法解析镜像名称
ImageInspectError: 无法校验镜像
ErrImageNeverPull: 策略克制拉取镜像
ImagePullBackOff: 正在重试拉取
RegistryUnavailable: 毗连不到镜像中心
ErrImagePull: 通用的拉取镜像出错
CreateContainerConfigError: 不能创建kubelet利用的容器设置
CreateContainerError: 创建容器失败
m.internalLifecycle.PreStartContainer  执行hook报错
RunContainerError: 启动容器失败
PostStartHookError: 执行hook报错 
ContainersNotInitialized: 容器没有初始化完毕
ContainersNotReady: 容器没有准备完毕 
ContainerCreating:容器创建中
PodInitializing:pod 初始化中 
DockerDaemonNotReady:docker还没有完全启动
NetworkPluginNotReady: 网络插件还没有完全启动
4、投射数据卷 Projected Volume

Projected Volume 是 Kubernetes v1.11 之后引入的新特性,类似于 Docker 中的映射卷(docker run -v)。
在 Kubernetes 中,有几种特殊的 Volume 不是为了存放容器数据,也不是用来举行容器和宿主机之间的数据互换,而是为了为容器提供预先定义好的数据。从容器的角度来看,这些 Volume 里的信息仿佛是被 Kubernetes "投射"(Project)进入容器当中的。
Kubernetes 支持的 Projected Volume 包罗四种类型(这些在k8s中都被看做资源对象):


  • Secret
  • ConfigMap
  • Downward API
  • ServiceAccount
4.1、secret

secret介绍:


  • secret用来生存小片敏感数据的k8s资源对象,例如暗码,token,或者秘钥。这类数据固然也可以存放在Pod或者镜像中,但是放在Secret中是为了更方便的控制怎样利用数据,并减少袒露的风险。
  • 用户可以创建自己的secret,系统也会有自己的secret。
  • Pod需要先引用才能利用某个secret
pod利用secre的方式:


  • 內建的Secrets::由ServiceAccount创建的API证书附加的秘钥k8s主动天生的用来访问apiserver的Secret,全部Pod会默认利用这个Secret与apiserver通信



  • 创建自己的Secret:利用kubectl create secret命令或yaml文件创建Secret
4.1.1、创建secret

命令创建secret:
  1. [root@k8s-master1 ~]# echo -n 'admin' > username.txt
  2. [root@k8s-master1 ~]# echo -n 'Liumuquan@123' > password.txt
  3. [root@k8s-master1 ~]# kubectl create secret generic db-user-pass --from-file=username.txt --from-file=password.txt
  4. secret/db-user-pass created
  5. [root@k8s-master1 ~]#  kubectl get secret
  6. NAME                  TYPE                                  DATA   AGE
  7. db-user-pass          Opaque                                2      3s
  8. default-token-l87r2   kubernetes.io/service-account-token   3      5d17h
  9. 查看详细信息
  10. [root@k8s-master1 ~]# kubectl describe secret db-user-pass
  11. Name:         db-user-pass
  12. Namespace:    default
  13. Labels:       <none>
  14. Annotations:  <none>
  15. Type:  Opaque
  16. Data
  17. ====
  18. password.txt:  13 bytes
  19. username.txt:  5 bytes
  20. [root@k8s-master1 ~]# kubectl get secret db-user-pass -o yaml
  21. apiVersion: v1
  22. data:
  23.   password.txt: TGl1bXVxdWFuQDEyMw==
  24.   username.txt: YWRtaW4=
  25. kind: Secret
  26. metadata:
  27.   creationTimestamp: "2024-08-20T10:15:04Z"
  28.   managedFields:
  29.   - apiVersion: v1
  30.     fieldsType: FieldsV1
  31.     fieldsV1:
  32.       f:data:
  33.         .: {}
  34.         f:password.txt: {}
  35.         f:username.txt: {}
  36.       f:type: {}
  37.     manager: kubectl-create
  38.     operation: Update
  39.     time: "2024-08-20T10:15:04Z"
  40.   name: db-user-pass
  41.   namespace: default
  42.   resourceVersion: "70826"
  43.   selfLink: /api/v1/namespaces/default/secrets/db-user-pass
  44.   uid: fddaf0fd-96ac-461c-88df-f301a8dcbd08
  45. type: Opaque
复制代码
对data选项举行解码
  1. [root@k8s-master1 ~]# echo TGl1bXVxdWFuQDEyMw== | base64 --decode
  2. Liumuquan@123
复制代码
yaml创建secret:
明文显示容易袒露,先转码,再写入文件
  1. [root@k8s-master1 ~]# echo -n "admin" | base64
  2. YWRtaW4=
  3. [root@k8s-master1 ~]# echo -n "123456" | base64
  4. MTIzNDU2
  5. [root@k8s-master1 ~]# mkdir secret.yaml.d
  6. [root@k8s-master1 ~]# cd secret.yaml.d/
  7. [root@k8s-master1 secret.yaml.d]# vim secret1.yaml
  8. [root@k8s-master1 secret.yaml.d]# cat secret1.yaml
  9. ---
  10. apiVersion: v1
  11. kind: Secret
  12. metadata:
  13.   name: mysecret
  14. type: Opaque
  15. data:
  16.   username: YWRtaW4=
  17.   password: MTIzNDU2
  18. [root@k8s-master1 secret.yaml.d]# kubectl apply -f secret1.yaml
  19. secret/mysecret created
复制代码
检察secret
  1. [root@k8s-master1 secret.yaml.d]# kubectl get secrets
  2. NAME                  TYPE                                  DATA   AGE
  3. db-user-pass          Opaque                                2      22m
  4. default-token-l87r2   kubernetes.io/service-account-token   3      5d17h
  5. mysecret              Opaque                                2      10s
  6. [root@k8s-master1 secret.yaml.d]# kubectl get secret mysecret -o yaml -n default
  7. apiVersion: v1
  8. data:
  9.   password: MTIzNDU2
  10.   username: YWRtaW4=
  11. kind: Secret
  12. metadata:
  13.   annotations:
  14.     kubectl.kubernetes.io/last-applied-configuration: |
  15.       {"apiVersion":"v1","data":{"password":"MTIzNDU2","username":"YWRtaW4="},"kind":"Secret","metadata":{"annotations":{},"name":"mysecret","namespace":"default"},"type":"Opaque"}
  16.   creationTimestamp: "2024-08-20T10:37:34Z"
  17.   managedFields:
  18.   - apiVersion: v1
  19.     fieldsType: FieldsV1
  20.     fieldsV1:
  21.       f:data:
  22.         .: {}
  23.         f:password: {}
  24.         f:username: {}
  25.       f:metadata:
  26.         f:annotations:
  27.           .: {}
  28.           f:kubectl.kubernetes.io/last-applied-configuration: {}
  29.       f:type: {}
  30.     manager: kubectl-client-side-apply
  31.     operation: Update
  32.     time: "2024-08-20T10:37:34Z"
  33.   name: mysecret
  34.   namespace: default
  35.   resourceVersion: "74069"
  36.   selfLink: /api/v1/namespaces/default/secrets/mysecret
  37.   uid: a66ffa02-f40f-4b1b-ab47-efb35c9bc829
  38. type: Opaque
复制代码
4.1.2、引用secret

1)卷挂载方式引用
创建pod文件,并以卷挂载格式引用secret
  1. [root@k8s-master1 pod.yaml.d]# vim pod_use_secret.yaml
  2. [root@k8s-master1 pod.yaml.d]# cat pod_use_secret.yaml
  3. ---
  4. apiVersion: v1
  5. kind: Pod
  6. metadata:
  7.   name: mypod
  8. spec:
  9.   containers:
  10.   - name: testredis
  11.     image: daocloud.io/library/redis
  12.     volumeMounts:    #挂载一个卷
  13.     - name: foo     #这个名字需要与定义的卷的名字一致
  14.       mountPath: "/etc/foo"  #挂载到容器里哪个目录下,随便写
  15.       readOnly: true
  16.   volumes:     #数据卷的定义
  17.   - name: foo   #卷的名字这个名字自定义
  18.     secret:    #卷是直接使用的secret。
  19.       secretName: mysecret   #调用刚才定义的secret
复制代码
创建pod并进入pod检察挂载的目次
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f pod_use_secret.yaml
  2. pod/mypod created
  3. [root@k8s-master1 pod.yaml.d]# kubectl get pod
  4. NAME     READY   STATUS    RESTARTS   AGE
  5. mypod    1/1     Running   0          10s
  6. websit   1/1     Running   0          105m
  7. [root@k8s-master1 pod.yaml.d]# kubectl exec -it mypod /bin/sh
  8. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  9. root@mypod:/# ls /etc/foo
  10. password  username
  11. root@mypod:/# cat /etc/foo/username
  12. admin
复制代码
这种方式会将secret中全部key全部引用
映射secret key
删除刚创建的pod,创建pod文件如下
  1. [root@k8s-master1 pod.yaml.d]# cat pod_use_secret.yaml
  2. ---
  3. apiVersion: v1
  4. kind: Pod
  5. metadata:
  6.   name: mypod
  7. spec:
  8.   containers:
  9.   - name: testnginx
  10.     image: linuxserver/nginx
  11.     volumeMounts:
  12.     - name: foo
  13.       mountPath: "/etc/foo"
  14.       readOnly: true
  15.   volumes:
  16.   - name: foo
  17.     secret:
  18.       secretName: mysecret
  19.       items:   #定义一个items
  20.       - key: username   #将那个key重新定义到那个目录下
  21.         path: my-group/my-username  #相对路径,相对于/etc/foo的路径
复制代码
创建pod并进入pod检察挂载的目次
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f pod_use_secret.yaml
  2. pod/mypod created
  3. [root@k8s-master1 pod.yaml.d]# kubectl get pod
  4. NAME    READY   STATUS    RESTARTS   AGE
  5. mypod   1/1     Running   0          10s
  6. [root@k8s-master1 pod.yaml.d]# kubectl exec -it mypod /bin/sh
  7. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  8. root@mypod:/# ls /etc/foo
  9. my-group
  10. root@mypod:/# ls /etc/foo/my-group/
  11. my-username
  12. root@mypod:/# cat /etc/foo/my-group/my-username
  13. admin
复制代码
修改secret的值,然后重新设置secret
  1. [root@k8s-master1 pod.yaml.d]# echo -n "Administrator" | base64
  2. QWRtaW5pc3RyYXRvcg==
  3. [root@k8s-master1 pod.yaml.d]# vim /root/secret.yaml.d/secret1.yaml
  4. [root@k8s-master1 pod.yaml.d]# cat /root/secret.yaml.d/secret1.yaml
  5. ---
  6. apiVersion: v1
  7. kind: Secret
  8. metadata:
  9.   name: mysecret
  10. type: Opaque
  11. data:
  12.   username: QWRtaW5pc3RyYXRvcg==
  13.   password: MTIzNDU2
  14. [root@k8s-master1 pod.yaml.d]# kubectl apply -f /root/secret.yaml.d/secret1.yaml
  15. secret/mysecret configured
复制代码
secret主动更新
等待一段时间进入pod内部
  1. [root@k8s-master1 pod.yaml.d]# kubectl exec -it mypod /bin/sh
  2. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  3. root@mypod:/# cat /etc/foo/my-group/my-username
  4. Administrator
复制代码
卷挂载方式是可以主动更新的,后面演示的环境变量方式是无法主动更新的
2)环境变量方式引用
以mysql的用户名和暗码为例,先创建secert和pod文件
  1. [root@k8s-master1 pod.yaml.d]# echo -n "root" | base64
  2. cm9vdA==
  3. [root@k8s-master1 pod.yaml.d]# echo -n "Liumuquan@123" | base64
  4. TGl1bXVxdWFuQDEyMw==
  5. [root@k8s-master1 pod.yaml.d]# cat pod_mysql_secert.yaml
  6. ---
  7. apiVersion: v1
  8. kind: Secret
  9. metadata:
  10.   name: mysql-user-pass
  11. type: Opaque
  12. data:
  13.   username: cm9vdA==
  14.   password: TGl1bXVxdWFuQDEyMw==
  15. ---
  16. apiVersion: v1
  17. kind: Pod
  18. metadata:
  19.   name: mysql
  20. spec:
  21.   containers:
  22.   - name: mysql
  23.     image: docker pull registry.cn-chengdu.aliyuncs.com/liumuquan_app/mysql:5.7
  24.     env:
  25.      - name: MYSQL_ROOT_PASSWORD  #创建新的环境变量名称
  26.        valueFrom:
  27.          secretKeyRef:   #调用的key是什么
  28.            name: mysql-user-pass  #变量的值来自于mysecret
  29.            key: password       #username里面的
复制代码
根据yaml文件创建镜像
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f pod_mysql_secert.yaml
复制代码
验证暗码是否设置乐成
  1. [root@k8s-master1 pod.yaml.d]# kubectl exec -it mysql /bin/bash
  2. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  3. bash-4.2# mysql -uroot -p'Liumuquan@123'
  4. mysql: [Warning] Using a password on the command line interface can be insecure.
  5. Welcome to the MySQL monitor.  Commands end with ; or \g.
  6. Your MySQL connection id is 2
  7. Server version: 5.7.44 MySQL Community Server (GPL)
  8. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  13. mysql>
复制代码
修改yaml后应用文件,并不会更新暗码。
4.1.3、私有仓库secret应用

以阿里云私有仓库为例
  1. [root@k8s-master1 pod.yaml.d]# kubectl create secret docker-registry myregistrykey --docker-server=registry.cn-chengdu.aliyuncs.com --docker-username=liumuquan --docker-password=XXXX密码XXXX
复制代码
secret引用

4.2、ConfigMap

ConfigMap 与 Secret 类似,用来存储设置文件的kubernetes资源对象,全部的设置内容都存储在etcd中。ConfigMap 生存的是不需要加密的、应用所需的设置信息。
ConfigMap 的用法几乎与 Secret 完全类似:可以利用 kubectl create configmap 从文件或者目次创建 ConfigMap,也可以直接编写 ConfigMap 对象的 YAML 文件。
创建ConfigMap有四种方式(也可以说是两种)


  • 方式1:通过直接在命令行中指定configmap参数创建,即--from-literal
  • 方式2:通过指定文件创建,即将一个设置文件创建为一个ConfigMap,--from-file=<文件>
  • 方式3:通过指定目次创建,即将一个目次下的全部设置文件创建为一个ConfigMap,--from-file=<目次>
  • 方式4:事先写好尺度的 configmap的yaml文件,然后kubectl create -f 创建
4.2.1、创建configmap

1)命令行--from-literal创建
  1. [root@k8s-master1 ~]# kubectl create configmap test-configmap --from-literal=user=liumuquan --from-literal=pass=mypassword@123
  2. configmap/test-configmap created
  3. [root@k8s-master1 ~]# kubectl get configmap
  4. NAME             DATA   AGE
  5. test-configmap   2      14s
  6. [root@k8s-master1 ~]# kubectl get cm
  7. NAME             DATA   AGE
  8. test-configmap   2      19s
复制代码
2)指定文件创建
  1. [root@k8s-master1 configmap.d]# vim mysql_configmapm_test
  2. [root@k8s-master1 configmap.d]# cat mysql_configmapm_test
  3. key.1 = value-1
  4. key.2 = value-2
  5. key.3 = value-3
  6. key.4 = value-4
  7. [mysqld]
  8. !include /home/wing/mysql/etc/mysqld.cnf
  9. port = 3306
  10. socket = /home/wing/mysql/tmp/mysql.sock
  11. pid-file = /wing/mysql/mysql/var/mysql.pid
  12. basedir = /home/mysql/mysql
  13. datadir = /wing/mysql/mysql/var
  14. [root@k8s-master1 configmap.d]# kubectl create configmap test-configmap2 --from-file=mysql_configmapm_test
  15. configmap/test-configmap2 created
  16. 可以指定多个文件
复制代码
效果如下:

3)指定目次创建 
  1. [root@k8s-master1 configmap.d]# mkdir configmap_test
  2. [root@k8s-master1 configmap.d]# cd configmap_test/
  3. [root@k8s-master1 configmap_test]# pwd
  4. /root/configmap.d/configmap_test
  5. [root@k8s-master1 configmap_test]# vim configmap_test1
  6. [root@k8s-master1 configmap_test]# cat configmap_test1
  7. aaa
  8. bbb
  9. ccc
  10. ddd
  11. a=d
  12. [root@k8s-master1 configmap_test]# vim configmap_test2
  13. [root@k8s-master1 configmap_test]# cat configmap_test2
  14. eee
  15. fff
  16. h=p
  17. [root@k8s-master1 configmap_test]# cd ..
  18. [root@k8s-master1 configmap.d]# kubectl create configmap test-configmap3 --from-file=configmap_test
  19. configmap/test-configmap3 created
复制代码
效果如下:

这里内容格式为key:value,对应为文件名:文件内容 
4)yaml文件创建
  1. [root@k8s-master1 configmap.d]# vim configmap4.yaml
  2. [root@k8s-master1 configmap.d]# cat configmap4.yaml
  3. ---
  4. apiVersion: v1
  5. kind: ConfigMap
  6. metadata:
  7.   name: test-configmap4
  8.   namespace: default
  9. data:
  10.   key1_cache_host: memcached-gcxt
  11.   key2_cache_port: "11211"
  12.   key3_cache_prefix: gcxt
  13.   my.cnf: |
  14.    [mysqld]
  15.    log-bin = mysql-bin
  16.    haha = hehe
  17. [root@k8s-master1 configmap.d]# kubectl apply -f configmap4.yaml
  18. configmap/test-configmap4 created
复制代码
效果如下:

4.2.2、引用configmap

利用ConfigMap有三种方式,一种是通过环境变量的方式,直接通报pod,另一种是通过在pod的命令行下运行的方式,第三种(最常用的)是利用volume的方式挂载入到pod内
 利用卷挂载这里有一个需要注意的地方,就是subPath的利用:
在 Linux 中,将目次 A 挂载到目次 B 时,目次 B 中原有的文件会被目次 A 下的文件覆盖。在 Kubernetes 中,可以利用 subPath 将 ConfigMap 挂载到容器中某个目次的文件中,从而制止覆盖该目次下的其他文件。
利用 subPath 可以将 ConfigMap 或 Secret 挂载为容器中某个目次的文件,而不会覆盖挂载目次下的现有文件。然而,利用 subPath 参数后,设置文件不支持热更新。
卷挂载利用方式如下:
先做一份nginx的设置文件出来
  1. [root@k8s-master1 configmap.d]# cat /etc/nginx/nginx.conf > configmap_nginx
复制代码
创建configmap
  1. [root@k8s-master1 configmap.d]# kubectl create cm cm-nginx --from-file=configmap_nginx
复制代码
创建pod文件并引用configmap
  1. [root@k8s-master1 configmap.d]# cd /root/pod.yaml.d/
  2. [root@k8s-master1 pod.yaml.d]# vim nginx-cm-pod.yaml
  3. [root@k8s-master1 pod.yaml.d]# cat nginx-cm-pod.yaml
  4. ---
  5. apiVersion: v1
  6. kind: Pod
  7. metadata:
  8.   name: nginx-cm-test
  9. spec:
  10.   containers:
  11.   - name: nginx
  12.     image: registry.cn-chengdu.aliyuncs.com/liumuquan_app/nginx:1.20.1
  13.     volumeMounts:
  14.     - name: nginx
  15.       mountPath: /etc/nginx/nginx.conf
  16.       subPath: nginx.conf #只覆盖这一个文件,不影响该路径其他文件
  17.   volumes:
  18.    - name: nginx
  19.      configMap:
  20.        name: cm-nginx
  21.        items:
  22.        - key: configmap_nginx #这个值来自于-o yaml查看
  23.          path: nginx.conf #挂载到pod内产生的文件名
复制代码
创建pod
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f nginx-cm-pod.yaml
  2. pod/nginx-cm-test created
  3. [root@k8s-master1 pod.yaml.d]# kubectl get pod
  4. NAME            READY   STATUS    RESTARTS   AGE
  5. mypod           1/1     Running   1          25h
  6. mysql           1/1     Running   0          5h52m
  7. nginx-cm-test   1/1     Running   0          3s
复制代码
这个cm是利用命令行方式创建的,修改方式有所不同
  1. [root@k8s-master1 pod.yaml.d]# kubectl edit configmap cm-nginx
复制代码
纵然颠末上面方式修改文件,已经创建的pod内并不会随之更新
4.2.3、ConfigMap 的热更新


  • 利用 ConfigMap 挂载的环境变量 (Env) 不会同步更新。
  • 利用 ConfigMap 挂载的卷 (Volume) 中的数据需要一些时间(大约 10 秒)才能同步更新。请注意:

    • 只有通过 YAML 文件创建的 ConfigMap 才支持热更新。
    • 不能利用 subPath 参数。

附注:当 ConfigMap 作为数据卷挂载到 Pod 中时,更新或重新创建 ConfigMap 后,Pod 内部的设置会热更新。但如果 ConfigMap 用作环境变量,环境变量不会主动更新,由于它们在容器启动时被注入,启动后 Kubernetes 不会改变环境变量的值。此外,同一 namespace 中的 Pod 的环境变量是累加的
以下为操纵方式以nginx搭建反向代理为例:
yaml文件如下
  1. [root@k8s-master1 pod.yaml.d]# vim nginx-pod.yaml
  2. [root@k8s-master1 pod.yaml.d]# cat nginx-pod.yaml
  3. ---
  4. apiVersion: v1
  5. kind: ConfigMap
  6. metadata:
  7.   name: configmap-yaml
  8. data:
  9.   server1.conf: |-
  10.     upstream tomcatserver1 {
  11.       server 192.168.15.55:8081;
  12.     }
  13.     server {
  14.       listen 80;
  15.       server_name 8081.max.com;
  16.       location / {
  17.         proxy_pass http://tomcatserver1;
  18.         index index.html index.htm;
  19.         proxy_set_header Host $host;
  20.         proxy_set_header X-Real-IP $remote_addr;
  21.       }
  22.     }
  23. ---
  24. apiVersion: v1
  25. kind: Pod
  26. metadata:
  27.   name: configmap-pod
  28. spec:
  29.   containers:
  30.     - name: nginx
  31.       image: registry.cn-chengdu.aliyuncs.com/liumuquan_app/nginx:1.20.1
  32.       ports:
  33.         - containerPort: 80
  34.       volumeMounts:
  35.         - mountPath: /etc/nginx/conf.d
  36.           name: conf-name
  37.   volumes:
  38.     - name: conf-name
  39.       configMap:
  40.         name: configmap-yaml
  41.         items:
  42.           - key: server1.conf
  43.             path: server1.conf
复制代码
创建cm和pod
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f nginx-pod.yaml
  2. configmap/configmap-yaml created
  3. pod/configmap-pod created
  4. [root@k8s-master1 pod.yaml.d]# kubectl get cm
  5. NAME             DATA   AGE
  6. cm-nginx         1      46m
  7. configmap-yaml   1      17s
  8. [root@k8s-master1 pod.yaml.d]# kubectl get pod
  9. NAME            READY   STATUS    RESTARTS   AGE
  10. configmap-pod   1/1     Running   0          21s
  11. mypod           1/1     Running   1          25h
  12. mysql           1/1     Running   0          6h13m
  13. nginx-cm-test   1/1     Running   0          21m
复制代码
进入刚创建的pod内部检察设置
  1. [root@k8s-master1 pod.yaml.d]# kubectl exec -it configmap-pod /bin/sh
  2. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  3. # ls /etc/nginx/conf.d/   
  4. server1.conf
  5. # cat /etc/nginx/conf.d/server1.conf
  6. upstream tomcatserver1 {
  7.   server 192.168.15.55:8081;
  8. }
  9. server {
  10.   listen 80;
  11.   server_name 8081.max.com;
  12.   location / {
  13.     proxy_pass http://tomcatserver1;
  14.     index index.html index.htm;
  15.     proxy_set_header Host $host;
  16.     proxy_set_header X-Real-IP $remote_addr;
  17.   }
  18. }#
复制代码
出去修改cm内容,查抄热更新
  1. [root@k8s-master1 pod.yaml.d]# vim nginx-pod.yaml
  2. [root@k8s-master1 pod.yaml.d]# kubectl apply nginx-pod.yaml
  3. error: must specify one of -f and -k
  4. [root@k8s-master1 pod.yaml.d]# kubectl apply -f nginx-pod.yaml
  5. configmap/configmap-yaml configured
  6. pod/configmap-pod configured
  7.     #    此处需要等待一段时间,热更新速度较慢
  8. [root@k8s-master1 pod.yaml.d]# kubectl exec -it configmap-pod /bin/bash
  9. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  10. root@configmap-pod:/# cat /etc/nginx/conf.d/server1.conf
  11. upstream tomcatserver1 {
  12.   server 111.111.111.111:1111;
  13. }
  14. server {
  15.   listen 2222;
  16.   server_name 3333.max.com;
  17.   location / {
  18.     proxy_pass http://tomcatserver1;
  19.     index index.html index.htm;
  20.     proxy_set_header Host $host;
  21.     proxy_set_header X-Real-IP $remote_addr;
  22.   }
  23. }root@configmap-pod:/#
  24. 内部ip和端口已经被修改,此时无需重启nginx,配置自动载入
复制代码
4.3、Downward API

Downward API 用于在容器中获取 POD 的根本信息,kubernetes支持 Downward API提供了两种方式用于将 POD 的信息注入到容器内部,无需提前创建:

  • 环境变量:用于单个变量,可以将 POD 信息和容器信息直接注入容器内部。
  • Volume挂载:将 POD 信息天生为文件,直接挂载到容器内部中去。
环境变量的方式:
通过Downward API来将 POD 的 IP、名称以及所对应的 namespace 注入到容器的环境变量中去,然后在容器中打印全部的环境变量来举行验证
利用fieldRef获取 POD 的根本信息,示例如下:
  1. [root@k8s-master1 pod.yaml.d]# vim test-env-pod.yml
  2. [root@k8s-master1 pod.yaml.d]# cat test-env-pod.yml
  3. ---
  4. apiVersion: v1
  5. kind: Pod
  6. metadata:
  7.     name: test-env-pod
  8.     namespace: kube-system
  9. spec:
  10.     containers:
  11.     - name: test-env-pod
  12.       image: registry.cn-chengdu.aliyuncs.com/liumuquan_app/nginx:1.20.1
  13.       env:
  14.       - name: POD_NAME   #第一个环境变量的名字
  15.         valueFrom:      #使用valueFrom方式设置
  16.           fieldRef:    #关联一个字段metadata.name(元数据的字段)
  17.             fieldPath: metadata.name  #这个字段从当前运行的pod详细信息查看
  18.       - name: POD_NAMESPACE
  19.         valueFrom:
  20.           fieldRef:
  21.             fieldPath: metadata.namespace
  22.       - name: POD_IP
  23.         valueFrom:
  24.           fieldRef:
  25.             fieldPath: status.podIP
  26. 这个podIP可以通过-o yaml查看
复制代码
创建pod,进入pod检察设置的环境变量
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f test-env-pod.yml
  2. [root@k8s-master1 pod.yaml.d]# kubectl get pod -n kube-system | grep test
  3. test-env-pod                          1/1     Running   0          4m45s
  4. [root@k8s-master1 pod.yaml.d]# kubectl exec -it test-env-pod -n kube-system /bin/bash
  5. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  6. root@test-env-pod:/# echo $POD_NAME
  7. test-env-pod
  8. root@test-env-pod:/# echo $POD_NAMESPACE
  9. kube-system
  10. root@test-env-pod:/# echo $POD_IP      
  11. 10.244.1.9
复制代码
Volume挂载
通过Downward API将 POD 的 Label、Annotation 等信息通过 Volume 挂载到容器的某个文件中去,然后在容器中打印出该文件的值来验证
操纵如下:
  1. [root@k8s-master1 pod.yaml.d]# vim test-volume-pod.yaml
  2. [root@k8s-master1 pod.yaml.d]# cat test-volume-pod.yaml
  3. ---
  4. apiVersion: v1
  5. kind: Pod
  6. metadata:
  7.    name: test-volume-pod
  8.    namespace: kube-system
  9.    labels:
  10.        k8s-app: test-volume
  11.        node-env: test
  12. spec:
  13.    containers:
  14.    - name: test-volume-pod-container
  15.      image: registry.cn-chengdu.aliyuncs.com/liumuquan_app/nginx:1.20.1
  16.      volumeMounts:
  17.      - name: podinfo
  18.        mountPath: /etc/podinfo
  19.    volumes:
  20.    - name: podinfo
  21.      downwardAPI:
  22.        items:
  23.        - path: "labels"
  24.          fieldRef:
  25.            fieldPath: metadata.labels
复制代码
创建pod,进入pod检察设置的环境变量
  1. [root@k8s-master1 pod.yaml.d]# kubectl apply -f test-volume-pod.yaml
  2. pod/test-volume-pod created
  3. [root@k8s-master1 pod.yaml.d]# kubectl get pod -n kube-system | grep test-volume-pod
  4. test-volume-pod                       1/1     Running   0          32s
  5. [root@k8s-master1 pod.yaml.d]# kubectl exec -it test-volume-pod -n kube-system /bin/bash
  6. kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
  7. root@test-volume-pod:/# cat /etc/podinfo/labels
  8. k8s-app="test-volume"
  9. node-env="test"root
复制代码
在实际应用中,如果你的应用有获取 POD 的根本信息的需求,就可以利用Downward API来获取根本信息,然后编写一个启动脚本或者利用initContainer将 POD 的信息注入到容器中去,然后在自己的应用中就可以正常的处理相干逻辑了。
现在 Downward API 支持的字段(常用部分):
  1. 1. 使用 fieldRef 可以声明使用:
  2. spec.nodeName - 宿主机名字
  3. status.hostIP - 宿主机 IP
  4. metadata.name - Pod 的名字
  5. metadata.namespace - Pod 的 Namespace
  6. status.podIP - Pod 的 IP
  7. spec.serviceAccountName - Pod 的 Service Account 的名字
  8. metadata.uid - Pod 的 UID
  9. metadata.labels['<KEY>'] - 指定 <KEY> 的 Label 值
  10. metadata.annotations['<KEY>'] - 指定 <KEY> 的 Annotation 值
  11. metadata.labels - Pod 的所有 Label
  12. metadata.annotations - Pod 的所有 Annotation
复制代码
Secret、ConfigMap,以及 Downward API 这三种 Projected Volume 定义的信息,大多还可以通过环境变量的方式出现在容器里。但是,通过环境变量获取这些信息的方式,不具备主动更新的本事。一样寻常环境下,发起利用 Volume 文件的方式获取这些信息(根据资源对象用途判断)。
4.4、ServiceAccount

ServiceAccount是一种 Kubernetes 资源,用于提供身份给 Pod。ServiceAccount 允许 Pod 访问 Kubernetes API 服务器,通常是为了举行 API 操纵或与 Kubernetes 集群交互。ServiceAccount 通常与角色(Role)和角色绑定(RoleBinding)结合利用,以控制 Pod 访问 Kubernetes API 的权限。
利用场景


  • 为 Pod 提供访问 Kubernetes API 的权限。
  • 定义 Pod 访问集群资源的权限和方式。
这一部分先临时做一个了解,后面会在用到的地方举行具体表明

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

大号在练葵花宝典

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表