原生 docker 可以正常运行,想在 kubernets 上跑的话 yml 需要怎么写?有生成 yml 的工具吗
docker run -d --name tracker -v /data/fastdfs/tracker:/data/tracker -p 22122:22122 phinexdaz/fdfs_tracker
docker run -d --name storage -v /data/fastdfs/storage:/data/storage --link tracker:tracker -p 80:80 -e TRACKER=tracker phinexdaz/fdfs_storage
其中 tracker 手动改的 yml 如下 [跑不起来,主要显示挂载格式错误] :
[root@k8s-master ~]# cat tracker-deploy.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tracker-service
spec:
replicas: 3
template:
metadata:
labels:
app: tracker
tier: tracker-service
spec:
containers:
- name: tracker-service
image: phinexdaz/fdfs_tracker
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: env
ports:
- containerPort: 22122
volumeMounts:
- mountPath: /data/tracker
name: tracker-volume
volumes:
- name: tracker-volume
hostPath:
path: /data/fastdfs/tracker
[root@k8s-master ~]# cat tracker-service.yaml
apiVersion: v1
kind: Service
metadata:
name: tracker-svc
labels:
app: tracker
tier: tracker-service
spec:
type: NodePort
ports:
- port: 22122
nodePort: 22122
selector:
app: tracker
tier: tracker-service
1
artandlol OP 有没有大佬帮看下
|
2
Zakun 2018-06-30 15:31:58 +08:00
```
volumes: - name: tracker-volume hostPath: path: /data/fastdfs/tracker type: Directory ``` |
3
Zakun 2018-06-30 15:34:04 +08:00
|
4
Zakun 2018-06-30 18:04:22 +08:00
另外注意 volumes filed 的 level。应该在 deployment.spec 下
|