Kubernetes for Normal People
How can we use tooling to handle the complexity of kubernetes for normal people?
Terraform
Create cloud resources such as VPCs and the Kubernetes cluster with Terraform. There are Terraform modules for AWS EKS and Azure AKS or GCP. Use CI/CD to run Terraform. See repo terraform-github-actions that demonstrates using GitHub actions to run Terraform.
Flux V2
Create all Kubernetes resources with Flux V2 from standard published helm charts. Have one git repo with cluster directory for each cluster and when you merge to main branch flux will automatically apply the helm changes to the cluster. See Introduction to GitOps on Kubernetes with Flux v2. Also see flux-examples.
Lens
Install Lens to show the status of various Kubernetes resources as this is much easier that entering kubectl commands.
To configure kubeconfig file for AWS EKS for lens in your command line:
export AWS_PROFILE=myprofile
aws eks — region eu-west-1 update-kubeconfig — name myclustername
Kubectl and Cloud CLI Tool
- Install kubectl as not everything can be done in lens.
- Install the CLI for your cloud environment For example AWS CLI
Updating kubernetes resources with kubectl
Lens is not so great and updating resources( When you are say debugging) so here is an example using kubectl:
kubectl config set-cluster arn:aws:eks:eu-west-1:09999999999:cluster/corpcluster-MDY678XYZkubectl get clusterRoleBinding -o yaml controller-manager > binding.yamlkubectl get deployment -o yaml app-abc -n app-abc-ns > originalDeployment.yamlkubectl delete deployment app-abc -n app-abc-ns
make changes then
kubectl apply -f <new yaml file>
SSH into a container in Kubernetes
using bash:
kubectl exec -it [POD_NAME] — namespace [NAMESPACE] — /bin/bash
Or use sh for Alpine based containers:
kubectl exec -it [POD_NAME] — namespace [NAMESPACE] — /bin/sh
References
Introduction to GitOps on Kubernetes with Flux v2
How to parse json format output of : kubectl get pods using jsonpath
How to SSH to docker container in kubernetes cluster?
Top 10 Kubernetes tips and tricks
Cloud Academy Administering Kubernetes Clusters
Platform Operations on Kubernetes (POOK)
Keywords: kubernetes, EKS, Terraform, Flux, Helm, Lens,kubectl, AWS CLI