kubernetes – Error trying to create a pod in namespace with kubectl
I’m new to Kubernetes and I’m trying to create a pod inside a namespace.
I have the following namesapce.yaml:
apiVersion: v1
kind: Namespace
metadata:
name: swirlai
The following configMap.yaml is:
apiVersion: v1
kind: ConfigMap
metadata:
name: config
namespace: swirlai
data:
enviroment: dev # Key - Value
db-host: localhost # Key - Value
airflow.cfg:
dags_folder = ../CodeExample/airflow/dags
base_log_folder = ../CodeExample/airflow/logs
The secret.yaml is:
apiVersion: v1
kind: Secret
metadata:
name: secret
namespace: swirlai
data:
secret-data: c3VwZXItc2VjcmV0
And the pod.yaml is:
apiVersion: v1
kind: Pod
metadata:
name: swirlai-pod
namespace: swirlai
spec:
containers:
- name: swirlai-container
image: nginx:latest
ports:
- containerPort: 80
env:
- name: DIRECT
value: Some String
- name: ENVIRONMENT
valueFrom:
configMapKeyRef:
name: config
key: environment
- name: SECRET_DATA
valueFrom:
secretKeyRef:
name: secret
key: secret-data
After running the “kubectl apply -f pod.yaml” command I can see that I have an error with the command “describe pod -n swirlai”
The error is:
Error: couldn’t find key environment in ConfigMap swirlai/config
Read more here: Source link
