Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions kustom-webapp/README.md
Original file line number Diff line number Diff line change
@@ -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 changes: 23 additions & 0 deletions kustom-webapp/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebapp
spec:
replicas: 1
template:
spec: # Pod spec
containers:
- name: mycontainer
image: "enzoyh/teste-repo: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 changes: 15 additions & 0 deletions kustom-webapp/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resources:
- deployment.yaml
- service.yaml

commonLabels:
app: kustomwebapp

commonAnnotations:
app: mykustom-annontations

namePrefix:
kustom-

nameSuffix:
-v1
10 changes: 10 additions & 0 deletions kustom-webapp/base/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: mywebapp
spec:
ports:
- port: 80
protocol: TCP
name: node
type: NodePort
3 changes: 3 additions & 0 deletions kustom-webapp/overlays/dev/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BG_COLOR=#000000
FONT_COLOR=#FFFFFF
CUSTOM_HEADER=Welcome to the DEV environment!!
9 changes: 9 additions & 0 deletions kustom-webapp/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bases:
- ../../base

patches:
- replicas.yaml

configMapGenerator:
- name: mykustom-map
env: config.properties
6 changes: 6 additions & 0 deletions kustom-webapp/overlays/dev/replicas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebapp
spec:
replicas: 3
3 changes: 3 additions & 0 deletions kustom-webapp/overlays/prod/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BG_COLOR=#12181b
FONT_COLOR=#FFFFFF
CUSTOM_HEADER=Welcome to the Prod environment!!
9 changes: 9 additions & 0 deletions kustom-webapp/overlays/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bases:
- ../../base

patches:
- replicas.yaml

configMapGenerator:
- name: mykustom-map
env: config.properties
6 changes: 6 additions & 0 deletions kustom-webapp/overlays/prod/replicas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebapp
spec:
replicas: 4