Post Valid as of October 12, 2021.
This is a continuation from the last post in the series. There are three primary ways to run Kubernetes locally on a notebook: Kind, k3d, and Minikube. I personally far prefer k3d due to it having good defaults to get up and running with stateful sets long before the other two and it can create large worker nodes, these have lead to a loyalty to the product. However, my org seems to have standardized on Kind for most of their CI so I will be covering that here as it is the easiest for my coworkers to find help and documentation. It is also an excellent product to get started with Kubernetes.
brew install kubernetes-cli
brew install kind
kind create cluster
kubectl get nodes
where you should see on nodekubectl create secret docker-registry regcred --docker-server=ghcr.io --docker-username=<changeme> --docker-password=<changeme>
deployment.yaml
file
apiVersion: apps/v1
kind: Deployment
metadata:
name: nodejs-deployment
spec:
selector:
matchLabels:
app: nodejs
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nodejs
spec:
imagePullSecrets:
- name: regcred
containers:
- name: nodejs
image: ghcr.io/CHANGEME/app:main
imagePullPolicy: Always
ports:
- containerPort: 3000
kubectl create -f deployment.yaml
kubectl get pods --watch
kubectl port-forward $( kubectl get pods -o name | head -n 1) 3000:3000
Follow the next steps here