[root@k8s-master-01 k8s]# kubectl get cm
NAME               DATA   AGE
kube-root-ca.crt   1      24h
[root@k8s-master-01 k8s]# kubectl get cm kube-root-ca.crt -o yaml
apiVersion: v1
data:
  ca.crt: |
    -----BEGIN CERTIFICATE-----
    MIIC/jCCAeagAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwprdWJl
    cm5ldGVzMB4XDTIyMDIwODA5NDM0MVoXDTMyMDIwNjA5NDM0MVowFTETMBEGA1UE
    AxMKa3ViZXJuZXRlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKBm
    GL1CBfVVJIsEgwDKMXoMdq4O/mHcvb4sr8xEh0TlV3r1dFrpRScf9WCQJ2CDERUZ
    M6Ast2B7+C8rgZ84dAKBZzzB38foHplaCHeoWElDc0xDUwiFg5fe0JwW5zJT/Z4C
    b8Hm9KDjvv0UHrY731rqiQgrUP0g9ul5PR90YcRrcMSXrz25YEnAQETK2JT5IY1e
    bBtA6SdFrB3WPUXjRnbUgElXkf/1kxhSFXAVLTp2Q9KOEw/vlEi1Vts6IMXeAnaH
    0WPYvnX6bTYwF9weeqSK5dmmdQrlO5PjfsUKxFQhDqowanFy7lTP5tzQPhGrgt7E
    87hhvlaonMA8v8oxc3UCAwEAAaNZMFcwDgYDVR0PAQH/BAQDAgKkMA8GA1UdEwEB
    /wQFMAMBAf8wHQYDVR0OBBYEFOnfJU8RVInGR7D/dlkOlHbe9LP3MBUGA1UdEQQO
    MAyCCmt1YmVybmV0ZXMwDQYJKoZIhvcNAQELBQADggEBAF6Xi5xCMSfpy2HbvKDw
    Cug296w0VQbhE3JbpVKeH06ctmWneLrFW7ZmGF5iUcdiXsQlyJrxOPIE+I3bdhGi
    0LKbHcbXWlBfLFTr4FifI5SDkMfGgtO3XLi8YtYg0cJWHPGTf9UYW+6H9z2bNPmk
    tbOQXqhs653wM4hya8Lzzeunr4BGedmokZxPRxILto3MyUxbpmmCUDYlQgZ/kPYJ
    1ZbrRx3LCQtL800DJRyELt0LGvy697PRjWkT8qtsOHlewXOyay0f2rhLhw4HWOIE
    8VoDAZyUYZWUfqJyN+ui78XEynMG0+1N1SWL7BLqYhVUsL4mUnYa5FxNu9kLblHw
    fPw=
    -----END CERTIFICATE-----
kind: ConfigMap
metadata:
  annotations:
    kubernetes.io/description: Contains a CA bundle that can be used to verify the
      kube-apiserver when using internal endpoints such as the internal service IP
      or kubernetes.default.svc. No other usage is guaranteed across distributions
      of Kubernetes clusters.
  creationTimestamp: "2022-02-11T04:15:43Z"
  name: kube-root-ca.crt
  namespace: app01
  resourceVersion: "113705"
  uid: 1aa05be5-3073-4933-86ad-a2d552c0ea2d


[root@k8s-master-01 k8s]# kubectl create cm nginx-conf --from-file=/tmp/nginx.conf
configmap/nginx-conf created
[root@k8s-master-01 k8s]# kubectl get cm nginx-conf
NAME         DATA   AGE
nginx-conf   1      9s
[root@k8s-master-01 k8s]# cat nginxConfTest.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: www05
  name: www05
spec:
  volumes:
  - name: v1
    configMap:
      name: nginx-conf
  containers:
  - image: nginx
    name: www05
    resources: {}
    volumeMounts:
    - name: v1
      mountPath: /ect/nginx/nginx.conf
      subPath: nginx.conf
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
[root@k8s-master-01 k8s]# kubectl apply -f nginxConfTest.yaml

[root@k8s-master-01 k8s]# kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
dbpod   1/1     Running   0          44m
www05   1/1     Running   0          31s
[root@k8s-master-01 k8s]# kubectl exec www05 -it -- bash
root@www05:/# ls /etc/nginx/nginx.conf
/etc/nginx/nginx.conf
#在线修改配置文件
[root@k8s-master-01 k8s]# kubectl edit cm nginx-conf 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐