备注: 使用的是golang 版本的实现,同时官方也提供了一个k8s 的helm 部署charts,我
没有使用这个helm,而是通过kompose 这个工具直接转换的
docker-compose 文件
文件名为:docker-compose-no-volumes.yaml
version: "3"
services:
demo:
image: artefactual/gearmand:latest
command: --queue-type=redis --redis-server=redis --redis-port=6379 --verbose=DEBUG
ports:
- "4731:4730"
redis:
image: redis
ports:
- "6379:6379"
app:
image: appscode/gearmand:0.5.2
command: run --v=3 --addr="0.0.0.0:4730"
ports:
- "4730:4730"
- "3000:3000"
client:
image: dalongrong/client-demo
build:
context: ./client
worker:
image: dalongrong/worker-demo
build:
context: ./worker
转换k8s deploy 文件
- 安装kompose
参考下面的地址即可
https://github.com/kubernetes/kompose/releases
- 转换k8s 部署文件
kompose convert -f docker-compose-no-volumes.yaml -o k8s
- 效果
├── app-deployment.yaml
├── app-service.yaml
├── client-deployment.yaml
├── demo-deployment.yaml
├── demo-service.yaml
├── redis-deployment.yaml
├── redis-service.yaml
└── worker-deployment.yaml
- 参考生成的文件
还是很方便的,减少了好多的工作量
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
namespace: gearman
annotations:
kompose.cmd: kompose convert -f docker-compose-no-volumes.yaml -o ./k8s
kompose.version: 1.17.0 ()
creationTimestamp: null
labels:
io.kompose.service: app
name: app
spec:
replicas: 1
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: app
spec:
containers:
- args:
- run
- --v=3
- --addr=0.0.0.0:4730
image: appscode/gearmand:0.5.2
name: app
ports:
- containerPort: 4730
- containerPort: 3000
resources: {}
restartPolicy: Always
status: {}
- 部署&&运行
kubectl apply -f k8s
参考资料
https://github.com/kubernetes/kompose/releases
https://github.com/appscode/g2/tree/master/chart
https://github.com/rongfengliang/gearmangolang-docker