Skip to content

Latest commit

 

History

History
197 lines (122 loc) · 5.04 KB

README.md

File metadata and controls

197 lines (122 loc) · 5.04 KB

Project 01: Setup Minikube

Objective

In this project, you will set up a local Kubernetes cluster using Minikube and deploy a sample application to get familiar with basic Kubernetes operations.

Steps

1. Install Minikube and kubectl

2. Create a Cluster with Minikube

  • Start Minikube and create a local Kubernetes cluster:

    minikube start

    This command will start a local Kubernetes cluster using a virtual machine or container.

    Minikube Start Command

3. Deploy a Sample Application

  • Deploy a simple web server application:

    kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0

    This command creates a deployment named hello-minikube using the echoserver image.

    Deployment of Echo Server

4. Expose and Access the Application

Using a Service

  • Expose the deployment as a service to make it accessible:

    kubectl expose deployment hello-minikube --type=NodePort --port=8080

    This command creates a service of type NodePort that maps port 8080 of the service to a port on the node.

    Service Exposure Command

  • Use kubectl to forward the port:

    kubectl port-forward service/hello-minikube 7080:8080

    This command forwards port 8080 of the service to port 7080 on your localhost, making the application accessible at http://localhost:7080/.

    Service in Browser with Port Forwarding

  • Alternatively, get the URL to access the application:

    minikube service hello-minikube

    This command provides the URL where you can access the sample application running in your Minikube cluster.

    Service Minikube Launch Service in Browser with Minikube Launch

Using a LoadBalancer

  • Create a deployment:

    kubectl create deployment balanced --image=kicbase/echo-server:1.0

    Balanced Deployment Creation

  • Expose the deployment as a LoadBalancer service:

    kubectl expose deployment balanced --type=LoadBalancer --port=8080

    LoadBalancer Service Exposure

  • Start the tunnel to create a routable IP for the 'balanced' deployment in another window:

    minikube tunnel

    Minikube Tunnel Start

  • Find the routable IP by running this command and examining the EXTERNAL-IP column:

    kubectl get services balanced

    Get Services with EXTERNAL-IP

    Your deployment is now available at 10.101.45.106:8080.

    Balanced Deployment Access

Using an Ingress

  • Enable the ingress addon:

    minikube addons enable ingress

    Enable Ingress Addon

  • Create an example deployment and service with Ingress:

Files
  • Apply the Ingress configuration:

    kubectl apply -f resources/foo-app.yaml
    kubectl apply -f resources/foo-service.yaml
    kubectl apply -f resources/bar-app.yaml
    kubectl apply -f resources/bar-service.yaml
    kubectl apply -f resources/ingress.yaml

    Apply Ingress Configuration

  • Get the Minikube IP:

    minikube ip
  • Access the application via the Ingress host configured in ingress.yaml.

    kubectl get ingress
    curl 192.168.49.2/foo
    # Output: Request served by foo-app
    
    curl 192.168.49.2/bar
    # Output: Request served by bar-app

    Ingress Access Verification

5. Scale the Application

  • Scale the deployment to run multiple replicas:

    kubectl scale deployment hello-minikube --replicas=3

    This command scales the deployment to 3 replicas.

    Scale the application

6. Perform a Rolling Update

  • Update the deployment with a new image:

    kubectl set image deployment/hello-minikube echo-server=kicbase/echo-server:latest

    This command performs a rolling update to the deployment by changing the container image to echo-server:latest.

    performs a rolling update

Resources