Kubernetes video Course 2. static website deployment
Articles,  Blog

Kubernetes video Course 2. static website deployment


In this video we will deploy a docker image
containing a static website to Kubernetes. This will be a very short demo just to give
you a feel of how Kubernetes looks. In a later section we will go through the
process of creating the docker image but for now, just enjoy the show. This course has been developed on a windows
laptop, but I have installed the linux tools for windows since it gives a nice bash terminal
to work with. However, if you chose to use Powershell that
should work as well. Since a production Kubernetes deployment needs
multiple nodes, we will use minikube to install a single node cluster on the laptop. Minikube gives us as a basic Kubernetes install
to experiment and develop on the laptop or home computer. Also, we will use the docker runtime installed
as part of minikube. Let me switch to the terminal. We first start Minikube by typing in minikube.exe
start This might take a while to start Lets see the status by typing in minikube.exe
status, this says minikube has started successfully. We have already created an image that contains
the static website. Lets check if the docker image is present. kubernetes_static_website is the name of our
docker image. Note that we have created the docker image
using the minikube container runtime and so its available to kubernetes. In a production environment, the image will
be downloaded by Kubernetes container runtime from a public or private docker repository. Here’s the index.html page from the website. Its the hello world of Kuberenetes and contains one just header which says First Kubernetes Deployment.. Hello Kubernetes! The deployment information is written in a
yaml file. Lets take a peek into the file without understanding
what the lines mean. It has all the information required to deploy
the container to kubernetes, information about the number of instances required and information
to make it accessible from outside the cluster. we use the kubectl tool to deploy it. kubectl is a kubernetes command line client. We first see currently deployed applications
by typing in kubectl get deployments.
and currently deployed pods by typing in kubectl get pods.
pods host the docker containers. next step is to deploy the static website
by using the yaml file that gives the deployment information. kubectl apply -f static_website_deployment.yml This will create the website and the service if we now check the deployments again, we
should see our deployment and also our pods. The pods may take a while to start since they
are starting the webserver. There are two instances of pods which
means we have two webservers running. Kubernetes sends traffic to either of the
pods and the user does not have to worry about it. The service makes the website accessible from
outside the cluster. For minikube we get the url of the website using minikube.exe
service static-website-service –url if we curl this url we should get the index.html
page which says Hello Kubernetes. We have successfully deployed our first containerized
application to kuberentes. Lets look at the minikube dashboard.
To see the dashboard we type in minikube.exe dashboard. This opens up a dashboard in a browser. On the left side of the dashboard are the
various Kubernetes entities or object links. clicking on deployments brings up the current deployments. we only have one deployment right now. If we scroll down, clicking on pods should bring up the pod list, where
we currently see 2. Lets see how easy it is to scale applications. Imagine that the traffic on our website has
increased and we need one more pod to handle that traffic. We go back to deployments, click on the 3
vertical dots on the right to bring up a menu and click on scale . We change the desired
number of replicas to 3 and click on ok. We then go back to the pods page and now we should see
3 pods once the third pod has started. Lets simulate a failed pod by deleting one
of the pods. Kubernetes immediately brings up another pod
since we always want 3 pods for this application. If we refresh the page, we should see three pods now. This finishes our introductory deployment. We have barely scratched the surface but we
have already seen an example of how powerful and exciting Kubernetes can be. It is going to completely revolutionize the
way companies handle containers. We will get into great details into all aspects
of Kubernetes in the next videos and by the end of the course you should feel pretty confident
to handle Kubernetes deployment or if you are brave enough you should have enough knowledge
to setup your own production grade cluster. Stay tuned for the next lecture on Containers!

Leave a Reply

Your email address will not be published. Required fields are marked *