配置示例:
    image.png

    [root@master manifests]# vim readness-httpget.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: readiness-httpget-pod
    namespace: default
    spec:
    containers:
    - name: readiness-httpget-container
    image: ikubernetes/myapp:v1
    imagePullPolicy: IfNotPresent
    ports:
    - name: http
    containerPort: 80
    readinessProbe:
    httpGet:
    port: http
    path: /index.html
    initialDelaySecond: 1
    periodSeconds: 3

    效果查看:
    image.png

    [root@master manifests]# kubectl exec -it readiness-httpget-pod — /bin/sh
    / # rm -f /usr/share/nginx/html/index.html

    [root@master manifests]# kubectl get pods -w
    NAME READY STATUS RESTARTS AGE
    client-f5cdb799f-pklmc 1/1 Running 0 26h
    myapp-9b4987d5-47sjj 1/1 Running 0 26h
    myapp-9b4987d5-684q9 1/1 Running 0 26h
    myapp-9b4987d5-djdr9 1/1 Running 1 26h
    nginx-deploy-84cbfc56b6-tcssz 1/1 Running 0 30h
    pod-demo 2/2 Running 5 5h27m
    readiness-httpget-pod 0/1 Running 0 115s