When starting rancher desktop for the first time select dockerd (moby)
Rancher Desktop comes with all the other tools we need to get started
kubectl run nginx --image=nginx
kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 77s
Depending on internet connection and speed it might take time get a status of running
kubectl delete pod nginx
kubectl create deployment nginx --image=nginx --port=80
kubectl get deployments
kubectl get pods
kubectl scale --replicas=3 deployment/nginx
kubectl get deployments
kubectl get pods
port forward to connect our computer direct to pod
kubectl port-forward deployment/nginx 8080:80
When going to localhost:8080 in your broswer you should see the nginx default page
To cancel the port forward and reclaim the shell hit ctrl + c
Lets expose via NodePort
kubectl expose deployment nginx --port=80 --type="NodePort"
To find the port that got created run the following
kubectl get service
You should get the following output
NAME TYPE CLUSTER-IP ... PORT(S)
kubernetes ClusterIP 10.43.0.1 ... 443/TCP
nginx NodePort 10.43.121.75 ... 80:31053/TCP
The 80:31053 tells you the nodeport selected is 31053
in this case going to localhost:31053 in your browser will get you the nginx default page
Starting clean up lets delete our pod (dont worry it wont come back on its own)
kubectl delete deployment nginx
# You can verify the pods are gone by running
kubectl get pods
To show services are seperated from pods you can see it still exists
kubectl get service
Since they are seperate objects how are they connected?
kubectl describe service nginx
describe is a valuable tool, make sure to try it out on other resource types
lets clean up our service
kubectl delete service nginx
helm template ./chart
# Make some namespaces
kubectl create namespace dashboard
kubectl create namespace dev
# Deploy local development
tilt up
docker build \
-t ghcr.io/codayblue/kubernetes-workshop/app:v1.0.0 \
-f ./app/Dockerfile \
./app
Normally we would push this to a registry for deployment
Since our cluster is local we built it on the same runtime so thats not needed
kubectl create namespace production
helm upgrade prod-app-helm ./chart \
--install \
--namespace production \
-f ./chart/prod-values.yaml
This is just the start, keep learning!