Installation of MiniKube

Shishir TambeShishir Tambe
5 min read

Kubernetes Objects

- Kubernetes uses objects to represent the state of your cluster.
- what containerized applications are running (and on which node)
- The policies around how those application behave, such as restart policies, upgrade and fault tolerance.
- Once you create the object, the kubernetes system will constantly work to ensure that object execute and maintain's cluster desired state.
- Every kubernetes object include two nested feilds that govern the object config that object spec and the object status.
- The spec, which we provide , describes your desired state for the object- the characteristics that you want to the object to have.
- The status describes the actual state of the object and is supplied and updated by the kubernetes system.
- All objects are identified by a unique name and a UID
The Basic keubernetes objects include:
• Pod
• Service
• Volume
• Namespace
• Replicasets
• Secrets
• ConfigMaps
• Deployments
• Jobs
• Daemonsets

Relationship between these objects:

- Pod manages containers
- Replicaset manage pod
- services expose pod processes to the outside world
- Config Maps and Secrets helps you config pods

Kubernetes Objects:

• It represent as JSON oy YAML files
• You create these and then push then to the kubernetes API with Kubectl
State of the object
- Replicas (2/2)
- Image (Tomcat/ Ubuntu)
- Name
- Port
- Volume
- startup
- Detached (default)

Kubernetes Object Management:

The kubectl command line tool supports several different way to create and manage kuberneets object.
• The management technique called imperative commands operates on LIVE OBJECTS in recommended envirnoment which is DEVELOPMENT PROJECTS.
• The management technique called declarative Object Configuration operates on INDIVIDUAL FIELDS (yml/json) in recommended environment which is PRODUCTION.

Declarative is about describing what you are trying to achieve , without instructing how to do it.
Imperative, explicitly telling "How to accomplish it"

Fundamentals of Pods:

- When a pod gets created, it is scheduled to run on a node in your cluster
- The pod remains on that node until the process is terminated, the pod object is deleted, the pod is evicted for a lack of resources or the node fails.
- If a pod is scheduled to a node that fails, or if the scheduling operation itself fails, the pod is deleted.
- If a node dies, the pod scheduled to that node are scheduled for deletion after a timeout period
- A given pod (UID) is not "rescheduled " to a new node, instead it will be replaced by an identical Pod, with even the same name if desired, but with a new UID
- Volume in Pod will exist as long as that pod (with that UID) exist if that Pod (with that UID) is deleted for any reason, volume is also destroyed and created as new on new pod.
- A controller can create and manage multiple pod, handling replication, rollout and providing self-healing capabilities.

Kubernetes Configuration:

1. All-in-One single node installation: (only for practice, not for production)
-> With all-in-one, all the master and worker components are installed on a single node. This is very useful for learning, development and testing. This type should not be used in Production MiniKube is one such example, and we are going to explore it soon.
(Only for practice)

2. Single-Node etcd, single-Master and Multi-worker installation:
-> In this setup, we have a single mster node, which also runs a single-node etcd instance. Multiple orker nodes are connected to the master node.

3. Single-Node etcd, Multi-Master and Multi-worker installation:
-> In this setup, we have multiple master nodes, which works in an HA(high avaliability) mode, but we have a sigle-node etcd instance. Multiple worker nodes are connected to the master node.
Commands to follows:
go to aws account -> launch instance -> ubuntu -> t2 medium (2CPU)
Now access EC2 via putty -> login as "ubuntu"
-> sudo su
-> sudo apt update && apt -y install docker.io
Now install kubectl

Then install

Mini Kube:

sudo su

Now install docker

sudo apt update && apt -y install docker.io

install Kubectl

curl -LO [https://storage.googleapis.com/kubernetes-release/release/$(curl](https://storage.googleapis.com/kubernetes-release/release/$(curl) -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl/bin/linux/amd64/kubectl) && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl

install Minikube

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

apt install conntrack
minikube start --vm-driver=none

Pod1.yml

kind: Pod
apiVersion: v1
metadata:
name: testpod
spec:
containers:
- name: c00
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo Hello-Shishir; sleep 5 ; done"]
restartPolicy: Never # Defaults to Always

COMMANDS FOR CHECKING, APPLYING, LOGS, & DESCRIBE CHANGES
kubectl apply -f pod1.yml
kubectl get pods
kubectl get pods -o wide
kubectl describe pod testpod
kubectl describe pod/testpod
kubectl logs -f testpod
kubectl delete pod testpod

MULTI CONTAINER POD ENVIRONMENT
Pod2.yml

kind: Pod
apiVersion: v1
metadata:
name: testpod3
spec:
containers:
- name: c00
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo The Beatles; sleep 5 ; done"]
- name: c01
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo Hello-Shishir; sleep 5 ; done"]

POD ENVIRONMENT VARIABLES
Pod3.yml

kind: Pod
apiVersion: v1
metadata:
name: environments
spec:
containers:
- name: c00
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo Hello-shishir; sleep 5 ; done"]
env: # List of environment variables to be used inside the pod
- name: MYNAME
value: SHISHIR

POD WITH PORTS
Pod4.yml

kind: Pod
apiVersion: v1
metadata:
name: testpod4
spec:
containers:
- name: c00
image: httpd
ports:
- containerPort: 80

1
Subscribe to my newsletter

Read articles from Shishir Tambe directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shishir Tambe
Shishir Tambe

Newbie to IT/CS