node-env.yaml
apiVersion: v1
kind: Pod
metadata:
name: envar-demo
labels:
purpose: demonstrate-envars
spec:
containers:
- name: envar-demo-container
image: gcr.io/google-samples/node-hello:1.0
env:
- name: DEMO_GREETING
value: "Hello from the environment"
- name: DEMO_FAREWELL
value: "Such a sweet sorrow"
kubectl create configmap <map-name> <data-source>
imkunyoung@cloudshell:~/config (k8s-inflearn)$ vim test
imkunyoung@cloudshell:~/config (k8s-inflearn)$ cat test
1234
imkunyoung@cloudshell:~/config (k8s-inflearn)$ kubectl create configmap map-name --from-file=test
configmap/map-name created
imkunyoung@cloudshell:~/config (k8s-inflearn)$ kubectl get configmap map-name -o yaml
apiVersion: v1
data:
test: |
1234
kind: ConfigMap
metadata:
creationTimestamp: "2023-09-04T09:58:57Z"
name: map-name
namespace: default
resourceVersion: "31764217"
uid: 812923aa-ecda-4742-9781-f5ce36275a1a
node-env-configmap.yaml
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "/bin/sh", "-c", "env" ]
env:
- name: SPECIAL_LEVEL_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: special.how
configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: special-config
namespace: default
data:
special.how: very
---
apiVersion: v1
kind: ConfigMap
metadata:
name: env-config
namespace: default
data:
log_level: INFO
imkunyoung@cloudshell:~/secret (k8s-inflearn)$ cat password username
1f2d1e2e67df
admin
imkunyoung@cloudshell:~/secret (k8s-inflearn)$ kubectl create secret generic db-user-pass --from-file=./username --from-file=./password --dry-run=client -o yaml
apiVersion: v1
data:
password: MWYyZDFlMmU2N2RmCg==
username: YWRtaW4K
kind: Secret
metadata:
creationTimestamp: null
name: db-user-pass
imkunyoung@cloudshell:~/secret (k8s-inflearn)$ kubectl create secret generic db-user-pass --from-file=./username --from-file=./password
secret/db-user-pass created
imkunyoung@cloudshell:~/secret (k8s-inflearn)$ kubectl get secret
NAME TYPE DATA AGE
db-user-pass Opaque 2 8s
gasbugs-tls kubernetes.io/tls 2 34d
apiVersion: v1
data:
password: MWYyZDFlMmU2N2RmCg==
username: YWRtaW4K
kind: Secret
metadata:
creationTimestamp: null
name: db-user-pass
imkunyoung@cloudshell:~/secret (k8s-inflearn)$ echo -n 'admin' | base64
YWRtaW4=
imkunyoung@cloudshell:~/secret (k8s-inflearn)$ echo -n '1f2d1e2e67df' | base64
MWYyZDFlMmU2N2Rm
apiVersion: v1
kind: Secret
metadata:
name: db-user-pass
data:
password: MWYyZDFlMmU2N2RmCg==
username: YWRtaW4K