目标是使用Kubernetes协调生产和本地开发环境.问题是hostPath不适用于相对路径值.这导致每个开发人员的计算机上的配置文件略有不同,以适应不同的项目位置(即"/my/absolute/path/to/the/project"):
apiVersion: v1
kind: Service
metadata:
name: some-service
labels:
app: app
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: app
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: some-deploy
spec:
selector:
matchLabels:
app: app
replicas: 1
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: nginx:1.13.12-alpine
ports:
- containerPort: 80
volumeMounts:
- name: vol_example
mountPath: /var/www/html
volumes:
- name: vol_example
hostPath:
path: "/my/absolute/path/to/the/project"
type: Directory
Run Code Online (Sandbox Code Playgroud)
如何在Kubernetes配置文件中使用相对路径?$(PWD)/project已经尝试过可变替换(例如),但似乎没有用.如果配置变量可以使用卷,这可能有所帮助,但不确定如何实现这一点.
| 归档时间: |
|
| 查看次数: |
2274 次 |
| 最近记录: |