首页 > 其他 > 详细

Pass variable to K8S

时间:2021-02-23 11:22:33      阅读:16      评论:0      收藏:0      [点我收藏+]

1) Hard code in code base 

2) add in deployment as environment variable 

---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: myapp
  namespace: myapp
spec:
  template:
    spec:
      containers:
      - image: myapp-docker-image
        name: django
        env:
        - name: DJANGO_ALLOWED_HOSTS
          value: "[‘myapp.K8S_INGRESS_ROOT_DOMAIN_NAME‘]"

 3) add in config map

---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: myapp
  namespace: myapp
spec:
  template:
    spec:
      containers:
      - image: myapp-docker-image
        name: django
        env:
        - name: DJANGO_MYAPP_SOME_API_URI    // the variable want to replace
          valueFrom:
          configMapKeyRef:
            name: app-override-env      // config map which includes the key DJANGO....
            key: DJANGO_MYAPP_SOME_API_URI   // the key of the variable in the config map
            optional: true  // If you removed optional: true, and the config map did not exist in the deployment repository or did not contain the key DJANGO_MYAPP_SOME_API_URI, the deployment pipeline would succeed, but the deployment pods would all fail to start.
        ...

 4) Secrect 

---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: myapp
  namespace: myapp
spec:
  replicas: 3
  revisionHistoryLimit: 2
  template:
    metadata:
      labels:
        app: django
    spec:
      containers:
      - image: image-url
        name: django
        env:
        - name: DJANGO_DATABASES
          valueFrom:
            secretKeyRef:
              name: quartz
              key: django.databases

 

Pass variable to K8S

原文:https://www.cnblogs.com/anyu686/p/14433944.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!