Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tuhin47/6cd64c49b46747ac1771399f0cf5ed8c to your computer and use it in GitHub Desktop.
Save tuhin47/6cd64c49b46747ac1771399f0cf5ed8c to your computer and use it in GitHub Desktop.
Reading Environment Variables from a Kubernetes ConfigMap YAML

Reading Environment Variables from a Kubernetes ConfigMap YAML

Preview:
apiVersion: v1
kind: Pod
metadata:
  name: dapi-test-pod
spec:
  containers:
    - name: test-container
      image: registry.k8s.io/busybox
      command: [ "/bin/sh", "-c", "env" ]
      env:
        # Define the environment variable
        - name: SPECIAL_LEVEL_KEY
          valueFrom:
            configMapKeyRef:
              # The ConfigMap containing the value you want to assign to SPECIAL_LEVEL_KEY
              name: special-config
              # Specify the key associated with the value
              key: special.how
  restartPolicy: Never
Associated Context
Type Code Snippet ( .yaml )
Associated Tags consul Kubernetes Pod Player Initial Lives Container Spec Containerization Spec Command Line Interface minikube Metadata API Use Case Framework: Kubernetes envoyproxy SDK Integration ConfigMap kubernetes Command kubectl Environment Variables Pod Metadata ValueFrom PLAYER_INITIAL_LIVES Config Map Key Ref Key Reference
💡 Smart Description This is a Kubernetes pod that sets up the initial lives for an application, including its container and environment variables. It also includes configuration keys to be used as config map key references in JSON format.
This code snippet defines a Kubernetes Pod named "my-pod" with a container named "my-container". The container runs a command that echoes the value of the environment variable "PLAYER_INITIAL_LIVES", which is sourced from a ConfigMap named "my
🔎 Suggested Searches Pod metadata with PLAYER_INITIAL_LIVES command
Container configuration key ref in pod spec
Pod config map for initial lives and player-initial -lives
Kubernetes kubernetes version of Pods API
Kubernetes Pod environment variable from ConfigMap
Retrieve environment variable value from ConfigMap in Kubernetes Pod
Kubernetes Pod command with environment variable from ConfigMap
Access ConfigMap value in Kubernetes Pod command
Kubernetes Pod spec with environment variable from ConfigMap
Related Links https://kubernetes.io/docs/concepts/configuration/secret/
https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data
Related People No Related People
Sensitive Information No Sensitive Information Detected
Shareable Link https://tuhin47.pieces.cloud/?p=3bd64fa664
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment