commit 594aa43c74c14d60cc0f0941a2e7c6ff0e300e91 Author: homejacob Date: Mon Sep 29 20:09:03 2025 +0200 initial commit diff --git a/helm-webapp/.helmignore b/helm-webapp/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-webapp/.helmignore @@ -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/ diff --git a/helm-webapp/Chart.yaml b/helm-webapp/Chart.yaml new file mode 100644 index 0000000..ef5e1f7 --- /dev/null +++ b/helm-webapp/Chart.yaml @@ -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" diff --git a/helm-webapp/templates/NOTES.txt b/helm-webapp/templates/NOTES.txt new file mode 100644 index 0000000..8bfc730 --- /dev/null +++ b/helm-webapp/templates/NOTES.txt @@ -0,0 +1,2 @@ +servicename=$(k get service -l "app={{ .Values.appName }}" -o jsonpath="{.items[0].metadata.name}") +kubectl --namespace port-forward service/{{ .Values.appName }} 8888:80 \ No newline at end of file diff --git a/helm-webapp/templates/configmap.yaml b/helm-webapp/templates/configmap.yaml new file mode 100644 index 0000000..aadeb34 --- /dev/null +++ b/helm-webapp/templates/configmap.yaml @@ -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 }} \ No newline at end of file diff --git a/helm-webapp/templates/deployment.yaml b/helm-webapp/templates/deployment.yaml new file mode 100644 index 0000000..1ba1743 --- /dev/null +++ b/helm-webapp/templates/deployment.yaml @@ -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" \ No newline at end of file diff --git a/helm-webapp/templates/service.yaml b/helm-webapp/templates/service.yaml new file mode 100644 index 0000000..0ffe034 --- /dev/null +++ b/helm-webapp/templates/service.yaml @@ -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 diff --git a/helm-webapp/values-dev.yaml b/helm-webapp/values-dev.yaml new file mode 100644 index 0000000..a53c0b2 --- /dev/null +++ b/helm-webapp/values-dev.yaml @@ -0,0 +1,6 @@ + +replicas: 5 + +configmap: + data: + CUSTOM_HEADER: 'This is on the DEV environment!' diff --git a/helm-webapp/values-prod.yaml b/helm-webapp/values-prod.yaml new file mode 100644 index 0000000..fa91ac7 --- /dev/null +++ b/helm-webapp/values-prod.yaml @@ -0,0 +1,6 @@ + +replicas: 4 + +configmap: + data: + CUSTOM_HEADER: 'This is on the PROD environment!' diff --git a/helm-webapp/values.yaml b/helm-webapp/values.yaml new file mode 100644 index 0000000..2f332a2 --- /dev/null +++ b/helm-webapp/values.yaml @@ -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 \ No newline at end of file diff --git a/kustom-webapp/README.md b/kustom-webapp/README.md new file mode 100644 index 0000000..47fa2b3 --- /dev/null +++ b/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/ diff --git a/kustom-webapp/base/deployment.yaml b/kustom-webapp/base/deployment.yaml new file mode 100644 index 0000000..dc11465 --- /dev/null +++ b/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" \ No newline at end of file diff --git a/kustom-webapp/base/kustomization.yaml b/kustom-webapp/base/kustomization.yaml new file mode 100644 index 0000000..7c0ea2d --- /dev/null +++ b/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 \ No newline at end of file diff --git a/kustom-webapp/base/service.yaml b/kustom-webapp/base/service.yaml new file mode 100644 index 0000000..b69d9ef --- /dev/null +++ b/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 \ No newline at end of file diff --git a/kustom-webapp/overlays/dev/config.properties b/kustom-webapp/overlays/dev/config.properties new file mode 100644 index 0000000..433cf01 --- /dev/null +++ b/kustom-webapp/overlays/dev/config.properties @@ -0,0 +1,3 @@ +BG_COLOR=#000000 +FONT_COLOR=#FFFFFF +CUSTOM_HEADER=Welcome to the DEV environment!! diff --git a/kustom-webapp/overlays/dev/kustomization.yaml b/kustom-webapp/overlays/dev/kustomization.yaml new file mode 100644 index 0000000..21c1717 --- /dev/null +++ b/kustom-webapp/overlays/dev/kustomization.yaml @@ -0,0 +1,9 @@ +bases: +- ../../base + +patches: + - replicas.yaml + +configMapGenerator: +- name: mykustom-map + env: config.properties \ No newline at end of file diff --git a/kustom-webapp/overlays/dev/replicas.yaml b/kustom-webapp/overlays/dev/replicas.yaml new file mode 100644 index 0000000..453b1cb --- /dev/null +++ b/kustom-webapp/overlays/dev/replicas.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mywebapp +spec: + replicas: 3 \ No newline at end of file diff --git a/kustom-webapp/overlays/prod/config.properties b/kustom-webapp/overlays/prod/config.properties new file mode 100644 index 0000000..b1819db --- /dev/null +++ b/kustom-webapp/overlays/prod/config.properties @@ -0,0 +1,3 @@ +BG_COLOR=#12181b +FONT_COLOR=#FFFFFF +CUSTOM_HEADER=Welcome to the Prod environment!! diff --git a/kustom-webapp/overlays/prod/kustomization.yaml b/kustom-webapp/overlays/prod/kustomization.yaml new file mode 100644 index 0000000..21c1717 --- /dev/null +++ b/kustom-webapp/overlays/prod/kustomization.yaml @@ -0,0 +1,9 @@ +bases: +- ../../base + +patches: + - replicas.yaml + +configMapGenerator: +- name: mykustom-map + env: config.properties \ No newline at end of file diff --git a/kustom-webapp/overlays/prod/replicas.yaml b/kustom-webapp/overlays/prod/replicas.yaml new file mode 100644 index 0000000..81d52ea --- /dev/null +++ b/kustom-webapp/overlays/prod/replicas.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mywebapp +spec: + replicas: 4 \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..b40ed77 --- /dev/null +++ b/readme.md @@ -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 #Get the application’s log output. +argocd app get #Get information about an Argo CD application. +argocd app diff #Compare the application’s configuration to its source repository. +argocd app sync #Synchronize the application with its source repository. +argocd app history #Get information about an Argo CD application. +argocd app rollback #Rollback to a previous version +argocd app set #Set the application’s configuration. +argocd app delete #Delete an Argo CD application. +``` + + + + +