From b4c980acdd24b0e96c4b7b0be839c3e6f8a9674d Mon Sep 17 00:00:00 2001 From: kevencript Date: Fri, 17 Mar 2023 23:00:01 -0300 Subject: [PATCH] feat: :sparkles: Config: Configmaps ConfigMaps in Kubernetes are a flexible way to store and manage non-sensitive configuration data for your applications, enabling you to decouple configuration settings from container images and simplifying updates and maintenance. --- Makefile | 2 ++ k8s/configmap-env.yaml | 7 +++++++ k8s/deployment.yaml | 10 ++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 k8s/configmap-env.yaml diff --git a/Makefile b/Makefile index 220648b..ad8fab8 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ delete: redeploy: $(MAKE) delete $(MAKE) deploy + sleep 3 + $(MAKE) port-forward port-forward: kubectl port-forward svc/go-http-app-service 8000:80 \ No newline at end of file diff --git a/k8s/configmap-env.yaml b/k8s/configmap-env.yaml new file mode 100644 index 0000000..78d77a4 --- /dev/null +++ b/k8s/configmap-env.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: go-http-app-env +data: + NAME: "Gabriel Costa" + AGE: "36" diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index a876206..36f05d2 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -20,6 +20,12 @@ spec: image: wesleywillians/hello-go:v4 # This image have the fields "NAME" & "AGE" env: - name: NAME - value: "Gabriel Costa" + valueFrom: + configMapKeyRef: + key: NAME + name: go-http-app-env - name: AGE - value: "23" + valueFrom: + configMapKeyRef: + key: AGE + name: go-http-app-env