Day 31 Task: Launching your First Kubernetes Cluster with Nginx running
What about doing some hands-on now?
- Let's read about minikube and implement kubeadm in our local machine
What is minikube?
Minikube is a tool that quickly sets up a local Kubernetes cluster on macOS, Linux, and Windows. It can deploy as a VM, a container, or on bare metal.
Minikube is a pared-down version of Kubernetes that gives you all the benefits of Kubernetes with a lot less effort.
This makes it an interesting option for users who are new to containers, and also for projects in the world of edge computing and the Internet of Things.
Features of minikube:
(a) Supports the latest Kubernetes release (+6 previous minor versions)
(b) Cross-platform (Linux, macOS, Windows)
(c) Deploy as a VM, a container, or on bare-metal
(d) Multiple container runtimes (CRI-O, containerd, docker)
(e) Direct API endpoint for blazing fast image load and build
(f) Advanced features such as LoadBalancer, filesystem mounts, FeatureGates, and network policy
(g) Addons for easily installed Kubernetes applications
(h) Supports common CI environments
Task-01:
Installation guide of minikube and kubeadm on your local
Let's understand the concept of pod
Let's deploy Nginx in Minikube, then move on to the next tasks or blogs where we'll set up Kubeadm and continue our Kubernetes journey.
Pods are the smallest deployable units of computing that you can create and manage in Kubernetes.
A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers. A Pod's contents are always co-located and co-scheduled, and run in a shared context. A Pod models an application-specific "logical host": it contains one or more application containers which are relatively tightly coupled.
Task-02:
Create your first pod on Kubernetes through Minikube.
- Step 1: Create a YAML file for an Nginx pod.
# vim pod.yaml
-------------------------------------------------------------------------------
apiVersion: v1 # Specifies the Kubernetes API version used in the configuration.
kind: Pod # Defines the type of Kubernetes resource, in this case, a Pod.
metadata: # Contains metadata about the Pod, including its name.
name: nginx # Names the container as "nginx".
spec: # Describes the Pod's desired state.
containers: # Defines the container(s) within the Pod.
- name: nginx # Names the container as "nginx".
image: nginx:1.14.2 # Specifies the Docker image (nginx:1.14.2) to use for the container.
ports: # Specifies the ports to open within the container.
- containerPort: 80 # Exposes port 80 inside the container, allowing external access to the application running within the Pod.
- Step 2: Now to check if the pod is created or not, use this commands for a detailed view and you will see our pod is running on IP : 10.244.0.3
kubectl apply -f pod.yaml
kubectl get pods
kubectl get pods -o wide
- Step 3: Let's see if, we have to go inside the Kubernetes cluster, minikube makes this quick easy, using this this command to get inside and then use curl to get the data from the IP
minikube ssh
- Step 4: After that use this command and You can see now that nginx is running inside the pod and you can operate your container
curl -L http://10.244.0.3:80