Skip to content
Snippets Groups Projects
Commit ff94583b authored by Xueshan Feng's avatar Xueshan Feng
Browse files

Added deploying docker-compose to kubernetes example.

parent 39976ab1
No related branches found
No related tags found
No related merge requests found
......@@ -230,8 +230,80 @@ Now you can connect to the guestbook application on http://127.0.0.1:8000 and si
You can terminate the proxy by Control-C to in the proxy window.
## Deploy to Kubernetes from a docker-compose file
We are going to demo how to deploy docker-compose file to Kubernetes cluster.
* First clone this repo:
```console
$ git clone https://code.stanford.edu/sfeng/docker-for-mac-kubernetes
```
* Deploy a word web application
```console
$ DOCKER_ORCHESTRATOR=kubernetes docker stack deploy docker-web --compose-file docker-compose.yml
Ignoring unsupported options: build
Stack docker-web was created
Waiting for the stack to be stable and running...
- Service words has one container running
- Service db has one container running
- Service web has one container running
Stack docker-web is stable and running
```
* Verify pods and service are running
```console
$ docker stack services docker-web
ID NAME MODE REPLICAS IMAGE PORTS
f37955ad-3e8 docker-web_db replicated 1/1 dockerdemos/lab-db
f37c0e41-3e8 docker-web_web replicated 1/1 dockerdemos/lab-web *:80->80/tcp
f38e0067-3e8 docker-web_words replicated 5/5 dockerdemos/lab-words
```
Or if you want to use kubectl:
```console
$ kubectl get pods,svc
NAME READY STATUS RESTARTS AGE
po/db-cc6d959d-t2j8l 1/1 Running 0 1m
po/web-bf8c55f48-56d2v 1/1 Running 0 1m
po/words-657d8f455b-bv6vk 1/1 Running 0 1m
po/words-657d8f455b-f9bjf 1/1 Running 0 1m
po/words-657d8f455b-lkdll 1/1 Running 0 1m
po/words-657d8f455b-ltq26 1/1 Running 0 1m
po/words-657d8f455b-t85ls 1/1 Running 0 1m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/db ClusterIP None <none> 55555/TCP 1m
svc/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 3h
svc/web ClusterIP None <none> 55555/TCP 1m
svc/web-published LoadBalancer 10.110.27.41 localhost 80:31119/TCP 1m
svc/words ClusterIP None <none> 55555/TCP 1m
`svc/web-published` is the frontend that exposed to external host. Just point your browser to
http://localhost:80. You get `hello-world!`
* To update the content, edi the web/static/index.html, then
```console
$ DOCKER_ORCHESTRATOR=kubernetes docker stack up docker-web --compose-file docker-compose.yml
```
* List stacks
## Teardown
* Delete the docker-web applicaiton if you deployed it
```console
$ DOCKER_ORCHESTRATOR=kubernetes docker stack rm docker-web
Removing stack: docker-web
```
* Delete dashboard application
```console
......
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
<html>
<header><title>Kubernetes with Docker-for-Mac</title></header>
<body>
Hello World!
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment