k8s中Deployment模板

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



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值