Kubernetes is an orchestrator for microservice apps running on containers. It is open source and automates the deployment, scaling and management of containerized applications.
For your local development purpose you might not want to interact with the K8s cluster hosted in Cloud & spend additional dollars. Also debugging can be challenging if you do not have services running locally. So in that case, as the initial step — you can build your docker image and test it locally first by deploying into Minikube.
I have created a video tutorial to setup a local development environment for K8s using Minikube. I will walk you through how to perform the required installations to create a running K8s cluster locally. We will then deploy an app using the K8s CLI. Once done, we will explore the deployed application and environments.
Minikube is a tool that allows you to run a single-node K8s cluster locally. Minikube starts a VM and runs the necessary K8s components. Once the K8s cluster is up, you can interact with it using the K8s CLI – kubectl.
Kubectl is used for running commands to deploy and manage components against your K8s instance. Minikube also configures kubectl for you.
You can find below the scripts used in the demonstration —
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|// Install Minikube|
|brew cask install minikube|
|// Verify that minikube is properly installed|
|// Install the Kubernetes Command Line Utility – kubectl|
|brew install kubectl|
|// Start Minikube|
|// Check Minikube status|
|// View Kubernetes Dashboard|
|// View Kubernetes Cluster Information|
|// View the nodes that can be used to host your applications|
|kubectl get nodes|
|// Create a new deployment|
|kubectl run hello-minikube –image=k8s.gcr.io/echoserver:1.4 –port=8080|
|// List the deployments|
|kubectl get deployments|
|// Expose the deployment to an external IP|
|kubectl expose deployment hello-minikube –type=NodePort|
|// View the K8s services|
|kubectl get services|
|// View the URL that you can hit via browser|
|minikube service hello-minikube –url|
|// View the K8s pods in the cluster|
|kubectl get pods|
|// View the details of a specific resource|
|kubectl describe svc hello-minikube|
|// Delete the service and deployment|
|kubectl delete service,deployment hello-minikube|
|// Shut down the Minikube cluster|
Leave a Reply