kubernetes Deployment 示例

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: study-center-api
  namespace: test
  labels: 
    name: study-center-api
spec:
  replicas: 1
  selector:
    matchLabels: 
      name: study-center-api
  template:
    metadata:
      labels: 
        app: study-center-api
        name: study-center-api
      annotations:
        "blackbox_port": "9003"
        "blackbox_scheme": "tcp"
        "prometheus_io_path": "/"
        "prometheus_io_port": "12346"
        "prometheus_io_scrape": "true"
    spec:
      containers:
      - name: study-center-api
        image: harbor.yutang.cn/app/study-center-api:test_2003241210
        resources:
          limits:
            cpu: "1"
            memory: 1500Mi
          requests:
            cpu: "1"
            memory: 1500Mi
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9003
          protocol: TCP
        readinessProbe:
          tcpSocket:
            port: 9003
          initialDelaySeconds: 20
          periodSeconds: 10
        livenessProbe:
          tcpSocket:
            port: 9003
          initialDelaySeconds: 30
          timeoutSeconds: 1
        env:
        - name: PODIP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: JAR_BALL
          value: '*.jar'
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: CONSUL_OPTS
          value:  --server.port=9003 --spring.application.name=study-center-api --spring.application.node=${PODIP}  --spring.profiles.active=dev  --spring.cloud.consul.discovery.preferIpAddress=true
        volumeMounts:
        - mountPath: /opt/project_dir/logs
          name: logm
        lifecycle:
            preStop:
              exec:
                command:
                - /bin/sh
                - -c
                - curl -v  "http://manager-service:9010/services/manager/remove?name=study-center-api&node=${PODIP}"
         
      - name: filebeat
        image: harbor.yutang.cn/infra/filebeat:v7.4.0
        imagePullPolicy: IfNotPresent
        env:
        - name: ENV
          value: test
        - name: PROJ_NAME
          value: study-center-api
        volumeMounts:
        - mountPath: /logm
          name: logm
      volumes:
      - emptyDir: {}
        name: logm
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      securityContext: 
        runAsUser: 0
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate: 
      maxUnavailable: 1
      maxSurge: 1
  revisionHistoryLimit: 7
  progressDeadlineSeconds: 600


posted @ 2020-12-02 16:52  Done、  阅读(4)  评论(0编辑  收藏  举报