Home Explore Blog CI



kubernetes

1st chunk of `content/en/docs/tutorials/hello-minikube.md`
f716ab3a1a952ca3257b522a646fcd5d9562ccdbdbd7742b0000000100000faa
---
title: Hello Minikube
content_type: tutorial
weight: 5
card:
  name: tutorials
  weight: 10
---

<!-- overview -->

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 __Step 1__ in [minikube start](https://minikube.sigs.k8s.io/docs/start/) for installation instructions.
{{< note >}}
Only execute the instructions in __Step 1, Installation__. The rest is covered on this page.  
{{< /note >}}

You also need to install `kubectl`.
See [Install tools](/docs/tasks/tools/#kubectl) for installation instructions.


<!-- lessoncontent -->

## 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.

To find out how to avoid directly invoking the browser from the terminal and get a URL for the web dashboard, see the "URL copy and paste" tab.

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` subcommand 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, you can use this URL and 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
    ```

    (It may take some time for the pod to become available. If you see "0/1", try again in a few seconds.)

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

Title: Deploying a Sample Application on Minikube
Summary
This tutorial guides users on deploying a sample application on Kubernetes using Minikube. It outlines the steps to create a Minikube cluster, open the Kubernetes dashboard, create a deployment, and view the deployment and pod. The application uses a pre-built container image with NGINX to echo back all requests.