zoukankan      html  css  js  c++  java
  • k8s简单服务模板

    一个简单的服务模板

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: tophc-link-portal
      namespace: prod
    spec:
      selector:
        matchLabels:
          app: tophc-link-portal
      replicas: 3
      strategy:
        rollingUpdate:
          maxSurge: 1
          maxUnavailable: 0
        type: RollingUpdate
      template:
        metadata:
          labels:
            app: tophc-link-portal
        spec:
          imagePullSecrets:
          - name: tophc-harbor
          containers:
          - name: tophc-link-portal
            env:
            - name: springProfiles
              value: prod
            - name: TZ
              value: CST-8
            image: xxxx-link-portal:latest
            imagePullPolicy: Always
            livenessProbe:
              failureThreshold: 3
              httpGet:
                path: /healthz
                port: 80
                scheme: HTTP
              initialDelaySeconds: 10
              periodSeconds: 10
              successThreshold: 1
              timeoutSeconds: 2
            readinessProbe:
              failureThreshold: 3
              httpGet:
                path: /healthz
                port: 80
                scheme: HTTP
              initialDelaySeconds: 5
              periodSeconds: 3
              successThreshold: 1
              timeoutSeconds: 2
            ports:
              - containerPort: 80
            resources:
              limits:
                cpu: 300m
                memory: 200Mi
              requests:
                cpu: 200m
                memory: 100Mi
                
    ---
    
    # 自动扩缩容
    
    apiVersion: autoscaling/v2beta1
    kind: HorizontalPodAutoscaler
    metadata:
      name: tophc-link-portal-hpa-v2
      namespace: prod
    spec:
      minReplicas: 2
      maxReplicas: 6
      scaleTargetRef:
        apiVersion: extensions/v1beta1
        kind: Deployment
        name: tophc-link-portal
      metrics:
      - type: Resource
        resource:
          name: cpu
          targetAverageUtilization: 70
      - type: Resource
        resource:
          name: memory
          targetAverageUtilization: 70
    ---
    
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: tophc-link-portal
      name: tophc-link-portal
      namespace: prod
    spec:
      ports:
      - name: http
        port: 80
        targetPort: 80
      selector:
        app: tophc-link-portal
      type: ClusterIP
    
    ---
    
    # 服务暴露
    
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      labels:
        env: prod
        project: tophc
        service: tophc-link-portal
      name: tophc-link-portal-80
      namespace: prod
    spec:
      rules:
      - host: portal.xxxxxxx.xxx
        http:
          paths:
          - backend:
              serviceName: tophc-link-portal
              servicePort: 80
            path: /
    
  • 相关阅读:
    统计中的精度和召回率的解释
    人工智能在医疗行业中的应用
    解决Myeclipse在调试(debug)时无法显示变量值问题(转载)
    溢出的问题
    返回引用和对象遇到的坑
    vmWare上网配置(转载)
    linux内核相关的术语(转载)
    一个死锁问题
    Ethernet,token ring,FDDI,ATM,WLAN(转载)
    kmalloc与vmalloc
  • 原文地址:https://www.cnblogs.com/lizhaojun-ops/p/12910768.html
Copyright © 2011-2022 走看看