Here my command line:
kubectl apply -f postgres.secret.yaml \
-f postgres.configmap.yaml \
-f postgres.volume.yaml \
-f postgres.deployment.yaml \
-f postgres.service.yaml
and i got and error as this picture :
Here my yaml file deployment:
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
And i got an error : Unknown field "name" in io.k8s.api.core.v1.EnvFromSource I have checked this error everyobdy says that is from space from envFrom however it is rightly indent as the solution they propose.
The indentation is wrong.
It should be:
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
i.e. name
should be indented under the secretRef
or configMapRef
fields
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With