diff --git a/k8s/ARGOCD.md b/k8s/ARGOCD.md new file mode 100644 index 0000000000..cb8911e32a --- /dev/null +++ b/k8s/ARGOCD.md @@ -0,0 +1,105 @@ +# ArgoCD Setup +### Installation verification +```bash +kubectl get pods --namespace argocd +``` +```text +NAME READY STATUS RESTARTS AGE +argocd-application-controller-0 1/1 Running 0 78m +argocd-applicationset-controller-559566846f-shch5 1/1 Running 0 78m +argocd-dex-server-8f5687997-8t499 1/1 Running 0 78m +argocd-notifications-controller-56c7d65875-jbhv2 1/1 Running 0 78m +argocd-redis-fcd76bcfb-x97cm 1/1 Running 0 78m +argocd-repo-server-7b8447858f-2vcj4 1/1 Running 26 (10m ago) 78m +argocd-server-7f857f54f-m56tl 1/1 Running 0 78m +``` + +### UI access method +![Argo UI](/k8s/screenshots/argo_ui.png) + +### CLI configuration +![Argo UI](/k8s/screenshots/argo_cli_config.png) + +# Application Configuration +### Application manifests +Complete listing: +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: python-app + namespace: argocd +spec: + project: default + source: + repoURL: https://github.com/Error10556/DevOps-Core-Course.git + targetRevision: lab13 + path: k8s/dinfochart + helm: + valueFiles: + - values.yaml + - values-dev.yaml + destination: + server: https://kubernetes.default.svc + namespace: default + syncPolicy: + syncOptions: + - CreateNamespace=true +``` + +# Multi-Environment +### Dev vs Prod configuration differences +The only differences are shown below: + +```diff +--- argocd/application-dev.yaml 2026-04-23 19:12:06.412196521 +0300 ++++ argocd/application-prod.yaml 2026-04-23 19:25:09.577043976 +0300 +@@ -12,13 +12,10 @@ + helm: + valueFiles: + - values.yaml +- - values-dev.yaml ++ - values-prod.yaml + destination: + server: https://kubernetes.default.svc +- namespace: dev ++ namespace: prod + syncPolicy: +- automated: +- prune: true +- selfHeal: true + syncOptions: + - CreateNamespace=true +``` + +### Sync policy differences and rationale +In production, automatic syncing may be dangerous. Syncing should be done manually when the team knows that the system +is stable (for example, if the staging environment rolled out fine). + +### Namespace separation +The development version of the app deployment will be located in the `dev` namespace, and the production will be in the +`prod` namespace to ensure no collisions. + +# Self-Healing Evidence +### Manual scale test with before/after +For example, assuming that the dev application is launched: +```bash +kubectl scale deployment devops-infoservice -n dev --replicas=2 +``` +After this, `argocd` automatically resets the replica count to 1. + +### Pod deletion test +Kubernetes restarts deleted pods on its own, I think, but still: +```bash +kubectl delete pods/python-app-dinfochart-6d448c7957-cxjxj +``` + +This command just resets the alive time counter. + +### Explanation of behaviors +ArgoCD automatically detects differences between the desired state and the real state of the deployment and can sync it +back to the desired state. + +# Screenshots + +See above. diff --git a/k8s/argocd/application-dev.yaml b/k8s/argocd/application-dev.yaml new file mode 100644 index 0000000000..98b12c1669 --- /dev/null +++ b/k8s/argocd/application-dev.yaml @@ -0,0 +1,24 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: python-app-dev + namespace: argocd +spec: + project: default + source: + repoURL: https://github.com/Error10556/DevOps-Core-Course.git + targetRevision: lab13 + path: k8s/dinfochart + helm: + valueFiles: + - values.yaml + - values-dev.yaml + destination: + server: https://kubernetes.default.svc + namespace: dev + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/k8s/argocd/application-prod.yaml b/k8s/argocd/application-prod.yaml new file mode 100644 index 0000000000..cecce4f314 --- /dev/null +++ b/k8s/argocd/application-prod.yaml @@ -0,0 +1,21 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: python-app-dev + namespace: argocd +spec: + project: default + source: + repoURL: https://github.com/Error10556/DevOps-Core-Course.git + targetRevision: lab13 + path: k8s/dinfochart + helm: + valueFiles: + - values.yaml + - values-prod.yaml + destination: + server: https://kubernetes.default.svc + namespace: prod + syncPolicy: + syncOptions: + - CreateNamespace=true diff --git a/k8s/argocd/application.yaml b/k8s/argocd/application.yaml new file mode 100644 index 0000000000..3dce36849b --- /dev/null +++ b/k8s/argocd/application.yaml @@ -0,0 +1,21 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: python-app + namespace: argocd +spec: + project: default + source: + repoURL: https://github.com/Error10556/DevOps-Core-Course.git + targetRevision: lab13 + path: k8s/dinfochart + helm: + valueFiles: + - values.yaml + - values-dev.yaml + destination: + server: https://kubernetes.default.svc + namespace: default + syncPolicy: + syncOptions: + - CreateNamespace=true diff --git a/k8s/dinfochart/templates/hooks/post-install-job.yaml b/k8s/dinfochart/templates/hooks/post-install-job.yaml deleted file mode 100644 index fa5018c191..0000000000 --- a/k8s/dinfochart/templates/hooks/post-install-job.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: '{{ include "dinfochart.fullname" . }}-post-install' - labels: - {{- include "dinfochart.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": post-install - "helm.sh/hook-weight": "5" - "helm.sh/hook-delete-policy": hook-succeeded -spec: - template: - metadata: - name: '{{ include "dinfochart.fullname" . }}-post-install' - spec: - restartPolicy: Never - containers: - - name: post-install-job - image: busybox - command: ['sh', '-c', 'echo Post-install validation && sleep 1 && echo Validation passed'] diff --git a/k8s/dinfochart/templates/hooks/pre-install-job.yaml b/k8s/dinfochart/templates/hooks/pre-install-job.yaml deleted file mode 100644 index 2afe4aef29..0000000000 --- a/k8s/dinfochart/templates/hooks/pre-install-job.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: '{{ include "dinfochart.fullname" . }}-pre-install' - labels: - {{- include "dinfochart.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": pre-install - "helm.sh/hook-weight": "-5" - "helm.sh/hook-delete-policy": hook-succeeded -spec: - template: - metadata: - name: '{{ include "dinfochart.fullname" . }}-pre-install' - spec: - restartPolicy: Never - containers: - - name: pre-install-job - image: busybox - command: ['sh', '-c', 'echo Pre-install task running && sleep 1 && echo Pre-install completed'] diff --git a/k8s/screenshots/argo_cli_config.png b/k8s/screenshots/argo_cli_config.png new file mode 100644 index 0000000000..0548803b75 Binary files /dev/null and b/k8s/screenshots/argo_cli_config.png differ diff --git a/k8s/screenshots/argo_ui.png b/k8s/screenshots/argo_ui.png new file mode 100644 index 0000000000..8de22e9a83 Binary files /dev/null and b/k8s/screenshots/argo_ui.png differ