Search code examples
kuberneteskubectlkubernetes-secrets

Kubectl apply -f mongo-secret.yaml is not creating the secret inside my config file


When I run the below command,

Kubectl apply -f mongo-secret.yaml 

I'm thrown the following error,

enter image description here

Below is the Secret configuration I used,

apiVersion: v1
kind: secret
metadata:
  name: mongodb-secret
type: opaque
data:
  mongo-root-username: dXNlcm5hbWU=
  mongo-root-password: cGFzc3dvcmQ=

Solution

  • Use Secret instead of secret in the kind field.

    apiVersion: v1
    kind: Secret
    metadata:
      name: mongodb-secret
    type: opaque
    data:
      mongo-root-username: dXNlcm5hbWU=
      mongo-root-password: cGFzc3dvcmQ=