Unabel to add secret in pod

Hi Team , What is the issue here
controlplane ~ ➜ k replace --force -f /tmp/kubectl-edit-2128903843.yaml
pod “webapp-pod” deleted
Error from server (BadRequest): Pod in version “v1” cannot be handled as a Pod: strict decoding error: unknown field “spec.envFrom”

unaable to add below secret
envFrom:

  • secretRef:
    name: db-secret

Hi @Sameer-Sameer-Ghatol,

This field doesn’t exist. You have added it in wrong place.
Please check this manifest file for a reference:

apiVersion: v1
kind: Pod
metadata:
  name: dapi-test-pod
spec:
  containers:
    - name: test-container
      image: registry.k8s.io/busybox
      command: [ "/bin/sh", "-c", "env" ]
      envFrom:
      - configMapRef:
          name: special-config
  restartPolicy: Never

This should come under the spec.containers.envFrom.

I had the same problem, the solution video for this task is pointing to documentation which is not there anymore, looks outdated. There is no envfrom example in the documentation.

No, there’s actually a very good doc for using secrets in pods. The envFrom example gets a whole section:

apiVersion: v1
kind: Pod
metadata:
  name: envfrom-secret
spec:
  containers:
  - name: envars-test-container
    image: nginx
    envFrom:
    - secretRef:
        name: test-secret