apiVersion: apps/v1
kind: deployment
metadata:
name: mongodb-deployment
labels:
app: mongodb
spec:
replicas: 1
selector:
matchLebels:
app: mongodb
template:
metadata:
lebels:
app: mongodb
spec:
containers:
- name: mongodb
image: mongo
ports:
- containerPort: 27017
env:
- name: MONGO_INITDB_ROOT_USERNAE
valueFrom:
secretKeyref:
name: mongodb-secret
key: mongo-root-username
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyref:
name: mongodb-secret
key: mongo-root-password
kind Deployment is case sensitive, use capital D
kind: Deployment
If above suggestion did not work..then check your kubernetes version. Probably you are using old version which does not support apps/v1 api.
You can please check the deployment
version Kubernetes supporting.
Try this command :
kubectl api-resources
according to that change the version in YAML file instead of apps/v1
maybe it will be apps/v1beta2
apiVersion: apps/v1
kind: deployment
command
kubectl api-resources
will print the all supported API version by the cluster you are running.
apiVersion: apps/v1
kind: Deployment #corrected typo deployment to Deployment
metadata:
name: mongodb-deployment
labels:
app: mongodb
spec:
replicas: 1
selector:
matchLabels: #corrected typo matchLebels to matchLabels
app: mongodb
template:
metadata:
labels: #corrected typo lebels to labels
app: mongodb
spec:
containers:
- name: mongodb
image: mongo
ports:
- containerPort: 27017
env:
- name: MONGO_INITDB_ROOT_USERNAE
valueFrom:
secretKeyRef: #corrected typo secretKeyref to secretKeyRef
name: mongodb-secret
key: mongo-root-username
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef: #corrected typo secretKeyref to secretKeyRef
name: mongodb-secret
key: mongo-root-password