As a devops engineer you create a yaml file ( .yml ) file
What this yaml file contains?
1) No of nodes you want?
2) Each node should have how many pods
3) Each pod should contain how many containers
All the above information will be available in yaml file.
This file is also called manifest file.
This document should be provided to kuberneted master.
kube api server acts like a receptionist.
It receives the yaml file and pass the request to kube scheduler.
kube scheduler will take the action.
So kube scheduler will create pods and containers.
What is etcd?
Etcd is also called cluster store.
It has the information of the complete cluster.
It is used to store the data of master, node and containers.
Data is stored in key-value pair.
What is controller manager?
It is responsibile to make sure that the actual state is same as desired state.
These four components together called as control plane.
Node container 3 components
3) container engine
Kubelet — is also called as agent, as it listenes to kubernetes master.
kube-scheduler component communicates to kubelet.
kubelet communicates to container engine ( docker ) so that containers are created. Note: Containers are created in pods
kube proxy —
It will provide IP Address to pod.
In docker Swarm, Manager machine takes the load.
In Kubernetes Manager is called as Master.
Kubernetes master does not take up the load.
It only distributes load to slaves/ nodes.
Nodes are also called Minion.
Minions combined together is called as cluster.
Smallest Object that kubernetes can create is pod.
Within the pod, we have the container.
Kubernetes commands are always triggered using kubectl.
Kuberneted introduced on June 2014 by Google.
To practice Kubernetes on AWS , we have a service EKS ( Elastic Kubernetes Service )
To practice Kubernetes on Azure , we have a service AKS ( Azure Kubernetes Service )
To practice Kubernetes on GCP , we have a service GKE ( google Kubernetes engine )
AWS, is expensive
Freeways to work on kubernetes is katakoda
Learn — — Kubernetes Introduction — Start Course
— Launch Multinode cluster — Start Scenario
Login using gmail
Step 1: Initialise Master
Run kubeadm init command ( just click on it )
We need to copy configuration files to home directory and change ownership.
Run sudo cp command.
Step 2: Deploy Container networking Interface
Run the three commands
cat , kubectl apply, kubectl get pod
kubeadm token list
kubeadm join ( this will create slave )
kbectl get nodes
You can see one controlplane and one node
We have one more site
using which we can practice Kubernetes.
But, both the options will be slow.
We learn kuberntes on GCP, as AWS is expensive.
Sign up to GCP account using gmail credentials. ( Free trial comes with USD 300 )
Sign in using gmail
Click on console
You will enter into google cloud platform console
Navigation Menu — Kubernetes Engine — Clusters — Create cluster — Create
Observation: Cluster size is 3
By default, it creates 3 node cluster.
Master Machine is not provided as a linux server.
It is given as a service.
As it is a service, it never fail.
So, we do not need to worry about master.
To connect to the cluster
In GCP, Cloud Shell is the terminal, used to connect to the cluster.
kubectl get nodes ( we can see the nodes )
After practice, Delete the cluster.
Next day, we can create the cluster again.
To Create pod
kubectl run –image tomcat webserver
Kubadm — This is an application that is responsible for creating master node. It also stores information about the slaves.
Kubeapi — This is an application that runs on salves, and accepts the instructions from kubeadm and executes them on slaves.
kubectl — This is an application that triggers the kubernetes commands
Kuberntes uses various types of objects.
1 Pod: This is a layer of abstraction on top of a container. This is the smallest object that kubernetes can work on. In the pod, we have the container. kubectl commands will work on the pod and pod communicates there instructions to the container.
- Service Object: This is used for port mapping and network load balancing.
- NameSpace: This is used for creating partitions in the cluster. Pods running in a namespace cannot communicate with other pods running in other namespace.
- Secrets: This is used for passing encrypted data to the pods.
- ReplicaSet / Replication COntroller: This is used for managing multiple replicas of a pod to perform activities like load balancing and autoscaling.
- Deployment: This is used for performing all activites that a ReplicaSet can do. It can also handle rollling updates.
Open cloud shell terminal.
Command to create a pod
kubectl run –image tomcat webserver
( Webserver is pod name )
To see list of pods
kubectl get pods
If we do not specify replicas, it creates only one replica.
To delete the pod
kubectl delete pods webserver