Three quick ways to start with Kubernetes

2019-02-16-182143_819x482_scrot.png

There are many ways to start with Kuberntetes, I will write three of them with which you can make your first project quickly.

1. Minikube: 

Is a simple way to create a cluster of Kubernetes in single-node. We need to install first the following:

  • Install virtual box

    Minikube pulls an image into a virtual box. We will use these commands to install it:

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo apt-get -y install gcc make linux-headers-$(uname -r) dkms
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list'
sudo apt-get update
sudo apt-get install virtualbox-5.2

Check if virtual box is installed:  VBoxManage -v

  • Install Kubectl

    To execute kubernetes commands:

sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

Check if Kubectl is installed: kubectl version

  • Install Minikube

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube

sudo cp minikube /usr/local/bin && rm minikube

Check if minikube is installed: minikube version

  • Start Minikube

minikube start

  • Creating a hello-minikube container

kubectl run hello-minikube --image=gcr.io/google-samples/node-hello:1.0 --port=8080

  • Expose the service

kubectl expose deployment hello-minikube --type=NodePort

  • We can see the pod  status

kubectl get pod

2019-02-16-011113_746x65_scrot

  • We can see the service

minikube service hello-minikube --url

  • Delete the pod

kubectl delete deployment hello-minikube

  • Deleted the service

kubectl delete service hello-minikube

2. Kubernetes on Google Cloud Platform:

We need to have a Google Cloud Platform account if you have one go to console: https://console.cloud.google.com

Select kubernetes cluster on left menu:

2019-02-16-025616_307x425_scrot

Click on create cluster:2019-02-16-011535_529x263_scrot

In Google we will create 03 workers, the master is created by default.

2019-02-16-011647_925x847_scrot.png

2019-02-16-032857_1165x325_scrot.png

Click on “Connect”, and click on “Run in cloud shell”

2019-02-16-032647_942x564_scrot.png

Test: kubectl get nodes

2019-02-16-032822_1714x318_scrot.png

We have a kubernetes cluster created on GCP

3. Labs play with k8s

Play with Kubernetes to run K8 cluster in seconds: https://labs.play-with-k8s.com

Click on “Add new Instance” to start a node. Enter the console and you can follow the guide to start the cluster. ( If  the terminal doesn’t show, refresh the page).

2019-02-16-183639_1547x801_scrot

 

With these three tools, we can start playing with Kuberntes, If you have questions, do not hesitate to write.

Thank you!

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s