mirror of
https://github.com/outbackdingo/kubernetes.git
synced 2026-02-26 04:40:19 +00:00
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubelet status manager sync the status of local Pods **What this PR does / why we need it**: In the kubelet, when using `--pod-manifest-path` the kubelet creates static pods but doesn't update the status accordingly in the `PodList`. This PR fixes the incorrect status of each Pod in the kubelet's `PodList`. This is the setup used to reproduce the issue: **manifest**: ```bash cat ~/kube/staticpod.yaml ``` ```yaml apiVersion: v1 kind: Pod metadata: labels: app: nginx name: nginx namespace: default spec: hostNetwork: true containers: - name: nginx image: nginx:latest imagePullPolicy: IfNotPresent volumeMounts: - name: os-release mountPath: /usr/share/nginx/html/index.html readOnly: true volumes: - name: os-release hostPath: path: /etc/os-release ``` **kubelet**: ```bash ~/go/src/k8s.io/kubernetes/_output/bin/kubelet --pod-manifest-path ~/kube/ --cloud-provider="" --register-node --kubeconfig kubeconfig.yaml ``` You can observe this by querying the kubelet API `/pods`: ```bash curl -s 127.0.0.1:10255/pods | jq . ``` ```json { "kind": "PodList", "apiVersion": "v1", "metadata": {}, "items": [ { "metadata": { "name": "nginx-nodeName", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/nginx-nodeName", "uid": "0fdfa64c73d9de39a9e5c05ef7967e72", "creationTimestamp": null, "labels": { "app": "nginx" }, "annotations": { "kubernetes.io/config.hash": "0fdfa64c73d9de39a9e5c05ef7967e72", "kubernetes.io/config.seen": "2017-12-12T18:42:46.088157195+01:00", "kubernetes.io/config.source": "file" } }, "spec": { "volumes": [ { "name": "os-release", "hostPath": { "path": "/etc/os-release", "type": "" } } ], "containers": [ { "name": "nginx", "image": "nginx:latest", "resources": {}, "volumeMounts": [ { "name": "os-release", "readOnly": true, "mountPath": "/usr/share/nginx/html/index.html" } ], "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "nodeName": "nodeName", "hostNetwork": true, "securityContext": {}, "schedulerName": "default-scheduler", "tolerations": [ { "operator": "Exists", "effect": "NoExecute" } ] }, "status": { "phase": "Pending", "conditions": [ { "type": "PodScheduled", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-12-12T17:42:51Z" } ] } } ] } ``` The status of the nginx `Pod` will remain in **Pending** state phase. ```bash curl -I 127.0.0.1 HTTP/1.1 200 OK ``` It's reported as expected on the apiserver side: ```bash kubectl get po --all-namespaces -w NAMESPACE NAME READY STATUS RESTARTS AGE default nginx-nodeName 0/1 Pending 0 0s default nginx-nodeName 1/1 Running 0 2s ``` It doesn't work either with a standalone kubelet: ```bash ~/go/src/k8s.io/kubernetes/_output/bin/kubelet --pod-manifest-path ~/kube/ --cloud-provider="" --register-node false ``` **Special notes for your reviewer**: **Release note**: ```release-note NONE ```