k8s和prometheus的yaml模板

本文详细描述了一个Kubernetes中的Deployment配置,包括应用版本、副本数、标签选择、滚动更新策略,以及与之关联的Service和Ingress配置,展示了如何使用Traefik进行流量路由和访问控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    creator: demouser
    description: create from ship
    owner_name: ship-test-service-02
    prometheus.io/path: /prometheus
    prometheus.io/port: "8080"
    prometheus.io/scrape: "true"
  creationTimestamp: null
  labels:
    app: ship-test-service-02
    app_id: "231003"
    appversion: e9e4fa10-default-1679301625-n49t2
    base_name: ship-test-service-02
    company_id: "79002"
    domain_suffix: prd.za-tech.net
    flow_id: 674fe4d9569b
    initcontainerset.kubecloud.io/za-repeater-agent: ""
    prime_department_id: "10120001"
    project_id: "21003"
    publish_version: v1-2581
    version: btzsg
  name: ship-test-service-02-btzsg
  namespace: product
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ship-test-service-02
      version: btzsg
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        creator: demouser
        description: create from ship
        owner_name: ship-test-service-02
        prometheus.io/path: /prometheus
        prometheus.io/port: "8080"
        prometheus.io/scrape: "true"
      creationTimestamp: null
      labels:
        app: ship-test-service-02
        app_id: "231003"
        appversion: e9e4fa10-default-1679301625-n49t2
        base_name: ship-test-service-02
        company_id: "79002"
        domain_suffix: prd.za-tech.net
        flow_id: 674fe4d9569b
        initcontainerset.kubecloud.io/za-repeater-agent: ""
        prime_department_id: "10120001"
        project_id: "21003"
        publish_version: v1-2581
        version: btzsg
      name: ship-test-service-02-btzsg
      namespace: product
    spec:
      affinity: {}
      containers:
      - env:
        - name: DEPLOY_ENV
          value: prd
        - name: DEPLOY_BIZ_ENV
          value: prd
        - name: REPEATER_APP_NAME
          value: ship-test-service-01
        - name: SERVICE_CHECK_HTTP
          value: /health
        - name: SERVICE_CHECK_INTERVAL
          value: 30s
        - name: SERVICE_CHECK_TIMEOUT
          value: 8s
        - name: HOST_IP
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: status.hostIP
        - name: PUBLISH_ENV
          value: prd_ci
        - name: PUBLISH_VERSION
          value: v1-2581
        image: poc-registry.zhonganinfo.com/10001/ship-test-service-02:e9e4fa10-default-1679301625
        imagePullPolicy: Always
        lifecycle: {}
        livenessProbe:
          failureThreshold: 5
          initialDelaySeconds: 30
          periodSeconds: 60
          successThreshold: 1
          tcpSocket:
            port: 8080
          timeoutSeconds: 2
        name: ship-test-service-02
        readinessProbe:
          failureThreshold: 2
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 2
        resources:
          limits:
            cpu: "2"
            memory: 2Gi
          requests:
            cpu: 100m
            memory: 2Gi
        securityContext:
          privileged: false
        volumeMounts:
        - mountPath: /alidata1/admin/ship-test-service-02/logs
          name: ship-test-service-02-c6fb000
        - mountPath: /etc/localtime
          name: ship-test-service-02-c6fb001
          readOnly: true
        - mountPath: /usr/local/lib/libEncrypt.so
          name: ship-test-service-02-c6fb002
          readOnly: true
          subPath: libEncrypt.so
        - mountPath: /usr/local/lib/libzaenc.so
          name: ship-test-service-02-c6fb003
          readOnly: true
          subPath: libzaenc.so
        - mountPath: /usr/local/lib/keyEncrypt.txt
          name: ship-test-service-02-c6fb004
          readOnly: true
          subPath: keyEncrypt.txt
      dnsPolicy: ClusterFirst
      enableServiceLinks: false
      imagePullSecrets:
      - name: harbor-poc-registry
      nodeSelector:
        com.zhonganinfo.bizcluster: zainfo
      restartPolicy: Always
      terminationGracePeriodSeconds: 60
      volumes:
      - hostPath:
          path: /alidata1/admin/logs/ship-test-service-02
        name: ship-test-service-02-c6fb000
      - hostPath:
          path: /etc/localtime
        name: ship-test-service-02-c6fb001
      - hostPath:
          path: /usr/local/lib/
        name: ship-test-service-02-c6fb002
      - hostPath:
          path: /usr/local/lib/
        name: ship-test-service-02-c6fb003
      - hostPath:
          path: /usr/local/lib/
        name: ship-test-service-02-c6fb004
status: {}
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    creator: demouser
    description: create from ship
    owner_name: ship-test-service-02
  creationTimestamp: null
  labels:
    app: ship-test-service-02
    app_id: "231003"
    appversion: e9e4fa10-default-1679301625-n49t2
    base_name: ship-test-service-02
    company_id: "79002"
    domain_suffix: prd.za-tech.net
    flow_id: 674fe4d9569b
    initcontainerset.kubecloud.io/za-repeater-agent: ""
    prime_department_id: "10120001"
    project_id: "21003"
    publish_version: v1-2581
    version: btzsg
  name: svc-ship-test-service-02
  namespace: product
spec:
  ports:
  - name: http-8080-8080
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: ship-test-service-02
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    created_default: "true"
    creator: demouser
    description: create from ship
    kubernetes.io/ingress.class: traefik
    owner_name: ship-test-service-02
  creationTimestamp: null
  labels:
    app: ship-test-service-02
    app_id: "231003"
    appversion: e9e4fa10-default-1679301625-n49t2
    base_name: ship-test-service-02
    company_id: "79002"
    domain_suffix: prd.za-tech.net
    flow_id: 674fe4d9569b
    initcontainerset.kubecloud.io/za-repeater-agent: ""
    prime_department_id: "10120001"
    project_id: "21003"
    publish_version: v1-2581
    version: btzsg
  name: ing-ship-test-service-02
  namespace: product
spec:
  rules:
  - host: ship-test-service-02.prd.za-tech.net
    http:
      paths:
      - backend:
          service:
            name: svc-ship-test-service-02
            port:
              number: 8080
        path: /
        pathType: ImplementationSpecific
status:
  loadBalancer: {}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值