Brad 2 anos atrás
pai
commit
d09c32c1de

+ 40 - 0
kustom-webapp/README.md

@@ -0,0 +1,40 @@
+# Installation
+```
+kubectl version
+```
+*If you have 1.21 or above of kubectl you will have access to kubectl kustomize which is the recommended method. If you aren't on version 1.21 or above, upgrade kubectl.
+*You could also download/use the 'kutomize' binary seperatly but the cmds are different.
+
+
+# Viewing Kustomize Configs - (Using kubectl kustomize integration)
+```
+kubectl kustomize .
+kubectl kustomize overlays/dev/
+kubectl kustomize overlays/prod/
+```
+
+# Applying Kustomize Configs - (Using kubectl kustomize integration)
+```
+kubectl apply -k .
+kubectl apply -k overlays/dev/
+kubectl apply -k overlays/prod/
+```
+Note: if you get field is immutable error, check your configuration and try deleting the resources.
+
+
+# Creating Namespaces if you dont have them already
+```
+kubectl create namespace dev; kubectl create namespace prod;
+```
+
+
+# Accessing the application
+```
+minikube service kustom-mywebapp-v1
+minikube service kustom-mywebapp-v1 -n dev
+minikube service kustom-mywebapp-v1 -n prod
+```
+
+# References:
+https://github.com/kubernetes-sigs/kustomize/blob/master/README.md
+https://kubectl.docs.kubernetes.io/guides/config_management/offtheshelf/

+ 23 - 0
kustom-webapp/base/deployment.yaml

@@ -0,0 +1,23 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: mywebapp
+spec:
+  replicas: 1
+  template:
+    spec: # Pod spec
+      containers:
+      - name: mycontainer
+        image: "devopsjourney1/mywebapp:latest"
+        ports:
+        - containerPort: 80
+        envFrom:
+        - configMapRef:
+            name: mykustom-map
+        resources:
+          requests:
+            memory: "16Mi" 
+            cpu: "50m"    # 500milliCPUs (1/2 CPU)
+          limits:
+            memory: "128Mi"
+            cpu: "100m"

+ 15 - 0
kustom-webapp/base/kustomization.yaml

@@ -0,0 +1,15 @@
+resources:
+- deployment.yaml
+- service.yaml
+
+commonLabels:
+  app: kustomwebapp
+
+commonAnnotations:
+  app: mykustom-annontations
+
+namePrefix:
+  kustom-
+
+nameSuffix:
+  -v1

+ 10 - 0
kustom-webapp/base/service.yaml

@@ -0,0 +1,10 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: mywebapp
+spec:
+  ports:
+  - port: 80
+    protocol: TCP
+    name: flask
+  type: NodePort

+ 3 - 0
kustom-webapp/overlays/dev/config.properties

@@ -0,0 +1,3 @@
+BG_COLOR=#12181b
+FONT_COLOR=#FFFFFF
+CUSTOM_HEADER=Welcome to the DEV environment

+ 9 - 0
kustom-webapp/overlays/dev/kustomization.yaml

@@ -0,0 +1,9 @@
+bases:
+- ../../base
+
+patches:
+ - replicas.yaml
+
+configMapGenerator:
+- name: mykustom-map
+  env: config.properties

+ 6 - 0
kustom-webapp/overlays/dev/replicas.yaml

@@ -0,0 +1,6 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: mywebapp
+spec:
+  replicas: 2

+ 3 - 0
kustom-webapp/overlays/prod/config.properties

@@ -0,0 +1,3 @@
+BG_COLOR=#12181b
+FONT_COLOR=#FFFFFF
+CUSTOM_HEADER=Welcome to the PROD environment

+ 9 - 0
kustom-webapp/overlays/prod/kustomization.yaml

@@ -0,0 +1,9 @@
+bases:
+- ../../base
+
+patches:
+ - replicas.yaml
+
+configMapGenerator:
+- name: mykustom-map
+  env: config.properties

+ 6 - 0
kustom-webapp/overlays/prod/replicas.yaml

@@ -0,0 +1,6 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: mywebapp
+spec:
+  replicas: 5