[WIP] Clean up and reorganize minikube.md (#14255)

The current content was not following the style guide and lacked information on what the user was doing under the quick start section. Added more information and tested the section out. Further reorganized the content.

Correct typos

Updated the content.

Updated the content

Fixed syntax error.

Update the unordered list formatting

Fix formatting issues

Formatting update

Format the content

Format the content

Format content

Format ordered content

Format unordered list

Clean up and reorganize minikube.md

Updated the content

Updated the content as per the comments received.

Fixed an error

Fixes the note shortcode

Fixes error in shortcode

Clean up and reorganize minikube.md
pull/14604/head
shavidissa 2019-05-29 00:00:21 -07:00 committed by Kubernetes Prow Robot
parent f38c90768d
commit 5c9a9b1fe2
1 changed files with 196 additions and 195 deletions

View File

@ -9,7 +9,7 @@ content_template: templates/concept
{{% capture overview %}}
Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day.
Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day.
{{% /capture %}}
@ -17,14 +17,15 @@ Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a
## Minikube Features
* Minikube supports Kubernetes features such as:
* DNS
* NodePorts
* ConfigMaps and Secrets
* Dashboards
* Container Runtime: Docker, [rkt](https://github.com/rkt/rkt), [CRI-O](https://github.com/kubernetes-incubator/cri-o) and [containerd](https://github.com/containerd/containerd)
* Enabling CNI (Container Network Interface)
* Ingress
Minikube supports the following Kubernetes features:
* DNS
* NodePorts
* ConfigMaps and Secrets
* Dashboards
* Container Runtime: Docker, [rkt](https://github.com/rkt/rkt), [CRI-O](https://github.com/kubernetes-incubator/cri-o), and [containerd](https://github.com/containerd/containerd)
* Enabling CNI (Container Network Interface)
* Ingress
## Installation
@ -32,9 +33,169 @@ See [Installing Minikube](/docs/tasks/tools/install-minikube/).
## Quickstart
Here's a brief demo of Minikube usage.
If you want to change the VM driver add the appropriate `--vm-driver=xxx` flag to `minikube start`. Minikube supports
the following drivers:
This brief demo guides you on how to start, use, and delete Minikube locally. Follow the steps given below to start and explore Minikube.
1. Start Minikube and create a cluster:
```shell
minikube start
```
The output is similar to this:
```
Starting local Kubernetes cluster...
Running pre-create checks...
Creating machine...
Starting local Kubernetes cluster...
```
For more information on starting your cluster on a specific Kubernetes version, VM, or container runtime, see [Starting a Cluster](docs/setup/minikube/#starting-a-cluster).
2. Now, you can interact with your cluster using kubectl. For more information, see [Interacting with Your Cluster](docs/setup/minikube/#interacting-with-your-cluster).
Lets create a Kubernetes Deployment using an existing image named `echoserver`, which is a simple HTTP server and expose it on port 8080 using `--port`.
```shell
kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080
```
The output is similar to this:
```
deployment.apps/hello-minikube created
```
3. To access the `hello-minikue` Deployment, expose it as a Service:
```shell
kubectl expose deployment hello-minikube --type=NodePort
```
The option `--type=NodePort` specifies the type of the Service.
The output is similar to this:
```
service/hello-minikube exposed
```
4. The `hello-minikube` Pod is now launched but you have to wait until the Pod is up before accessing it via the exposed Service.
Check if the Pod is up and running:
```shell
kubectl get pod
```
If the output shows the `STATUS` as `ContainerCreating`, the Pod is still being created:
```
NAME READY STATUS RESTARTS AGE
hello-minikube-3383150820-vctvh 0/1 ContainerCreating 0 3s
```
If the output shows the `STATUS` as `Running`, the Pod is now up and running:
```
NAME READY STATUS RESTARTS AGE
hello-minikube-3383150820-vctvh 1/1 Running 0 13s
```
5. Get the URL of the exposed Service to view the Service details:
```shell
minikube service hello-minikube --url
```
6. To view the details of your local cluster, copy and paste the URL you got as the output, on your browser.
The output is similar to this:
```
Hostname: hello-minikube-7c77b68cff-8wdzq
Pod Information:
-no pod information available-
Server values:
server_version=nginx: 1.13.3 - lua: 10008
Request Information:
client_address=172.17.0.1
method=GET
real path=/
query=
request_version=1.1
request_scheme=http
request_uri=http://192.168.99.100:8080/
Request Headers:
accept=*/*
host=192.168.99.100:30674
user-agent=curl/7.47.0
Request Body:
-no body in request-
```
If you no longer want the Service and cluster to run, you can delete them.
7. Delete the `hello-minikube` Service:
```shell
kubectl delete services hello-minikube
```
The output is similar to this:
```
service "hello-minikube" deleted
```
8. Delete the `hello-minikube` Deployment:
```shell
kubectl delete deployment hello-minikube
```
The output is similar to this:
```
deployment.extensions "hello-minikube" deleted
```
9. Stop the local Minikube cluster:
```shell
minikube stop
```
The output is similar to this:
```
Stopping "minikube"...
"minikube" stopped.
```
For more information, see [Stopping a Cluster](docs/setup/minikube/#stopping-a-cluster).
10. Delete the local Minikube cluster:
```shell
minikube delete
```
The output is similar to this:
```
Deleting "minikube" ...
The "minikube" cluster has been deleted.
```
For more information, see [Deleting a cluster](/docs/setup/minikube/#deleting-a-cluster).
## Managing your Cluster
### Starting a Cluster
The `minikube start` command can be used to start your cluster.
This command creates and configures a Virtual Machine that runs a single-node Kubernetes cluster.
This command also configures your [kubectl](/docs/user-guide/kubectl-overview/) installation to communicate with this cluster.
{{< note >}}
If you are behind a web proxy, you need to pass this information to the `minikube start` command:
```shell
https_proxy=<my proxy> minikube start --docker-env http_proxy=<my proxy> --docker-env https_proxy=<my proxy> --docker-env no_proxy=192.168.99.0/24
```
Unfortunately, setting the environment variables alone does not work.
Minikube also creates a "minikube" context, and sets it to default in kubectl.
To switch back to this context, run this command: `kubectl config use-context minikube`.
{{< /note >}}
#### Specifying the Kubernetes version
You can specify the version of Kubernetes for Minikube to use by
adding the `--kubernetes-version` string to the `minikube start` command. For
example, to run version {{< param "fullversion" >}}, you would run the following:
```
minikube start --kubernetes-version {{< param "fullversion" >}}
```
#### Specifying the VM driver
You can change the VM driver by adding the `--vm-driver=<enter_driver_name>` flag to `minikube start`.
For example the command would be.
```shell
minikube start --vm-driver=<driver_name>
```
Minikube supports the following drivers:
{{< note >}}
See [DRIVERS](https://git.k8s.io/minikube/docs/drivers.md) for details on supported drivers and how to install
plugins.
{{< /note >}}
* virtualbox
* vmwarefusion
@ -45,137 +206,11 @@ Note that the IP below is dynamic and can change. It can be retrieved with `mini
* vmware ([driver installation](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#vmware-unified-driver)) (VMware unified driver)
* none (Runs the Kubernetes components on the host and not in a VM. Using this driver requires Docker ([docker install](https://docs.docker.com/install/linux/docker-ce/ubuntu/)) and a Linux environment)
1. Start a minikube
```
minikube start
```
The output shows that the kubernetes cluster is started:
```
Starting local Kubernetes cluster...
Running pre-create checks...
Creating machine...
Starting local Kubernetes cluster...
```
2. Create an echo server deployment
```
kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080
```
The output of a successful command verifies that the deployment is created:
```
deployment.apps/hello-minikube created
```
3. Expose an echo server deployment to create service
```
kubectl expose deployment hello-minikube --type=NodePort
```
The output of a successful command verifies that the service is created:
```
service/hello-minikube exposed
```
4. Check whether the pod is up and running
```
kubectl get pod
```
The output displays the pod is still being created:
```
NAME READY STATUS RESTARTS AGE
hello-minikube-3383150820-vctvh 0/1 ContainerCreating 0 3s
```
5. Wait for while and then check again, whether the pod is up and running using same command
```
kubectl get pod
```
Now the output displays the pod is created and it is running:
```
NAME READY STATUS RESTARTS AGE
hello-minikube-3383150820-vctvh 1/1 Running 0 13s
```
6. Curl service which we have created
```
curl $(minikube service hello-minikube --url)
```
Output looks similer to this:
```
Hostname: hello-minikube-7c77b68cff-8wdzq
Pod Information:
-no pod information available-
Server values:
server_version=nginx: 1.13.3 - lua: 10008
Request Information:
client_address=172.17.0.1
method=GET
real path=/
query=
request_version=1.1
request_scheme=http
request_uri=http://192.168.99.100:8080/
Request Headers:
accept=*/*
host=192.168.99.100:30674
user-agent=curl/7.47.0
Request Body:
-no body in request-
```
7. Delete the service which we have created
```
kubectl delete services hello-minikube
```
The output of a successful command verifies that the service is deleted:
```
service "hello-minikube" deleted
```
8. Delete the deployment which we have created
```
kubectl delete deployment hello-minikube
```
The output of a successful command verifies that the deployment is deleted:
```
deployment.extensions "hello-minikube" deleted
```
9. Stop a minikube
```
minikube stop
```
The output displays the kubernetes cluster is stopping:
```
Stopping local Kubernetes cluster...
Stopping "minikube"...
```
### Alternative Container Runtimes
#### containerd
#### Starting a cluster on alternative container runtimes
You can start Minikube on the following container runtimes.
{{< tabs name="container_runtimes" >}}
{{% tab name="containerd" %}}
To use [containerd](https://github.com/containerd/containerd) as the container runtime, run:
```bash
minikube start \
--network-plugin=cni \
@ -195,11 +230,9 @@ minikube start \
--extra-config=kubelet.image-service-endpoint=unix:///run/containerd/containerd.sock \
--bootstrapper=kubeadm
```
#### CRI-O
{{% /tab %}}
{{% tab name="CRI-O" %}}
To use [CRI-O](https://github.com/kubernetes-incubator/cri-o) as the container runtime, run:
```bash
minikube start \
--network-plugin=cni \
@ -207,7 +240,6 @@ minikube start \
--container-runtime=cri-o \
--bootstrapper=kubeadm
```
Or you can use the extended version:
```bash
@ -219,48 +251,47 @@ minikube start \
--extra-config=kubelet.image-service-endpoint=/var/run/crio.sock \
--bootstrapper=kubeadm
```
#### rkt container engine
{{% /tab %}}
{{% tab name="rkt container engine" %}}
To use [rkt](https://github.com/rkt/rkt) as the container runtime run:
```shell
minikube start \
--network-plugin=cni \
--enable-default-cni \
--container-runtime=rkt
```
This will use an alternative minikube ISO image containing both rkt, and Docker, and enable CNI networking.
{{% /tab %}}
{{< /tabs >}}
### Driver plugins
#### Use local images by re-using the Docker daemon
See [DRIVERS](https://git.k8s.io/minikube/docs/drivers.md) for details on supported drivers and how to install
plugins, if required.
When using a single VM for Kubernetes, it's useful to reuse Minikube's built-in Docker daemon. Reusing the built-in daemon means you don't have to build a Docker registry on your host machine and push the image into it. Instead, you can build inside the same Docker daemon as Minikube, which speeds up local experiments.
### Use local images by re-using the Docker daemon
{{< note >}}
Be sure to tag your Docker image with something other than latest and use that tag to pull the image. Because `:latest` is the default value, with a corresponding default image pull policy of `Always`, an image pull error (`ErrImagePull`) eventually results if you do not have the Docker image in the default Docker registry (usually DockerHub).
{{< /note >}}
When using a single VM of Kubernetes, it's really handy to reuse the Minikube's built-in Docker daemon; as this means you don't have to build a docker registry on your host machine and push the image into it - you can just build inside the same docker daemon as minikube which speeds up local experiments. Just make sure you tag your Docker image with something other than 'latest' and use that tag while you pull the image. Otherwise, if you do not specify version of your image, it will be assumed as `:latest`, with pull image policy of `Always` correspondingly, which may eventually result in `ErrImagePull` as you may not have any versions of your Docker image out there in the default docker registry (usually DockerHub) yet.
To be able to work with the docker daemon on your mac/linux host use the `docker-env command` in your shell:
To work with the Docker daemon on your Mac/Linux host, use the `docker-env command` in your shell:
```shell
eval $(minikube docker-env)
```
You should now be able to use docker on the command line on your host mac/linux machine talking to the docker daemon inside the minikube VM:
You can now use Docker at the command line of your host Mac/Linux machine to communicate with the Docker daemon inside the Minikube VM:
```shell
docker ps
```
On Centos 7, docker may report the following error:
{{< note >}}
On Centos 7, Docker may report the following error:
```shell
```
Could not read CA certificate "/etc/docker/ca.pem": open /etc/docker/ca.pem: no such file or directory
```
The fix is to update /etc/sysconfig/docker to ensure that Minikube's environment changes are respected:
You can fix this by updating /etc/sysconfig/docker to ensure that Minikube's environment changes are respected:
```shell
< DOCKER_CERT_PATH=/etc/docker
@ -269,37 +300,7 @@ The fix is to update /etc/sysconfig/docker to ensure that Minikube's environment
> DOCKER_CERT_PATH=/etc/docker
> fi
```
Remember to turn off the imagePullPolicy:Always, otherwise Kubernetes won't use images you built locally.
## Managing your Cluster
### Starting a Cluster
The `minikube start` command can be used to start your cluster.
This command creates and configures a Virtual Machine that runs a single-node Kubernetes cluster.
This command also configures your [kubectl](/docs/user-guide/kubectl-overview/) installation to communicate with this cluster.
If you are behind a web proxy, you will need to pass this information to the `minikube start` command:
```shell
https_proxy=<my proxy> minikube start --docker-env http_proxy=<my proxy> --docker-env https_proxy=<my proxy> --docker-env no_proxy=192.168.99.0/24
```
Unfortunately just setting the environment variables will not work.
Minikube will also create a "minikube" context, and set it to default in kubectl.
To switch back to this context later, run this command: `kubectl config use-context minikube`.
#### Specifying the Kubernetes version
You can specify the specific version of Kubernetes for Minikube to use by
adding the `--kubernetes-version` string to the `minikube start` command. For
example, to run version `v1.7.3`, you would run the following:
```
minikube start --kubernetes-version v1.7.3
```
{{< /note >}}
### Configuring Kubernetes
@ -361,7 +362,7 @@ minikube dashboard
### Services
To access a service exposed via a node port, run this command in a shell after starting Minikube to get the address:
To access a Service exposed via a node port, run this command in a shell after starting Minikube to get the address:
```shell
minikube service [-n NAMESPACE] [--url] NAME