os/macOS/kubernetes/README.md
Kubernetes is available in Docker for Mac 17.12 CE Edge and higher, and 18.06 Stable and higher , this 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.
Under this tutorial, we will see how Docker Stack Controller can be used to run Apps on Swarm as well as Kubernetes.
[Captains-Bay]🚩 > docker version
Client: Docker Engine - Community
Version: 18.09.1
API version: 1.39
Go version: go1.10.6
Git commit: 4c52b90
Built: Wed Jan 9 19:33:12 2019
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.1
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 4c52b90
Built: Wed Jan 9 19:41:49 2019
OS/Arch: linux/amd64
Experimental: true
Kubernetes:
Version: v1.13.0
StackAPI: v1beta2
Use the DOCKER_STACK_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.
DOCKER_STACK_ORCHESTRATOR=swarm docker stack deploy -c docker-compose.yml myapp2
[Captains-Bay]🚩 > docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
ety51y7hfwfi myapp2_db1 replicated 2/2 nginx:alpine
9vkik71wtfox myapp2_web1 replicated 3/3 nginx:alpine *:8083->80/tcp
docker service scale myapp2_web1=5
myapp2_web1 scaled to 5
overall progress: 5 out of 5 tasks
1/5: running
2/5: running
3/5: running
4/5: running
5/5: running
verify: Service converged
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
ety51y7hfwfi myapp2_db1 replicated 2/2 nginx:alpine
9vkik71wtfox myapp2_web1 replicated 5/5 nginx:alpine *:8083->80/tcp
You can use docker service rm myapp2_db1 myapp2_web1 to clean up services, though I was expecting it being done directly via docker stack rm myapp1.
[Captains-Bay]🚩 > kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.6", GitCommit:"6260bb08c46c31eea6cb538b34a9ceb3e406689c", GitTreeState:"clean", BuildDate:"2017-12-21T06:34:11Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.0", GitCommit:"ddf47ac13c1a9483ea035a79cd7c10005ff21a6d", GitTreeState:"clean", BuildDate:"2018-12-03T20:56:12Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
[Captains-Bay]🚩 > kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-desktop Ready master 17h v1.13.0
[Captains-Bay]🚩 >
[Captains-Bay]🚩 > docker stack deploy -c docker-compose1.yml myapp1
Waiting for the stack to be stable and running...
db1: Ready [pod status: 1/2 ready, 1/2 pending, 0/2 failed]
web1: Ready [pod status: 1/3 ready, 2/3 pending, 0/3 failed]
Stack myapp1 is stable and running
[Captains-Bay]🚩 > docker stack ls
NAME SERVICES ORCHESTRATOR NAMESPACE
myapp1 2 Kubernetes default
[Captains-Bay]🚩 > kubectl get all
NAME AGE
deploy/db1 13s
deploy/web1 13s
NAME AGE
rs/db1-6cf565f7cc 13s
rs/web1-69c7f5d64b 13s
NAME READY STATUS RESTARTS AGE
po/db1-6cf565f7cc-p49bp 1/1 Running 0 13s
po/db1-6cf565f7cc-z9lnw 1/1 Running 0 13s
po/web1-69c7f5d64b-jhwgh 1/1 Running 0 13s
po/web1-69c7f5d64b-pmx79 1/1 Running 0 13s
po/web1-69c7f5d64b-x7r7b 1/1 Running 0 13s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/db1 ClusterIP None <none> 55555/TCP 13s
svc/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 17h
svc/web1 ClusterIP None <none> 55555/TCP 13s
svc/web1-published LoadBalancer 10.101.67.167 localhost 8083:32350/TCP 13s
[Captains-Bay]🚩 >