10 Secrets666
10 Secrets666
---
Example:
```yaml
apiVersion: v1
kind: Pod
metadata:
name: env-example
spec:
containers:
- name: my-container
image: busybox
env:
- name: APP_MODE
value: "production"
```
```yaml
envFrom:
- configMapRef:
name: my-configmap
```
### **Using Environment Variables from a Secret**
```yaml
envFrom:
- secretRef:
name: my-secret
```
---
Here are concise notes on **Environment Variables, ConfigMaps, and Secrets** in Kubernetes.
---
Example:
```yaml
apiVersion: v1
kind: Pod
metadata:
name: env-example
spec:
containers:
- name: my-container
image: busybox
env:
- name: APP_MODE
value: "production"
```
```yaml
envFrom:
- configMapRef:
name: my-configmap
```
```yaml
envFrom:
- secretRef:
name: my-secret
```
---
```yaml
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: my-configmap
data:
APP_MODE: "production"
LOG_LEVEL: "debug"
```
```sh
```
```yaml
env:
- name: APP_MODE
valueFrom:
configMapKeyRef:
name: my-configmap
key: APP_MODE
```
```yaml
volumes:
- name: config-volume
configMap:
name: my-configmap
volumeMounts:
- mountPath: "/etc/config"
name: config-volume
```
---
A **Secret** is used to store sensitive data like passwords, tokens, and certificates.
```yaml
apiVersion: v1
kind: Secret
metadata:
name: my-secret
type: Opaque
data:
```
```sh
```
```yaml
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: my-secret
key: DB_PASSWORD
```
```yaml
volumes:
- name: secret-volume
secret:
secretName: my-secret
volumeMounts:
- mountPath: "/etc/secret"
name: secret-volume
```
---
|-----------------|-------------------------|--------|
These notes provide a **quick reference** for using **environment variables, ConfigMaps, and
Secrets** in Kubernetes. Let me know if you need **more details or examples**! 🚀