Minikube – Deploying an app

The following is based on module two of the Kubernetes Bootcamp.
K8S Bootcamp: Module 2

Module overview

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

First application deployment

# View the nodes in the cluster

kubectl get nodes

# run an example app on port 8080

kubectl run kubernetes-bootcamp –image=docker.io/jocatalin/kubernetes-bootcamp:v1 –port=8080

# Observe the deployments

kubectl get deployments

# Results indicate 1 deployment running as a single instance of the app. The instance is running inside a Docker container on the node.

# Note by default deployed applications are only visible with the Kubernetes cluster. To route traffic between the terminal and the Kubernetes cluster, we can use a proxy.

# Start a proxy

kubectl proxy

# The proxy provides a connection between the host and the cluster. To access the app, we need to get the name of the Pod it is running in and store the name as an environment variable (i.e. POD_NAME).

export POD_NAME=$(kubectl get pods -o go-template –template ‘{{range .items}}{{.metadata.name}}{{“\n”}}{{end}}’) echo Name of the Pod: $POD_NAME

# To see the output

curl http://localhost:8001/api/v1/proxy/namespaces/default/pods/$POD_NAME/

Stuff you should now know

  • Kubectl is the kubernetes command line interface (cli) tool.
  • Deployments are responsible for managing the state of the applications by creating and updating the associated instances.
  • To initiate a new deployment, use the kubectl run command.
  • To observe existing deployments, use the kubectl get deployments command.

 

 

Leave a comment