Day 38: Creating our first pod on Kubernetes through Minikube
Launching into Kubernetes
Creating your first pod on Kubernetes through Minikube is an exciting step toward exploring container orchestration. Follow these steps to get started:
Install Minikube
In our previous blog, we have gone through the steps on how to install Minikube on our local machine. Minikube allows you to run a single-node Kubernetes cluster locally for development and testing.
Start Minikube
Open the terminal and start Minikube using the following command:
minikube start
Create a Pod Definition
Create a YAML file (e.g., my-first-pod.yaml
) with the definition of your pod. Here's a simple example:
apiVersion: v1
kind: Pod
metadata:
name: my-first-pod
spec:
containers:
- name: my-container
image: nginx:latest
In this example, we're creating a pod named my-first-pod
that runs an Nginx container.
Apply the Pod Definition
Apply the pod definition to your Minikube cluster using the kubectl
command:
kubectl apply -f my-first-pod.yaml
Check the Pod Status
You can check the status of your pod using:
kubectl get pods
The output will show the pod's name, status, and other details. Once the pod's status changes to "Running," your Nginx container is up and running.
Access the Pod
To access the Nginx service inside the pod, you need to expose it using a service or port-forwarding. For port-forwarding, use:
kubectl port-forward my-first-pod 8080:80
Now you can open a web browser and navigate to http://localhost:8080
to see the default Nginx page.
Conclusion:
Finally !! We've successfully created the first pod on Kubernetes using Minikube. This simple example gives you a glimpse of how to define and deploy containers within a Kubernetes cluster. Feel free to explore more advanced features and deploy different types of workloads as you dive deeper into the Kubernetes world.
Hope you like my post. Don't forget to like, comment, and share.