Friday, March 10, 2023

Docker and Kubernetes

(Kubernetes aka k8s)

Kubernetes CLI

KubeCtl CLI doc

Kubernetes cheat sheet

K8s CLI Cheat sheet

CLI Quick ref

Docker Compose Kubernetes Cheat sheet

Kubernetes - Contexts

src: Docker: Kubernetes - intro - CLI example

kubectl config get-contexts

kubectl config use-context docker-desktop

kubectl get nodes

kubectl config view

Kubernetes - Orchestration example - running Pods:

src: Docker Kubernetes orchestration - short CLI reference

kubectl apply -f pod.yaml

kubectl get pods

kubectl logs demo

kubectl delete -f pod.yaml

Deploy to Kubernetes

(Containerize, Kubernetize, run)


Containerize your application - Create image getting-started

git clone

cd getting-started\app

copy con Dockerfile

# syntax=docker/dockerfile:1

FROM node:18-alpine


COPY . .

RUN yarn install --production

CMD ["node", "src/index.js"]



docker build -t getting-started .

rem docker run -dp 3000:3000 getting-started

rem start http://localhost:3000

Kubernetize and run

src: Deploy to Kubernetes

Deploy, list, check, remote:

kubectl apply -f bb.yaml

kubectl get deployments

kubectl get services

start http://localhost:30001/

kubectl delete -f bb.yaml

Convert Docker Compose to Kubernetes

CLI kompose

Converts docker-compose.yaml to kubernetes-service.yaml

Kubernetes Dashboard

Web UI Dashboard

Create sample user

kubectl apply -f

kubectl proxy

start http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

kubectl delete -f


kubectl -n kubernetes-dashboard delete serviceaccount admin-user

kubectl -n kubernetes-dashboard delete clusterrolebinding admin-user

Kubernetes Dashboard - in Docker container (have not tested yet)


docker pull kubernetesui/dashboard


Namespaces intro

kubectl get namespaces

kubectl get namespaces --show-labels

Create DEV namespace:

kubectl create -f

Kubernetes config

src: StackOverflow

Config Example



~/.kube/config # Linux

%USERPROFILE%/.kube # Windows

Kubernetes config file

src: DevOpsCube: KubeConfig file

kubectl -n kube-system create serviceaccount devops-cluster-admin

Kubernetes short tutorial

Docker and Kubernetes at TutorialPoint

See also


Docker: Get started with Kubernetes - build docker k8s ready apps

Docker: Play with Kubernetes

Kubernetes - home


Kubernetes: deprecating Docker, switch to other containers (containerd or CRI-O) (Open Container Initiative)

Kubernetes: Dockershim deprecation FAQ

MS: Kubernetes vs Docker - cz

Docker limits cpu memory

Docker memory CPU limits (Windows)

for WSL2, create or open file:


not: %HOMEPATH%\.wslconfig

Note: you have to save it in Linux LF (not Windows CRLF) mode

Add or update lines:




#kernelCommandLine = vsyscall=emulate








Microsoft Learn: example .wslconfig

src: Google search

StackOverflow: The Memory and CPU settings were removed for WSL2 integration

You have to stop all running WSL2 containers for changes to take effect.

Stop WSL2:

wsl --shutdown