Self-hosted Blog Guide for Engineers: Part II - Setting up Kubernetes
In this part we will continue and finish setting up a blog using Kubernetes. As it's the first tutorial on Humble Thoughts, it's available to all-tier members (including Free), but serves an example of exclusive content available in the Exclusive subscription.
Kubernetes Configuration
In the previous step, we set up k3s on our remote server using Ansible. We should use the kube config file to control the remote Kubernetes (single-node) cluster. For this, try running the following command from the root directory of the repository:
source .env && kubectl config use-context blog
Sourcing the .env
file is required to reload the KUBECONFIG
variable to ensure the new file is found and loaded to kubectl. If the result is successful and the context is switched, you should be able to check up on our K3s cluster on the server. Try running kubectl get all -A
:
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/local-path-provisioner-5d56847996-jchms 1/1 Running 0 26m
kube-system pod/coredns-7c444649cb-sxq6d 1/1 Running 0 26m
kube-system pod/metrics-server-7b67f64457-xlnt6 1/1 Running 0 26m
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 26m
kube-system service/kube-dns ClusterIP 10.43.0.10 <none> 53/UDP,53/TCP,9153/TCP 26m
kube-system service/metrics-server ClusterIP 10.43.92.33 <none> 443/TCP 26m
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/local-path-provisioner 1/1 1 1 26m
kube-system deployment.apps/coredns 1/1 1 1 26m
kube-system deployment.apps/metrics-server 1/1 1 1 26m
NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/local-path-provisioner-5d56847996 1 1 1 26m
kube-system replicaset.apps/coredns-7c444649cb 1 1 1 26m
kube-system replicaset.apps/metrics-server-7b67f64457 1 1 1 26m
Great! Now the server is ready to create the application and supporting services.