k8s-minikube 02 – Create a first Deployment and Service

by Ismail.EL
0 comment

1. Definitions

1-1) What is : Minikube ?

is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

1-2) What is Kubernetes Pod ?

A Pod is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers.

2. Objectives

  • Learn about application Deployments.
  • Deploy your first app on Kubernetes with kubectl.

3. Adience

This article is prepared for anyone who want to create cluster using kubernetes.

4. Prerequisites

Minikube cluster deployed if it is not the case then you can do it using this how-to-install-kubernetes-k8s-using-minikube-linux-mac-and-windows

5. Create a Deployment

  • Use the kubectl create command to create a Deployment that manages a Pod. The Pod runs a Container based on the provided Docker image.
  • View the Deployment:
  • View the Deployment:

The output is similar to:

  • View the Pod:

The output is similar to:

  • View cluster events:
  • View the kubectl configuration:

6. Create a Service

By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster. To make the hello-node Container accessible from outside the Kubernetes virtual network, you have to expose the Pod as a Kubernetes Service.

  • Expose the Pod to the public internet using the kubectl expose command:

The --type=LoadBalancer flag indicates that you want to expose your Service outside of the cluster.

  • View the Service you just created:

The output is similar to:

  • Acces to service by runing the following command:

On minikube, the LoadBalancer type makes the Service accessible through the minikube service command.

As you see in the screenshot you can access to service in the browser via url http://192.168.99.100:32411

7. Conclusion

In this post, i have explained the create your first pod (deployment) and a first service in kubernetes cluster using minikube.
If you have any questions or feedback, feel free to leave a comment.
As always, if you found this post useful, then click like and share it 🙂

22310cookie-checkk8s-minikube 02 – Create a first Deployment and Service

Related Posts

Leave a Comment