initial commit
This commit is contained in:
23
helm-webapp/.helmignore
Normal file
23
helm-webapp/.helmignore
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*.orig
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
.vscode/
|
||||||
24
helm-webapp/Chart.yaml
Normal file
24
helm-webapp/Chart.yaml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: webapp
|
||||||
|
description: A Helm chart for Kubernetes
|
||||||
|
|
||||||
|
# A chart can be either an 'application' or a 'library' chart.
|
||||||
|
#
|
||||||
|
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||||
|
# to be deployed.
|
||||||
|
#
|
||||||
|
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||||
|
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||||
|
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||||
|
type: application
|
||||||
|
|
||||||
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
|
# to the chart and its templates, including the app version.
|
||||||
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
# This is the version number of the application being deployed. This version number should be
|
||||||
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
|
# It is recommended to use it with quotes.
|
||||||
|
appVersion: "1.16.0"
|
||||||
2
helm-webapp/templates/NOTES.txt
Normal file
2
helm-webapp/templates/NOTES.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
servicename=$(k get service -l "app={{ .Values.appName }}" -o jsonpath="{.items[0].metadata.name}")
|
||||||
|
kubectl --namespace <namespace> port-forward service/{{ .Values.appName }} 8888:80
|
||||||
8
helm-webapp/templates/configmap.yaml
Normal file
8
helm-webapp/templates/configmap.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
kind: ConfigMap
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.configmap.name }}
|
||||||
|
data:
|
||||||
|
BG_COLOR: '#12181b'
|
||||||
|
FONT_COLOR: '#FFFFFF'
|
||||||
|
CUSTOM_HEADER: {{ .Values.configmap.data.CUSTOM_HEADER }}
|
||||||
33
helm-webapp/templates/deployment.yaml
Normal file
33
helm-webapp/templates/deployment.yaml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.appName }}
|
||||||
|
labels:
|
||||||
|
app: {{ .Values.appName }}
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.replicas }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ .Values.appName }}
|
||||||
|
tier: frontend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Values.appName }}
|
||||||
|
tier: frontend
|
||||||
|
spec: # Pod spec
|
||||||
|
containers:
|
||||||
|
- name: mycontainer
|
||||||
|
image: "{{ .Values.image.name }}:{{ .Values.image.tag }}"
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: {{ .Values.configmap.name }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "16Mi"
|
||||||
|
cpu: "50m" # 500milliCPUs (1/2 CPU)
|
||||||
|
limits:
|
||||||
|
memory: "128Mi"
|
||||||
|
cpu: "100m"
|
||||||
15
helm-webapp/templates/service.yaml
Normal file
15
helm-webapp/templates/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.appName }}
|
||||||
|
labels:
|
||||||
|
app: {{ .Values.appName }}
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
protocol: TCP
|
||||||
|
name: flask
|
||||||
|
selector:
|
||||||
|
app: {{ .Values.appName }}
|
||||||
|
tier: frontend
|
||||||
|
type: NodePort
|
||||||
6
helm-webapp/values-dev.yaml
Normal file
6
helm-webapp/values-dev.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
replicas: 5
|
||||||
|
|
||||||
|
configmap:
|
||||||
|
data:
|
||||||
|
CUSTOM_HEADER: 'This is on the DEV environment!'
|
||||||
6
helm-webapp/values-prod.yaml
Normal file
6
helm-webapp/values-prod.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
replicas: 4
|
||||||
|
|
||||||
|
configmap:
|
||||||
|
data:
|
||||||
|
CUSTOM_HEADER: 'This is on the PROD environment!'
|
||||||
12
helm-webapp/values.yaml
Normal file
12
helm-webapp/values.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
appName: myhelmapp
|
||||||
|
|
||||||
|
port: 80
|
||||||
|
|
||||||
|
configmap:
|
||||||
|
name: myhelmapp-configmap-v1
|
||||||
|
data:
|
||||||
|
CUSTOM_HEADER: 'This app was deployed with helm!'
|
||||||
|
|
||||||
|
image:
|
||||||
|
name: devopsjourney1/mywebapp
|
||||||
|
tag: latest
|
||||||
40
kustom-webapp/README.md
Normal file
40
kustom-webapp/README.md
Normal file
@@ -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
kustom-webapp/base/deployment.yaml
Normal file
23
kustom-webapp/base/deployment.yaml
Normal file
@@ -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
kustom-webapp/base/kustomization.yaml
Normal file
15
kustom-webapp/base/kustomization.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- service.yaml
|
||||||
|
|
||||||
|
commonLabels:
|
||||||
|
app: kustomwebapp
|
||||||
|
|
||||||
|
commonAnnotations:
|
||||||
|
app: mykustom-annontations
|
||||||
|
|
||||||
|
namePrefix:
|
||||||
|
kustom-
|
||||||
|
|
||||||
|
nameSuffix:
|
||||||
|
-v1
|
||||||
10
kustom-webapp/base/service.yaml
Normal file
10
kustom-webapp/base/service.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: mywebapp
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
protocol: TCP
|
||||||
|
name: flask
|
||||||
|
type: NodePort
|
||||||
3
kustom-webapp/overlays/dev/config.properties
Normal file
3
kustom-webapp/overlays/dev/config.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
BG_COLOR=#000000
|
||||||
|
FONT_COLOR=#FFFFFF
|
||||||
|
CUSTOM_HEADER=Welcome to the DEV environment!!
|
||||||
9
kustom-webapp/overlays/dev/kustomization.yaml
Normal file
9
kustom-webapp/overlays/dev/kustomization.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
bases:
|
||||||
|
- ../../base
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- replicas.yaml
|
||||||
|
|
||||||
|
configMapGenerator:
|
||||||
|
- name: mykustom-map
|
||||||
|
env: config.properties
|
||||||
6
kustom-webapp/overlays/dev/replicas.yaml
Normal file
6
kustom-webapp/overlays/dev/replicas.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: mywebapp
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
3
kustom-webapp/overlays/prod/config.properties
Normal file
3
kustom-webapp/overlays/prod/config.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
BG_COLOR=#12181b
|
||||||
|
FONT_COLOR=#FFFFFF
|
||||||
|
CUSTOM_HEADER=Welcome to the Prod environment!!
|
||||||
9
kustom-webapp/overlays/prod/kustomization.yaml
Normal file
9
kustom-webapp/overlays/prod/kustomization.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
bases:
|
||||||
|
- ../../base
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- replicas.yaml
|
||||||
|
|
||||||
|
configMapGenerator:
|
||||||
|
- name: mykustom-map
|
||||||
|
env: config.properties
|
||||||
6
kustom-webapp/overlays/prod/replicas.yaml
Normal file
6
kustom-webapp/overlays/prod/replicas.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: mywebapp
|
||||||
|
spec:
|
||||||
|
replicas: 4
|
||||||
56
readme.md
Normal file
56
readme.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# Follow this video to be a ArgoCD Boss
|
||||||
|
https://youtu.be/JLrR9RV9AFA
|
||||||
|
|
||||||
|
|
||||||
|
# Installing latest/stable version of ArgoCD
|
||||||
|
```
|
||||||
|
kubectl create namespace argocd
|
||||||
|
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Forward Ports
|
||||||
|
```
|
||||||
|
k get services -n argocd
|
||||||
|
kubectl port-forward service/argocd-server -n argocd 8080:443
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get Credentials
|
||||||
|
```
|
||||||
|
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
|
||||||
|
```
|
||||||
|
|
||||||
|
# Install ArgoCD CLI / Login via CLI
|
||||||
|
```
|
||||||
|
brew install argocd
|
||||||
|
kubectl port-forward svc/argocd-server -n argocd 8080:443
|
||||||
|
argocd login 127.0.0.1:8080
|
||||||
|
```
|
||||||
|
|
||||||
|
# Creating an Application using ArgoCD CLI:
|
||||||
|
```
|
||||||
|
argocd app create webapp-kustom-prod \
|
||||||
|
--repo https://github.com/devopsjourney1/argo-examples.git \
|
||||||
|
--path kustom-webapp/overlays/prod --dest-server https://kubernetes.default.svc \
|
||||||
|
--dest-namespace prod
|
||||||
|
```
|
||||||
|
|
||||||
|
# Command Cheat sheet
|
||||||
|
```
|
||||||
|
argocd app create #Create a new Argo CD application.
|
||||||
|
argocd app list #List all applications in Argo CD.
|
||||||
|
argocd app logs <appname> #Get the application’s log output.
|
||||||
|
argocd app get <appname> #Get information about an Argo CD application.
|
||||||
|
argocd app diff <appname> #Compare the application’s configuration to its source repository.
|
||||||
|
argocd app sync <appname> #Synchronize the application with its source repository.
|
||||||
|
argocd app history <appname> #Get information about an Argo CD application.
|
||||||
|
argocd app rollback <appname> #Rollback to a previous version
|
||||||
|
argocd app set <appname> #Set the application’s configuration.
|
||||||
|
argocd app delete <appname> #Delete an Argo CD application.
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user