From 3cbf54bbbe5f8160678bace9fd4e8c829f401b43 Mon Sep 17 00:00:00 2001 From: Daniel Bodky Date: Tue, 9 Apr 2024 09:32:36 +0200 Subject: [PATCH] Initial commit --- README.md | 12 +++++++ apps/.gitkeep | 0 first-gitops-app/configmap.yaml | 23 ++++++++++++ first-gitops-app/deployment.yaml | 41 ++++++++++++++++++++++ first-gitops-app/ingress.yaml | 17 +++++++++ first-gitops-app/service.yaml | 15 ++++++++ monitoring-appset.yaml | 40 +++++++++++++++++++++ monitoring-appset/alertmanager/Chart.yaml | 8 +++++ monitoring-appset/alertmanager/values.yaml | 4 +++ monitoring-appset/prometheus/Chart.yaml | 8 +++++ monitoring-appset/prometheus/values.yaml | 13 +++++++ parent-app.yaml | 16 +++++++++ 12 files changed, 197 insertions(+) create mode 100644 README.md create mode 100644 apps/.gitkeep create mode 100644 first-gitops-app/configmap.yaml create mode 100644 first-gitops-app/deployment.yaml create mode 100644 first-gitops-app/ingress.yaml create mode 100644 first-gitops-app/service.yaml create mode 100644 monitoring-appset.yaml create mode 100644 monitoring-appset/alertmanager/Chart.yaml create mode 100644 monitoring-appset/alertmanager/values.yaml create mode 100644 monitoring-appset/prometheus/Chart.yaml create mode 100644 monitoring-appset/prometheus/values.yaml create mode 100644 parent-app.yaml diff --git a/README.md b/README.md new file mode 100644 index 0000000..b832dd5 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# GitOps Examples + +This repository contains examples on GitOps with [ArgoCD](https://argo-cd.readthedocs.io) +to try out and build upon. + +It explores the following concepts: + +- basic ArgoCD `Applications`, using the manifests in [`first-gitops-app/`](./first-gitops-app) +- a simple _App-of-Apps_ `Application`, using [`parent-app.yaml`](./parent-app.yaml) and the children `Applications` in [`apps/`](./apps) +- an example `ApplicationSet`, using [`monitoring-appset.yaml`](./monitoring-appset.yaml) and the directories under [`monitoring-appset/`](./monitoring-appset/) + +For `parent-app.yaml` and `monitoring-appset.yaml`, only boilerplate YAML is defined - all information regarding the actual ArgoCD environment, repositories, etc. need to be entered. diff --git a/apps/.gitkeep b/apps/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/first-gitops-app/configmap.yaml b/first-gitops-app/configmap.yaml new file mode 100644 index 0000000..252b2c6 --- /dev/null +++ b/first-gitops-app/configmap.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-configmap +data: + index.html: | + + + + Welcome to NGINX! + + + +

Welcome to Our First Example!

+

This webserver has been deployed by ArgoCD, isn't that neat?

+ + diff --git a/first-gitops-app/deployment.yaml b/first-gitops-app/deployment.yaml new file mode 100644 index 0000000..b2437fe --- /dev/null +++ b/first-gitops-app/deployment.yaml @@ -0,0 +1,41 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx + labels: + app: nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:stable + ports: + - containerPort: 80 + livenessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 15 + periodSeconds: 10 + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + periodSeconds: 5 + volumeMounts: + - name: nginx-config + mountPath: /usr/share/nginx/html + volumes: + - name: nginx-config + configMap: + name: nginx-configmap diff --git a/first-gitops-app/ingress.yaml b/first-gitops-app/ingress.yaml new file mode 100644 index 0000000..7d9eeed --- /dev/null +++ b/first-gitops-app/ingress.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: nginx +spec: + rules: + - host: + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: nginx + port: + number: 80 diff --git a/first-gitops-app/service.yaml b/first-gitops-app/service.yaml new file mode 100644 index 0000000..c1ee8c2 --- /dev/null +++ b/first-gitops-app/service.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx + labels: + app: nginx +spec: + selector: + app: nginx + ports: + - protocol: TCP + port: 80 + targetPort: 80 + type: ClusterIP diff --git a/monitoring-appset.yaml b/monitoring-appset.yaml new file mode 100644 index 0000000..eaf4a78 --- /dev/null +++ b/monitoring-appset.yaml @@ -0,0 +1,40 @@ +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + name: monitoring-appset + namespace: argocd +spec: + generators: + - matrix: + generators: + - list: + elements: + - team: team-green + namespace: team-green-mon + - team: team-blue + namespace: blue-monitoring + - git: + directories: + - path: monitoring-appset/* + repoURL: https://github.com/mocdaniel/gitops-examples + revision: HEAD + goTemplate: true + template: + metadata: + name: "{{ .team }}-{{ .path.basename }}" + spec: + project: team-monitoring + source: + repoURL: https://github.com/mocdaniel/gitops-examples + targetRevision: HEAD + path: "{{ .path.path }}" + helm: + valueFiles: + - values.yaml + destination: + server: https://kubernetes.default.svc + namespace: "{{ .namespace }}" # this is dangerous! + syncPolicy: + syncOptions: + - CreateNamespace=true diff --git a/monitoring-appset/alertmanager/Chart.yaml b/monitoring-appset/alertmanager/Chart.yaml new file mode 100644 index 0000000..cde8cc9 --- /dev/null +++ b/monitoring-appset/alertmanager/Chart.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v2 +name: mon-alertmanager +version: 1.0.0 +dependencies: + - name: alertmanager + version: 1.10.0 + repository: https://prometheus-community.github.io/helm-charts diff --git a/monitoring-appset/alertmanager/values.yaml b/monitoring-appset/alertmanager/values.yaml new file mode 100644 index 0000000..d10855d --- /dev/null +++ b/monitoring-appset/alertmanager/values.yaml @@ -0,0 +1,4 @@ +--- +alertmanager: + persistence: + enabled: false diff --git a/monitoring-appset/prometheus/Chart.yaml b/monitoring-appset/prometheus/Chart.yaml new file mode 100644 index 0000000..92ea4a9 --- /dev/null +++ b/monitoring-appset/prometheus/Chart.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v2 +name: mon-prometheus +version: 1.0.0 +dependencies: + - name: prometheus + version: 25.19.1 + repository: https://prometheus-community.github.io/helm-charts diff --git a/monitoring-appset/prometheus/values.yaml b/monitoring-appset/prometheus/values.yaml new file mode 100644 index 0000000..5f73cb9 --- /dev/null +++ b/monitoring-appset/prometheus/values.yaml @@ -0,0 +1,13 @@ +--- +prometheus: + alertmanager: + enabled: false + kube-state-metrics: + enabled: false + prometheus-node-exporter: + enabled: false + prometheus-pushgateway: + enabled: false + server: + persistentVolume: + enabled: false diff --git a/parent-app.yaml b/parent-app.yaml new file mode 100644 index 0000000..ba2b046 --- /dev/null +++ b/parent-app.yaml @@ -0,0 +1,16 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: parent-app + namespace: argocd +spec: + destination: + namespace: + in-cluster: + project: + source: + repoURL: + targetRevision: HEAD + path: apps + syncPolicy: + automated: {}