k8s secrets configmap资源

secrets资源
secrets: 存放密码,密钥,证书
base64解码

kubectl create secret docker-registry harbor-secret --namespace=default  --docker-username=admin  --docker-password=a123456 --docker-server=docker.io

[root@k8s-master ~]# cat k8s_pod.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: test
  labels:
    app: web
spec:
  imagePullSecrets:
    - name: harbor-secret
  containers:
    - name: alpine
      image: admin/test
      command: ["sleep","1000"]
configmap资源
configmap:存放配置文件

vi /opt/81.conf
i    server {
        listen       81;
        server_name  localhost;
        root         /html;
        index      index.html index.htm;
        location / {
        }
    }

kubectl create configmap 81.conf --from-file=/opt/81.conf
#验证
kubectl get cm

vi k8s_deploy.yaml
iapiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      volumes:
        - name: nginx-config
          configMap:
            name: 81.conf
            items:
              - key: 81.conf
                path: 81.conf
      containers:
      - name: nginx
        image: 10.0.0.11:5000/nginx:1.13
        volumeMounts:
          - name: nginx-config
            mountPath: /etc/nginx/conf.d
        ports:
        - containerPort: 80
          name: port1
        - containerPort: 81
          name: port2