/kubernetes-local-development

Presentation of useful tools to develop with Kubernetes locally

Primary LanguageShell

Local Development with Kubernetes ☸️

Presentation of useful tools to develop with Kubernetes locally

Local cluster

  • Minikube : Run Kubernetes locally on Windows, Mac or Linux.

  • MicroK8S : A single package of k8s that installs on 42 flavours of Linux.

  • Kind : A tool for running local Kubernetes clusters using Docker container “nodes”.

  • kubeadm-dind-cluster : A Kubernetes multi-node test cluster based on kubeadm. DEPRECATED

  • K3S / K3D : lightweight Kubernetes distribution by Rancher

Remote cluster

Improve K8S command line UX

# Tip : easy merge kube config files and switch contexts
export KUBECONFIG=~/.kube/k1_config:~/.kube/k2_config:~/.kube/k3_config
kubectx
<3 contexts>
  • kube-shell : An integrated shell for working with the Kubernetes CLI
  • kube-prompt : An interactive kubernetes client featuring auto-complete
  • K9S : A terminal UI to interact with your Kubernetes clusters
  • kube-ps1 : Kubernetes prompt info for bash and zsh
  • Stern : Multi pod and container log tailing
  • Kail : Kubernetes log viewer
  • KubeSpy : Tools for observing Kubernetes resources in real time
kubectl create ns gd
kubens gd

# In one shell (keep it displayed)
kubespy trace deploy gd/nginx-deployment
# In another shell
kubectl create -f https://k8s.io/examples/controllers/nginx-deployment.yaml 

# Pod
kubespy status v1 Pod gd/nginx
kubectl create -f https://github.com/pulumi/kubespy/raw/master/examples/trivial-pulumi-example/yaml/nginx.yaml

# Service
kubespy trace service  gd/nginx
kubectl create -f https://github.com/pulumi/kubespy/raw/master/examples/trivial-service-trace-example/yaml/nginx.yaml
kubectl krew {search,info,install,upgrade,remove} 
  • Examples :

    • kubectl view-utilization -h
    • kubectl get-all --only-scope=namespace --namespace=default
  • Arkade : helps you install kubernetes application with a single install command

Development

GUI/TUI

Other tools

Chaos gaming tools 🕹

Costing

kubereport () {
	mkdir -p /tmp/kubereport-output
	echo ""
	echo "----------------------------------------------------------"
	echo "Merging config files found in KUBECONFIG var..."
	echo "----------------------------------------------------------"
	echo $KUBECONFIG | sed 's/:/\n/g'
	echo ""
	echo "----------------------------------------------------------"
	kubectl config view --flatten > ~/.kube/config
	echo "Generating report..."
	echo "----------------------------------------------------------"
	docker pull hjacobs/kube-resource-report
	docker run -it --net=host -v ~/.kube/:/root/.kube/ -v /tmp/output:/output hjacobs/kube-resource-report /output
	echo ""
	echo "----------------------------------------------------------"
	echo "Opening report..."
	echo "----------------------------------------------------------"
	xdg-open /tmp/output/index.html &
}

Learning

Useful links

https://cloud.google.com/blog/products/containers-kubernetes/easier-kubernetes-development-from-your-laptop

https://medium.com/@wso2tech/multi-node-kubernetes-cluster-with-vagrant-virtualbox-and-kubeadm-9d3eaac28b98

https://garden.slides.com/ellenkorbes/k8sdevtools?token=t3egVfZS#/38

https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0

https://ostechnix.com/kubernetes-features/

https://github.com/medmouine/Kubernetes-autoscaling-poster/blob/main/k8s-auto-scaling-poster.pdf