这是我的命令行:
kubectl apply -f postgres.secret.yaml \
-f postgres.configmap.yaml \
-f postgres.volume.yaml \
-f postgres.deployment.yaml \
-f postgres.service.yaml
Run Code Online (Sandbox Code Playgroud)
这是我的 yaml 文件部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 0
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
restartPolicy: Always
containers:
- name: postgres
image: postgres:12
ports:
- containerPort: 5432
envFrom:
- secretRef:
name: postgres-secret
- configMapRef:
name: postgres-configmap
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-pv
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pv-claim
Run Code Online (Sandbox Code Playgroud)
我得到了一个错误: io.k8s.api.core.v1.EnvFromSource 中的未知字段“名称”
Mik*_*ant 13
缩进是错误的。
它应该是:
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 0
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
restartPolicy: Always
containers:
- name: postgres
image: postgres:12
ports:
- containerPort: 5432
envFrom:
- secretRef:
name: postgres-secret
- configMapRef:
name: postgres-configmap
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-pv
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pv-claim
Run Code Online (Sandbox Code Playgroud)
即name
应在secretRef
或configMapRef
字段下缩进
归档时间: |
|
查看次数: |
2991 次 |
最近记录: |