k8s发布模板

deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: {{ (datasource "config").name }}
  name: {{ (datasource "config").name }}
  namespace: {{ (datasource "config").namespace }}
spec:
  progressDeadlineSeconds: 600
  revisionHistoryLimit: 10
  replicas: {{ (datasource "config").replicas }}
  selector:
    matchLabels:
      app: {{ (datasource "config").name }}
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: {{ (datasource "config").name }}
    spec:
      topologySpreadConstraints:
      - maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
        labelSelector:
          matchLabels:
            app: {{ (datasource "config").name }}
      containers:
      - env:
        - name: TZ
          value: Asia/Shanghai
        - name: APOLLO_META
          value: {{ (datasource "config").apollo }}
        - name: configServerUrl
          value: {{ (datasource "config").apollo }}
        - name: RUN_ENV
          value: {{ (datasource "config").run_env }}
        - name: SPRING_PROFILES_ACTIVE
          value: {{ (datasource "config").run_env }}
        resources:
          limits:
            #ephemeral-storage: {{ (datasource "config").limits_disk }}
            cpu: {{ (datasource "config").limits_cpu }}
            memory: {{ (datasource "config").limits_mem }}
          requests:
            cpu: {{ (datasource "config").requests_cpu }}
            memory: {{ (datasource "config").requests_mem }}
        image: {{ (datasource "config").image }}:{{ (datasource "config").tag }}
        imagePullPolicy: Always
        restartPolicy: Never (Always)
        imagePullSecrets:
          - name: myregistrykey
        name: app
        volumeMounts:
        - mountPath: {{ (datasource "config").log_dir }}
          name: log-volume
    #  - env:
    #    - name: POD_IP
    #      valueFrom:
    #        fieldRef:
    #          apiVersion: v1
    #          fieldPath: status.podIP
    #    - name: POD_NAME
    #      valueFrom:
    #        fieldRef:
    #          apiVersion: v1
    #          fieldPath: metadata.name
    #    - name: KAFKA_HOSTS
    #      value: '{{ (datasource "config").kafka_hosts }}'
    #    - name: KAFKA_TOPIC
    #      value: {{ (datasource "config").kafka_topic }}
    #    - name: KAFKA_SERVICE
    #      value: {{ (datasource "config").namespace }}-{{ (datasource "config").name }}
    #    image: harbor.saxofintech.com/online/filebeat:7.12.0 
    #    imagePullPolicy: IfNotPresent
    #    name: filebeat
    #    resources:
    #      requests:
    #        cpu: 50m
    #    volumeMounts:
    #    - mountPath: /app/log/
    #      name: log-volume
      dnsPolicy: ClusterFirst
    #  imagePullSecrets:
    #  - name: harbor-secret
      volumes:
      - name: log-volume
        emptyDir:
          sizeLimit: {{ (datasource "config").limits_disk }}

service

apiVersion: v1
kind: Service
metadata:
  labels:
    app: {{ (datasource "config").name }}-svc
  name: {{ (datasource "config").name }}-svc
  namespace: {{ (datasource "config").namespace }}
spec:
  type: ClusterIP
  ports:
  - name: {{ (datasource "config").name }}-{{ $index }}
    port: {{ $element }}
    targetPort: {{ $element }}
    protocol: TCP{{ end }}
  sessionAffinity: ClientIP
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 10800
  selector:
    app: {{ (datasource "config").name }}

ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
  name: {{ (datasource "config").name }}-ingress
  namespace: {{ (datasource "config").namespace }}
spec:
  rules:
  - host: {{ (datasource "config").name }}.{{ (datasource "config").namespace }}.saxok8s.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: {{ (datasource "config").name }}-svc
            port:
              number: {{ $element }}{{ end }}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值