k8s中Deployment模板

  • Post author:
  • Post category:其他


apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: app-api
  name: app-api
spec:
  replicas: 1  #pod副本数
  selector:
    matchLabels:
      app: tomcat
  template:
    metadata:
      labels:
        app: tomcat
    spec:
      nodeSelector:  #设置pod运行的节点
        nodeRole: tool
      tolerations:	#设置节点容忍度
      - key: "node-role.kubernetes.io/master"
        operator: "Exists"
        effect: "NoSchedule"
      hostAliases:
      - hostnames: #设置pod内host解析
        - mysql
        ip: 1.2.3.4
      - hostnames:
        - zookeeper
        ip: 1.2.3.5
      containers:
      - image: tomcat
        imagePullPolicy: IfNotPresent ##Always,IfNotPresent,Never
        name: tomcat
        env:  #阿里云log-pilot日志收集
        - name: aliyun_logs_access 
          value: "/data/logs/*.log*"
        - name: aliyun_logs_access_tags   #定义一个tag
          value: "topic=app-api"               
        livenessProbe:	#健康检查
          httpGet:   # tcpSocket,exec
            path: /
            port: 8080
          initialDelaySeconds: 60	#pod初始化时间
          timeoutSeconds: 20
        readinessProbe:	#健康检查
          httpGet:
            path: /
            port: 8080
          initialDelaySeconds: 60
          timeoutSeconds: 20
        resources:  #资源限制
          limits:
            cpu: 100m
            memory: 100Mi
          requests:
            cpu: 10m
            memory: 10Mi
        volumeMounts: #挂载PV
        - name: hostPath-logs
          mountPath: /data/logs
      volumes:
        - name: hostPath-logs #声明PV
          hostPath:  
            path: /data/logs/app/api
            type: Directory
        - name: emptyDir-data
          emptyDir: {}
        - name: glusterfs-data
          glusterfs:
            endpoints: "glusterfs-cluster"
            path: "k8s-disperse-vol"
            readOnly: false
        - name: pvc-data
          persistentVolumeClaim:
            claimName: pvc-name





版权声明:本文为PlatoWG原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。