zoukankan      html  css  js  c++  java
  • K8S 之健康检查

    健康检查

    为了确保容器在部署后确实处在正常运行状态,Kubernetes提供了两种探针(Probe,支持exec、tcp和httpGet方式)来探测容器的状态:

    • LivenessProbe:探测应用是否处于健康状态,如果不健康则删除重建改容器
    • ReadinessProbe:探测应用是否启动完成并且处于正常服务状态,如果不正常则更新容器的状态
    apiVersion: v1
    kind: Pod
    metadata:
      labels:
        app: nginx
      name: nginx
    spec:
        containers:
        - image: nginx
          imagePullPolicy: Always
          name: http
          livenessProbe:
            httpGet:
            path: /
            port: 80
            initialDelaySeconds: 15
            timeoutSeconds: 1
          readinessProbe:
            httpGet:
            path: /ping
            port: 80
            initialDelaySeconds: 5
            timeoutSeconds: 1
    

    Init Container

    Init Container在所有容器运行之前执行(run-to-completion),常用来初始化配置。

    apiVersion: v1
    kind: Pod
    metadata:
      name: init-demo
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - name: workdir
          mountPath: /usr/share/nginx/html
      # These containers are run during pod initialization
      initContainers:
      - name: install
        image: busybox
        command:
        - wget
        - "-O"
        - "/work-dir/index.html"
        - http://kubernetes.io
        volumeMounts:
        - name: workdir
          mountPath: "/work-dir"
      dnsPolicy: Default
      volumes:
      - name: workdir
        emptyDir: {}
    

      

  • 相关阅读:
    [APIO2012]派遣
    Luogu_2774 方格取数问题
    Luogu4149 [IOI2011]Race
    Luogu_4886 快递员
    Loj_6282. 数列分块入门 6
    LOJ 6281 数列分块入门 5
    三维偏序 cdq
    【逆序对】 模板
    【luogu P1637 三元上升子序列】 题解
    【luogu P3609 [USACO17JAN]Hoof, Paper, Scissor蹄子剪刀布】 题解
  • 原文地址:https://www.cnblogs.com/NGU-PX/p/14235766.html
Copyright © 2011-2022 走看看