Skip to content

Instantly share code, notes, and snippets.

@1eedaegon
Last active August 14, 2023 09:09
Show Gist options
  • Save 1eedaegon/a4896a379e223a23bd9ce4a058028eb9 to your computer and use it in GitHub Desktop.
Save 1eedaegon/a4896a379e223a23bd9ce4a058028eb9 to your computer and use it in GitHub Desktop.
How to curl to kubelet on minikube

How to curl to kubelet on minikube

Directly

1. Connect inside conatiner

docker exec -it minikube bash

2. Request pods list to kubelet

curl -sk -X GET  "https://localhost:10250/pods" \
--key /var/lib/minikube/certs/apiserver-kubelet-client.key \
--cert /var/lib/minikube/certs/apiserver-kubelet-client.crt \
--cacert /var/lib/minikube/certs/ca.key

Request curl with jq

1. Install jq

curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o /usr/bin/jq
chmod a+x /usr/bin/jq
jq -V

2. With jq

curl -sk -X GET  "https://localhost:10250/pods" \
--key /var/lib/minikube/certs/apiserver-kubelet-client.key \
--cert /var/lib/minikube/certs/apiserver-kubelet-client.crt \
--cacert /var/lib/minikube/certs/ca.key | jq

--------------------------------------------------------

        "podIP": "192.168.49.2",
        "podIPs": [
          {
            "ip": "192.168.49.2"
          }
        ],
        "startTime": "2023-08-11T02:40:48Z",
        "containerStatuses": [
          {
            "name": "kube-controller-manager",
            "state": {
              "running": {
                "startedAt": "2023-08-11T02:40:49Z"
              }
            },
            "lastState": {
              "terminated": {
                "exitCode": 255,
                "reason": "Error",
                "startedAt": "2023-08-01T01:11:40Z",
                "finishedAt": "2023-08-11T02:40:29Z",
                "containerID": "docker://552fe7127b61e493a8ffd1f472676c3db3f9a228dc31c8e53de3b9b258d42d72"
              }
            },
            "ready": true,
            "restartCount": 1,
            "image": "registry.k8s.io/kube-controller-manager:v1.27.3",
            "imageID": "docker-pullable://registry.k8s.io/kube-controller-manager@sha256:1ad8df2b525e7270cbad6fd613c4f668e336edb4436f440e49b34c4cec4fac9e",
            "containerID": "docker://d54cd5a87d674ceb3660491efd3979415c5524a609458b709310a60bdc273431",
            "started": true
          }
        ],
        "qosClass": "Burstable"
      }
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment