Commands used for Configmap
To create a ConfigMap from a literal value, use the following command:
kubectl create configmap configmap-1 --from-literal=name=first-configmap
To create a ConfigMap from multiple literal values, use the following command:
kubectl create configmap configmap-2 --from-literal=name=second-configmap --from-literal=color=blue
To create a ConfigMap from a file, use the following command:
kubectl create configmap configmap-3 --from-file=data-file
To apply the YAML files provided in this repository, use the following command:
kubectl apply -f <file-name.yaml>
To see the pods running in your Kubernetes cluster, use the following command:
kubectl get pods
To see the ConfigMaps created in your Kubernetes cluster, use the following command:
kubectl get cm
To see the environment variables set in a running pod, use the following command:
kubectl exec -it <pod-name> -- printenv
To go inside a running pod, use the following command:
kubectl exec -it <pod-name> -- bash
kubectl exec -it configmap-demo-1 -- printenv
kubectl get cm
kubectl describe cm configmap-1
sudo nano data-file
cd /etc/config
echo &FIRSTNAME
kubectl create configmap configmap-3 --from-file=data-file --dry-run=client -o yaml > new-conf.yaml
kubectl edit secret db-secret
echo -n 'admin' | base64
echo ZGJ1c2Vy | base64 --decode
k port-forward -n kubesystem svc/sealed-secrets-ui 8080:8080 --address 0.0.0.0
apiVersion: v1
data:
firstname: kamal
lastname: jamal
kind: ConfigMap
metadata:
name: app-cm
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app.kubernetes.io/name: MyApp
spec:
containers:
- name: myapp-container
image: busybox:1.28
env:
- name: FIRSTNAME
valueFrom:
configMapKeyRef:
name: app-cm
key: firstname
command: ['sh', '-c', 'echo The app is running! && sleep 3600']