[Lab Notes] Kubernetes the Hard Way, For Real This Time (Step 10)
Continuing my Kubernetes the Hard Way homelab build. Steps 01-09 are already done, this covers step 10. Original guide: 10-configuring-kubectl.md
Thoughts I had while doing this
What we're basically doing in this step is configuring the jumpbox's own connection to the cluster. We use kubectl to create a config file (~/.kube/config) that points at the cluster.
Until now, any kubectl command that actually talked to the cluster had to run on the controller, either directly or over SSH. After this step, I can run them straight from the jumpbox.
The four kubectl config commands are the same ones from step 05 (set-cluster, set-credentials, set-context, use-context). Two differences:
- No
--kubeconfigflag this time, so everything gets written to the default~/.kube/config. - The server URL is
https://server.kubernetes.local:6443instead ofhttps://127.0.0.1:6443, since this timekubectlruns on the jumpbox, not on the controller itself.
Verify the API server is reachable
Before touching any config, a quick check that the jumpbox can reach the API server over TLS using the CA cert:
root@jumpbox:~/kubernetes-the-hard-way# curl --cacert ca.crt \
https://server.kubernetes.local:6443/version
{
"major": "1",
"minor": "32",
"gitVersion": "v1.32.3",
"gitCommit": "32cc146f75aad04beaaa245a7157eb35063a9f99",
"gitTreeState": "clean",
"buildDate": "2025-03-11T19:52:21Z",
"goVersion": "go1.23.6",
"compiler": "gc",
"platform": "linux/amd64"
}
Generate the admin kubeconfig
root@jumpbox:~/kubernetes-the-hard-way# {
kubectl config set-cluster kubernetes-the-hard-way \
--certificate-authority=ca.crt \
--embed-certs=true \
--server=https://server.kubernetes.local:6443
kubectl config set-credentials admin \
--client-certificate=admin.crt \
--client-key=admin.key
kubectl config set-context kubernetes-the-hard-way \
--cluster=kubernetes-the-hard-way \
--user=admin
kubectl config use-context kubernetes-the-hard-way
}
Cluster "kubernetes-the-hard-way" set.
User "admin" set.
Context "kubernetes-the-hard-way" created.
Switched to context "kubernetes-the-hard-way".
Verification
root@jumpbox:~/kubernetes-the-hard-way# kubectl version
Client Version: v1.32.3
Kustomize Version: v5.5.0
Server Version: v1.32.3
root@jumpbox:~/kubernetes-the-hard-way# kubectl get nodes
NAME STATUS ROLES AGE VERSION
node-0 Ready <none> 29d v1.32.3
node-1 Ready <none> 20d v1.32.3
kubectl version now reports both the client and the server version, and kubectl get nodes works straight from the jumpbox with both workers Ready.
Summary
Step 10 pointed the jumpbox's kubectl at the cluster by creating ~/.kube/config with the CA cert and the admin credentials from step 04. No more SSHing into the controller to run kubectl commands.
Comments
No comments yet. Start the discussion.