From fc5c6de0513e314d4bb60cbe98316828c1b71292 Mon Sep 17 00:00:00 2001 From: Multi-Environment Setup Date: Sun, 1 Feb 2026 22:48:59 +0100 Subject: [PATCH] feat: restructure GitOps for multi-environment deployment - Add apps/myapp/base with deployment, service, httproute - Add apps/myapp/overlays/staging (1 replica, 128Mi/256Mi, staging hostname) - Add apps/myapp/overlays/production (2 replicas, 256Mi/512Mi, prod hostname) - Remove old apps/sample-webapp structure Structure follows folder-per-environment pattern with Kustomize overlays. --- apps/myapp/base/deployment.yaml | 21 +++++++++++ apps/myapp/base/httproute.yaml | 19 ++++++++++ .../base}/kustomization.yaml | 7 ++-- .../base}/service.yaml | 7 ++-- .../overlays/production/deployment-patch.yaml | 17 +++++++++ .../overlays/production/httproute-patch.yaml | 7 ++++ .../overlays/production/kustomization.yaml | 15 ++++++++ .../overlays/staging/deployment-patch.yaml | 17 +++++++++ .../overlays/staging/httproute-patch.yaml | 7 ++++ .../myapp/overlays/staging/kustomization.yaml | 15 ++++++++ apps/sample-webapp/configmap.yaml | 18 --------- apps/sample-webapp/deployment.yaml | 37 ------------------- 12 files changed, 125 insertions(+), 62 deletions(-) create mode 100644 apps/myapp/base/deployment.yaml create mode 100644 apps/myapp/base/httproute.yaml rename apps/{sample-webapp => myapp/base}/kustomization.yaml (57%) rename apps/{sample-webapp => myapp/base}/service.yaml (59%) create mode 100644 apps/myapp/overlays/production/deployment-patch.yaml create mode 100644 apps/myapp/overlays/production/httproute-patch.yaml create mode 100644 apps/myapp/overlays/production/kustomization.yaml create mode 100644 apps/myapp/overlays/staging/deployment-patch.yaml create mode 100644 apps/myapp/overlays/staging/httproute-patch.yaml create mode 100644 apps/myapp/overlays/staging/kustomization.yaml delete mode 100644 apps/sample-webapp/configmap.yaml delete mode 100644 apps/sample-webapp/deployment.yaml diff --git a/apps/myapp/base/deployment.yaml b/apps/myapp/base/deployment.yaml new file mode 100644 index 0000000..e095559 --- /dev/null +++ b/apps/myapp/base/deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: myapp + labels: + app: myapp + managed-by: argocd +spec: + selector: + matchLabels: + app: myapp + template: + metadata: + labels: + app: myapp + spec: + containers: + - name: myapp + image: nginx:alpine + ports: + - containerPort: 80 diff --git a/apps/myapp/base/httproute.yaml b/apps/myapp/base/httproute.yaml new file mode 100644 index 0000000..380a60c --- /dev/null +++ b/apps/myapp/base/httproute.yaml @@ -0,0 +1,19 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: myapp-route + labels: + app: myapp + managed-by: argocd +spec: + parentRefs: + - name: cluster-gateway + namespace: traefik-system + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: myapp + port: 80 diff --git a/apps/sample-webapp/kustomization.yaml b/apps/myapp/base/kustomization.yaml similarity index 57% rename from apps/sample-webapp/kustomization.yaml rename to apps/myapp/base/kustomization.yaml index ff5298c..c9845ca 100644 --- a/apps/sample-webapp/kustomization.yaml +++ b/apps/myapp/base/kustomization.yaml @@ -1,6 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization + resources: - - configmap.yaml - - deployment.yaml - - service.yaml +- deployment.yaml +- service.yaml +- httproute.yaml diff --git a/apps/sample-webapp/service.yaml b/apps/myapp/base/service.yaml similarity index 59% rename from apps/sample-webapp/service.yaml rename to apps/myapp/base/service.yaml index 87bbf22..be91250 100644 --- a/apps/sample-webapp/service.yaml +++ b/apps/myapp/base/service.yaml @@ -1,14 +1,13 @@ apiVersion: v1 kind: Service metadata: - name: sample-webapp - namespace: sample + name: myapp labels: - app: sample-webapp + app: myapp managed-by: argocd spec: selector: - app: sample-webapp + app: myapp ports: - port: 80 targetPort: 80 diff --git a/apps/myapp/overlays/production/deployment-patch.yaml b/apps/myapp/overlays/production/deployment-patch.yaml new file mode 100644 index 0000000..461dc8d --- /dev/null +++ b/apps/myapp/overlays/production/deployment-patch.yaml @@ -0,0 +1,17 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: myapp +spec: + replicas: 2 + template: + spec: + containers: + - name: myapp + resources: + requests: + memory: "256Mi" + cpu: "200m" + limits: + memory: "512Mi" + cpu: "500m" diff --git a/apps/myapp/overlays/production/httproute-patch.yaml b/apps/myapp/overlays/production/httproute-patch.yaml new file mode 100644 index 0000000..e5c6c19 --- /dev/null +++ b/apps/myapp/overlays/production/httproute-patch.yaml @@ -0,0 +1,7 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: myapp-route +spec: + hostnames: + - myapp.kube2.tricnet.de diff --git a/apps/myapp/overlays/production/kustomization.yaml b/apps/myapp/overlays/production/kustomization.yaml new file mode 100644 index 0000000..3f17306 --- /dev/null +++ b/apps/myapp/overlays/production/kustomization.yaml @@ -0,0 +1,15 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: myapp-production + +resources: +- ../../base + +patches: +- path: deployment-patch.yaml +- path: httproute-patch.yaml + +images: +- name: nginx + newTag: alpine diff --git a/apps/myapp/overlays/staging/deployment-patch.yaml b/apps/myapp/overlays/staging/deployment-patch.yaml new file mode 100644 index 0000000..9c11540 --- /dev/null +++ b/apps/myapp/overlays/staging/deployment-patch.yaml @@ -0,0 +1,17 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: myapp +spec: + replicas: 1 + template: + spec: + containers: + - name: myapp + resources: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "256Mi" + cpu: "250m" diff --git a/apps/myapp/overlays/staging/httproute-patch.yaml b/apps/myapp/overlays/staging/httproute-patch.yaml new file mode 100644 index 0000000..7a86e75 --- /dev/null +++ b/apps/myapp/overlays/staging/httproute-patch.yaml @@ -0,0 +1,7 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: myapp-route +spec: + hostnames: + - staging.myapp.kube2.tricnet.de diff --git a/apps/myapp/overlays/staging/kustomization.yaml b/apps/myapp/overlays/staging/kustomization.yaml new file mode 100644 index 0000000..fb83471 --- /dev/null +++ b/apps/myapp/overlays/staging/kustomization.yaml @@ -0,0 +1,15 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: myapp-staging + +resources: +- ../../base + +patches: +- path: deployment-patch.yaml +- path: httproute-patch.yaml + +images: +- name: nginx + newTag: alpine diff --git a/apps/sample-webapp/configmap.yaml b/apps/sample-webapp/configmap.yaml deleted file mode 100644 index 11b18a1..0000000 --- a/apps/sample-webapp/configmap.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: sample-webapp-html - namespace: sample - labels: - app: sample-webapp - managed-by: argocd -data: - index.html: | - - - Sample Web App - -

Sample Web App

-

Managed by Argo CD - GitOps is working!

- - diff --git a/apps/sample-webapp/deployment.yaml b/apps/sample-webapp/deployment.yaml deleted file mode 100644 index 54ee17e..0000000 --- a/apps/sample-webapp/deployment.yaml +++ /dev/null @@ -1,37 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sample-webapp - namespace: sample - labels: - app: sample-webapp - managed-by: argocd -spec: - replicas: 2 - selector: - matchLabels: - app: sample-webapp - template: - metadata: - labels: - app: sample-webapp - spec: - containers: - - name: nginx - image: nginx:alpine - ports: - - containerPort: 80 - resources: - requests: - memory: "32Mi" - cpu: "10m" - limits: - memory: "64Mi" - cpu: "100m" - volumeMounts: - - name: html - mountPath: /usr/share/nginx/html - volumes: - - name: html - configMap: - name: sample-webapp-html