Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mocdaniel committed Apr 15, 2024
0 parents commit 3cbf54b
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Empty file added apps/.gitkeep
Empty file.
23 changes: 23 additions & 0 deletions first-gitops-app/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-configmap
data:
index.html: |
<!DOCTYPE html>
<html>
<head>
<title>Welcome to NGINX!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to Our First Example!</h1>
<p>This webserver has been deployed by ArgoCD, isn&apos;t that neat?</p>
</body>
</html>
41 changes: 41 additions & 0 deletions first-gitops-app/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions first-gitops-app/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx
spec:
rules:
- host: <valid-domain-here>
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx
port:
number: 80
15 changes: 15 additions & 0 deletions first-gitops-app/service.yaml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions monitoring-appset.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions monitoring-appset/alertmanager/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions monitoring-appset/alertmanager/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
alertmanager:
persistence:
enabled: false
8 changes: 8 additions & 0 deletions monitoring-appset/prometheus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions monitoring-appset/prometheus/values.yaml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions parent-app.yaml
Original file line number Diff line number Diff line change
@@ -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: {}

0 comments on commit 3cbf54b

Please sign in to comment.