diff --git a/_data/toc.yaml b/_data/toc.yaml index 39b18959b0..9e691797ba 100644 --- a/_data/toc.yaml +++ b/_data/toc.yaml @@ -2905,6 +2905,8 @@ manuals: title: Getting started - path: /docker-for-windows/install/ title: Install Docker for Windows + - path: /docker-for-windows/kubernetes/ + title: Deploy on Kubernetes - path: /docker-for-windows/troubleshoot/ title: Logs and troubleshooting - path: /docker-for-windows/faqs/ diff --git a/_includes/kubernetes-mac-win.md b/_includes/kubernetes-mac-win.md new file mode 100644 index 0000000000..e2cc1dddf8 --- /dev/null +++ b/_includes/kubernetes-mac-win.md @@ -0,0 +1,173 @@ +{% assign platform = include.platform %} + +{% comment %} + +Include a chunk of this file, using variables already set in the file +where you want to reuse the chunk. + +Usage: {% include kubernetes-mac-win.md platform="mac" %} + +{% endcomment %} + +{% if platform == "mac" %} + {% assign product = "Docker for Mac" %} + + {% capture min-version %}{{ product }} 17.12 CE Edge{% endcapture %} + + {% capture version-caveat %} +**Kubernetes is only available in {{ min-version }} and higher, on the Edge +channel.** Kubernetes support is not included in Docker for Mac Stable releases. + {% endcapture %} + + {% capture local-kubectl-warning %} +> If you independently installed the Kubernetes CLI, `kubectl`, make sure that +> it is pointing to `docker-for-desktop` and not some other context such as +> `minikube` or a GKE cluster. Run: `kubectl config use-context docker-for-desktop`. +> If you experience conflicts with an existing `kubectl` installation, remove `/usr/local/bin/kubectl`. + + {% endcapture %} + + {% assign kubectl-path = "/usr/local/bin/kubectl" %} + +{% elsif platform == "windows" %} + {% assign product = "Docker for Windows" %} + + {% capture min-version %}{{ product }} 18.02 CE Edge{% endcapture %} + + {% capture version-caveat %} + **Kubernetes is only available in {{ min-version }}.** Kubernetes + support is not included in {{ product }} 18.02 CE Stable. + {% endcapture %} + + {% capture local-kubectl-warning %} +If you installed `kubectl` by another method, and experience conflicts, remove it. + {% endcapture %} + + {% assign kubectl-path = "C:\>Program Files\Docker\Docker\Resources\bin\kubectl.exe" %} + +{% endif %} + +{{ version-caveat }} To find out more about Stable and Edge channels and how to +switch between them, see +[General configuration](/docker-for-{{ platform }}/#general). + +{{ min-version }} includes a standalone Kubernetes server and client, +as well as Docker CLI integration. The Kubernetes server runs locally within +your Docker instance, is not configurable, and is a single-node cluster. + +The Kubernetes server runs within a Docker container on your local system, and +is only for local testing. When Kubernetes support is enabled, you can deploy +your workloads, in parallel, on Kubernetes, Swarm, and as standalone containers. +Enabling or disabling the Kubernetes server does not affect your other +workloads. + +See [{{ product }} > Getting started](/docker-for-{{ platform }}/index.md#kubernetes) to +enable Kubernetes and begin testing the deployment of your workloads on +Kubernetes. + +{{ kubectl-warning }} + +## Use Docker commands + +You can deploy a stack on Kubernetes with `docker stack deploy`, the +`docker-compose.yml` file, and the name of the stack. + +```bash +docker stack deploy --compose-file /path/to/docker-compose.yml mystack +docker stack services mystack +``` + +You can see the service deployed with the `kubectl get services` command. + +### Specify a namespace + +By default, the `default` namespace is used. You can specify a namespace with +the `--namespace` flag. + +```bash +docker stack deploy --namespace my-app --compose-file /path/to/docker-compose.yml mystack +``` + +Run `kubectl get services -n my-app` to see only the services deployed in the +`my-app` namespace. + +### Override the default orchestrator + +While testing Kubernetes, you may want to deploy some workloads in swarm mode. +Use the `DOCKER_ORCHESTRATOR` variable to override the default orchestrator for +a given terminal session or a single Docker command. This variable can be unset +(the default, in which case Kubernetes is the orchestrator) or set to `swarm` or +`kubernetes`. The following command overrides the orchestrator for a single +deployment, by setting the variable{% if platform == "mac"" %} +at the start of the command itself. + +```bash +DOCKER_ORCHESTRATOR=swarm docker stack deploy --compose-file /path/to/docker-compose.yml mystack +```{% elsif platform == "windows" %} +before running the command. + +```shell +set DOCKER_ORCHESTRATOR=swarm +docker stack deploy --compose-file /path/to/docker-compose.yml mystack +``` + +{% endif %} + +> **Note**: Deploying the same app in Kubernetes and swarm mode may lead to +> conflicts with ports and service names. + +## Use the kubectl command + +The {{ platform }} Kubernetes integration provides the Kubernetes CLI command +at `{{ kubernetes-path }}`. This location may not be in your shell's `PATH` +variable, so you may need to type the full path of the command or add it to +the `PATH`. For more information about `kubectl`, see the +[official `kubectl` documentation](https://kubernetes.io/docs/reference/kubectl/overview/). +You can test the command by listing the available nodes: + +```bash +kubectl get nodes + +NAME STATUS ROLES AGE VERSION +docker-for-desktop Ready master 3h v1.8.2 +``` + +## Example app + +Docker has created the following demo app that you can deploy to swarm mode or +to Kubernetes using the `docker stack deploy` command. + +```yaml +version: '3.3' + +services: + web: + build: web + image: dockerdemos/lab-web + volumes: + - "./web/static:/static" + ports: + - "80:80" + + words: + build: words + image: dockerdemos/lab-words + deploy: + replicas: 5 + endpoint_mode: dnsrr + resources: + limits: + memory: 16M + reservations: + memory: 16M + + db: + build: db + image: dockerdemos/lab-db +``` + +If you already have a Kubernetes YAML file, you can deploy it using the +`kubectl` command. + + + diff --git a/docker-for-mac/index.md b/docker-for-mac/index.md index 0bb749f962..96d330c7cf 100644 --- a/docker-for-mac/index.md +++ b/docker-for-mac/index.md @@ -1,6 +1,6 @@ --- description: Getting Started -keywords: mac, beta, edge, alpha, tutorial +keywords: mac, edge, tutorial redirect_from: - /mackit/ - /mackit/getting-started/ @@ -297,13 +297,14 @@ choose to discard or not apply changes when asked. ### Kubernetes -**Kubernetes is only available in Docker for Mac 17.12 CE Edge.** Kubernetes -support is not included in Docker for Mac 17.12 CE Stable. To find out -more about Stable and Edge channels and how to switch between them, see -[General configuration](/docker-for-mac/#general). +**Kubernetes is only available in Docker for Mac 17.12 CE and higher, on the Edge +channel.** Kubernetes support is not included in Docker for Mac Stable releases. +To find out more about Stable and Edge channels and how to switch between them, +see [General configuration](/docker-for-mac/#general). -Docker for Mac 17.12 CE Edge includes a standalone Kubernetes server that runs -on your Mac, so that you can test deploying your Docker workloads on Kubernetes. +Docker for Mac 17.12 CE (and higher) Edge includes a standalone Kubernetes server +that runs on your Mac, so that you can test deploying your Docker workloads on +Kubernetes. The Kubernetes client command, `kubectl`, is included and configured to connect to the local Kubernetes server. If you have `kubectl` already installed and diff --git a/docker-for-mac/kubernetes.md b/docker-for-mac/kubernetes.md index 703faa1ebd..fc445f510e 100644 --- a/docker-for-mac/kubernetes.md +++ b/docker-for-mac/kubernetes.md @@ -4,119 +4,4 @@ keywords: mac, edge, kubernetes, kubectl, orchestration title: Deploy to Kubernetes --- -**Kubernetes is only available in Docker for Mac 17.12 CE Edge.** Kubernetes -support is not included in Docker for Mac 17.12 CE Stable. To find out -more about Stable and Edge channels and how to switch between them, see -[General configuration](/docker-for-mac/#general). - -Docker for Mac 17.12 CE Edge includes a standalone Kubernetes server and client, -as well as Docker CLI integration. The Kubernetes server runs locally within -your Docker instance, is not configurable, and is a single-node cluster. - -The Kubernetes server runs within a Docker container on your Mac, and is only -for local testing. When Kubernetes support is enabled, you can deploy your -workloads, in parallel, on Kubernetes, Swarm, and as standalone containers. -Enabling or disabling the Kubernetes server does not affect your other -workloads. - -See [Docker for Mac > Getting started](/docker-for-mac/index.md#kubernetes) to -enable Kubernetes and begin testing the deployment of your workloads on -Kubernetes. - -> If you independently installed the Kubernetes CLI, `kubectl`, make sure that -> it is pointing to `docker-for-desktop` and not some other context such as -> `minikube` or a GKE cluster. Run: `kubectl config use-context docker-for-desktop`. -> If you experience conflicts with an existing `kubectl` installation, remove `/usr/local/bin/kubectl`. - -## Use Docker commands - -You can deploy a stack on Kubernetes with `docker stack deploy`, the -`docker-compose.yml` file, and the name of the stack. - -```bash -$ docker stack deploy --compose-file /path/to/docker-compose.yml mystack -$ docker stack services mystack -``` - -You can see the service deployed with the `kubectl get services` command. - -### Specify a namespace - -By default, the `default` namespace is used. You can specify a namespace with -the `--namespace` flag. - -```bash -$ docker stack deploy --namespace my-app --compose-file /path/to/docker-compose.yml mystack -``` - -Run `kubectl get services -n my-app` to see only the services deployed in the -`my-app` namespace. - -### Override the default orchestrator - -While testing Kubernetes, you may want to deploy some workloads in swarm mode. -Use the `DOCKER_ORCHESTRATOR` variable to override the default orchestrator for -a given terminal session or a single Docker command. This variable can be unset -(the default, in which case Kubernetes is the orchestrator) or set to `swarm` or -`kubernetes`. The following command overrides the orchestrator for a single -deployment, by setting the variable at the start of the command itself. - -```bash -DOCKER_ORCHESTRATOR=swarm docker stack deploy --compose-file /path/to/docker-compose.yml mystack -``` - -> **Note**: Deploying the same app in Kubernetes and swarm mode may lead to -> conflicts with ports and service names. - -## Use the kubectl command - -The Docker for Mac Kubernetes integration provides the Kubernetes CLI command -at `/usr/local/bin/kubectl`. This location may not be in your shell's `PATH` -variable, so you may need to type the full path of the command or add it to -the `PATH`. For more information about `kubectl`, see the -[official `kubectl` documentation](https://kubernetes.io/docs/reference/kubectl/overview/). -You can test the command by listing the available nodes: - -```bash -$ kubectl get nodes - -NAME STATUS ROLES AGE VERSION -docker-for-desktop Ready master 3h v1.8.2 -``` - -## Example app - -Docker has created the following demo app that you can deploy to swarm mode or -to Kubernetes using the `docker stack deploy` command. - -```yaml -version: '3.3' - -services: - web: - build: web - image: dockerdemos/lab-web - volumes: - - "./web/static:/static" - ports: - - "80:80" - - words: - build: words - image: dockerdemos/lab-words - deploy: - replicas: 5 - endpoint_mode: dnsrr - resources: - limits: - memory: 16M - reservations: - memory: 16M - - db: - build: db - image: dockerdemos/lab-db -``` - -If you already have a Kubernetes YAML file, you can deploy it using the -`kubectl` command. +{% include kubernetes-mac-win.md platform="mac" %} \ No newline at end of file diff --git a/docker-for-windows/images/kubernetes/kubernetes-enable.png b/docker-for-windows/images/kubernetes/kubernetes-enable.png new file mode 100644 index 0000000000..161de87f2a Binary files /dev/null and b/docker-for-windows/images/kubernetes/kubernetes-enable.png differ diff --git a/docker-for-windows/images/kubernetes/kubernetes-status.png b/docker-for-windows/images/kubernetes/kubernetes-status.png new file mode 100644 index 0000000000..af0c01f62b Binary files /dev/null and b/docker-for-windows/images/kubernetes/kubernetes-status.png differ diff --git a/docker-for-windows/index.md b/docker-for-windows/index.md index 91a8212a3d..bbbb4c9b52 100644 --- a/docker-for-windows/index.md +++ b/docker-for-windows/index.md @@ -1,6 +1,6 @@ --- description: Getting Started -keywords: windows, beta, edge, alpha, tutorial +keywords: windows, edge, tutorial redirect_from: - /winkit/getting-started/ - /winkit/ @@ -705,6 +705,57 @@ Check out these [Docker Cloud topics](/docker-cloud/index.md) to learn more: Need a direct link to Cloud? [Take me to Docker Cloud](https://cloud.docker.com/){: target="_blank" class="_" }. +### Kubernetes + +**Kubernetes is only available in Docker for Windows 18.02 CE Edge.** Kubernetes +upport is not included in Docker for Windows 18.02 CE Stable. + +To find out more about Stable and Edge channels and how to switch between them, +see [General configuration](/docker-for-windows/#general). + +Docker for Windows 18.02 CE Edge includes a standalone Kubernetes server that runs +on your Windows host, so that you can test deploying your Docker workloads on Kubernetes. + +The Kubernetes client command, `kubectl`, is included and configured to connect +to the local Kubernetes server. If you have `kubectl` already installed and +pointing to some other environment, such as `minikube` or a GKE cluster, be sure +to change context so that `kubectl` is pointing to `docker-for-desktop`: + +```bash +kubectl config get-contexts +kubectl config use-context docker-for-desktop +``` + +If you installed `kubectl` by another method, and +experience conflicts, remove it. + +- To enable Kubernetes support and install a standalone instance of Kubernetes + running as a Docker container, select **Enable Kubernetes** and click the + **Apply and restart** button. + + ![Enable Kubernetes](/docker-for-windows/images/kubernetes/kubernetes-enable.png) + + An internet connection is required. Images required to run the Kubernetes + server are downloaded and instantiated as containers, and the + `C:\>Program Files\Docker\Docker\Resources\bin\kubectl.exe` command is installed. + + When Kubernetes is enabled and running, an additional status bar item displays + at the bottom left of the Docker for Windows Preferences dialog. + + ![Kubernetes status](/docker-for-windows/images/kubernetes/kubernetes-status.png) + +- By default, Kubernetes containers are hidden from commands like `docker + service ls`, because managing them manually is not supported. To make them + visible, select **Show system containers (advanced)** and click **Apply and restart**. + Most users do not need this option. + +- To disable Kubernetes support at any time, deselect **Enable Kubernetes**. + The Kubernetes containers are stopped and removed, and the + `/usr/local/bin/kubectl` command is removed. + + For more about using the Kubernetes integration with + Docker for Windows, see [Deploy to Kubernetes](/docker-for-windows/kubernetes.md). + ### Giving feedback and getting help To get help from the community, review current user topics, join or start a diff --git a/docker-for-windows/kubernetes.md b/docker-for-windows/kubernetes.md new file mode 100644 index 0000000000..8f989ecc56 --- /dev/null +++ b/docker-for-windows/kubernetes.md @@ -0,0 +1,7 @@ +--- +description: Deploying to Kubernetes on Docker for Windows +keywords: windows, edge, kubernetes, kubectl, orchestration +title: Deploy to Kubernetes +--- + +{% include kubernetes-mac-win.md platform="windows" %}