This code can be used to run an application on a kubernetes setup using docker on MacOS, Linus, or Windows.
Kubernetes is a portable, extensible open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.
(Source: https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/)
Download and install Docker here: https://docs.docker.com/docker-for-mac/install/ .
Download and Install kubectl (Kubernetes Command Line Tool) here: https://kubernetes.io/docs/tasks/tools/install-kubectl/ .
Go to Docker Preferenes and start Kubernetes from the Kubernetes tab. This may take a while.
$ kubectl version
$ kubectl cluster-info
$ kubectl run —-image=nginx webserver-yourname
$ kubectl get deploy
$ kubectl get rs
$ kubectl get pod
$ kubectl get pod
$ kubectl portforward <pod-name> 5000:80
$ kubectl expose deploy webserver-yourname --type=NodePort
$ kubectl get services
^ This expose command will assign a random port to your webserver. Let's call it:
<rand-port>
Access the node port at:
localhost:<rand-port>
docker build -t kubernetes-node .
$ kubectl apply -f deployment.yaml
$ kubectl expose deploy kubernetes-node-deployment --type=NodePort
$ kubectl get service
^ Let's call it:
<kub-node-port>
localhost:<kub-node-port>
Voila.