--- title: Hello Minikube content_type: tutorial weight: 5 menu: main: title: "Get Started" weight: 10 post: >
Ready to get your hands dirty? Build a simple Kubernetes cluster that runs a sample app.
card: name: tutorials weight: 10 --- This tutorial shows you how to run a sample app on Kubernetes using minikube. The tutorial provides a container image that uses NGINX to echo back all the requests. ## {{% heading "objectives" %}} * Deploy a sample application to minikube. * Run the app. * View application logs. ## {{% heading "prerequisites" %}} This tutorial assumes that you have already set up `minikube`. See [minikube start](https://minikube.sigs.k8s.io/docs/start/) for installation instructions. You also need to install `kubectl`. See [Install tools](/docs/tasks/tools/#kubectl) for installation instructions. ## Create a minikube cluster ```shell minikube start ``` ## Open the Dashboard Open the Kubernetes dashboard. You can do this two different ways: {{< tabs name="dashboard" >}} {{% tab name="Launch a browser" %}} Open a **new** terminal, and run: ```shell # Start a new terminal, and leave this running. minikube dashboard ``` Now, switch back to the terminal where you ran `minikube start`. {{< note >}} The `dashboard` command enables the dashboard add-on and opens the proxy in the default web browser. You can create Kubernetes resources on the dashboard such as Deployment and Service. If you are running in an environment as root, see [Open Dashboard with URL](#open-dashboard-with-url). By default, the dashboard is only accessible from within the internal Kubernetes virtual network. The `dashboard` command creates a temporary proxy to make the dashboard accessible from outside the Kubernetes virtual network. To stop the proxy, run `Ctrl+C` to exit the process. After the command exits, the dashboard remains running in the Kubernetes cluster. You can run the `dashboard` command again to create another proxy to access the dashboard. {{< /note >}} {{% /tab %}} {{% tab name="URL copy and paste" %}} If you don't want minikube to open a web browser for you, run the dashboard command with the `--url` flag. `minikube` outputs a URL that you can open in the browser you prefer. Open a **new** terminal, and run: ```shell # Start a new terminal, and leave this running. minikube dashboard --url ``` Now, switch back to the terminal where you ran `minikube start`. {{% /tab %}} {{< /tabs >}} ## Create a Deployment A Kubernetes [*Pod*](/docs/concepts/workloads/pods/) is a group of one or more Containers, tied together for the purposes of administration and networking. The Pod in this tutorial has only one Container. A Kubernetes [*Deployment*](/docs/concepts/workloads/controllers/deployment/) checks on the health of your Pod and restarts the Pod's Container if it terminates. Deployments are the recommended way to manage the creation and scaling of Pods. 1. Use the `kubectl create` command to create a Deployment that manages a Pod. The Pod runs a Container based on the provided Docker image. ```shell # Run a test container image that includes a webserver kubectl create deployment hello-node --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- /agnhost netexec --http-port=8080 ``` 1. View the Deployment: ```shell kubectl get deployments ``` The output is similar to: ``` NAME READY UP-TO-DATE AVAILABLE AGE hello-node 1/1 1 1 1m ``` 1. View the Pod: ```shell kubectl get pods ``` The output is similar to: ``` NAME READY STATUS RESTARTS AGE hello-node-5f76cf6ccf-br9b5 1/1 Running 0 1m ``` 1. View cluster events: ```shell kubectl get events ``` 1. View the `kubectl` configuration: ```shell kubectl config view ``` {{< note >}} For more information about `kubectl` commands, see the [kubectl overview](/docs/reference/kubectl/). {{< /note >}} ## 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*](/docs/concepts/services-networking/service/). 1. Expose the Pod to the public internet using the `kubectl expose` command: ```shell kubectl expose deployment hello-node --type=LoadBalancer --port=8080 ``` The `--type=LoadBalancer` flag indicates that you want to expose your Service outside of the cluster. The application code inside the test image only listens on TCP port 8080. If you used `kubectl expose` to expose a different port, clients could not connect to that other port. 2. View the Service you created: ```shell kubectl get services ``` The output is similar to: ``` NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-node LoadBalancer 10.108.144.78