美文网首页
Kubernetes ( k8s ) Pod 环境变量

Kubernetes ( k8s ) Pod 环境变量

作者: Hello泽泽 | 来源:发表于2020-04-29 18:18 被阅读0次
    
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: zeze-test-env
    data:
      APP_PORT: "8888"
      APP_URL: "www.linuxhub.cn"
    
    ---
    
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: zeze-test
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: zeze-test
      template:
        metadata:
          labels:
            app: zeze-test
        spec:
          containers:
            - name: nignx
              image: linuxhub/nginx:1.15.5
              ports:
                - containerPort: 80
       
              envFrom:
              - configMapRef:
                  name: zeze-test-env
    
    $  kubectl get pod -l app=zeze-test
    NAME                         READY   STATUS    RESTARTS   AGE
    zeze-test-6fbb8d5985-mldd8   1/1     Running   0          99s
    
    $ kubectl exec -it zeze-test-6fbb8d5985-mldd8 bash
    
    root@zeze-test-6fbb8d5985-mldd8:/# echo $APP_PORT
    8888
    
    root@zeze-test-6fbb8d5985-mldd8:/# echo $APP_URL
    www.linuxhub.cn
    

    相关文章

      网友评论

          本文标题:Kubernetes ( k8s ) Pod 环境变量

          本文链接:https://www.haomeiwen.com/subject/ifvnwhtx.html