k8s配置容器的环境变量可以直接使用Java获取或Spring的@Value获取

apiVersion: apps/v1
kind: Deployment
metadata:
  name: xxx-dev
  namespace: open
spec:
  replicas: 1
  selector:
    matchLabels:
      name: xxx
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:
    metadata:
      labels:
        name: xxx
    spec:
      containers:
      - name: xxx
        image: /public-repository/testsl/xxx:0.0.0
        imagePullPolicy: Always
        env:        
        - name: TCP_PORT
          value: '21399'
        - name: STR_DELIMITER
          value: ']'
        resources:
          limits:
            cpu: '1'
            memory: 1024Mi
          requests:
            cpu: 500m
            memory: 128Mi
        volumeMounts:
        - name: hosts
          mountPath: /etc/hosts
          subPath: hosts
        - name: logs
          mountPath: /www/logs/
      volumes:
      - name: hosts
        hostPath:
          path: /etc/
      - name: logs
        hostPath:
          path: /logs/
      imagePullSecrets:
      - name: xxxxxxx
      nodeSelector:
        lable_open: open

猜你喜欢

转载自blog.csdn.net/qq_30038111/article/details/111823146