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.
This commit is contained in:
21
apps/myapp/base/deployment.yaml
Normal file
21
apps/myapp/base/deployment.yaml
Normal file
@@ -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
|
||||
19
apps/myapp/base/httproute.yaml
Normal file
19
apps/myapp/base/httproute.yaml
Normal file
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
17
apps/myapp/overlays/production/deployment-patch.yaml
Normal file
17
apps/myapp/overlays/production/deployment-patch.yaml
Normal file
@@ -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"
|
||||
7
apps/myapp/overlays/production/httproute-patch.yaml
Normal file
7
apps/myapp/overlays/production/httproute-patch.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: myapp-route
|
||||
spec:
|
||||
hostnames:
|
||||
- myapp.kube2.tricnet.de
|
||||
15
apps/myapp/overlays/production/kustomization.yaml
Normal file
15
apps/myapp/overlays/production/kustomization.yaml
Normal file
@@ -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
|
||||
17
apps/myapp/overlays/staging/deployment-patch.yaml
Normal file
17
apps/myapp/overlays/staging/deployment-patch.yaml
Normal file
@@ -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"
|
||||
7
apps/myapp/overlays/staging/httproute-patch.yaml
Normal file
7
apps/myapp/overlays/staging/httproute-patch.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: myapp-route
|
||||
spec:
|
||||
hostnames:
|
||||
- staging.myapp.kube2.tricnet.de
|
||||
15
apps/myapp/overlays/staging/kustomization.yaml
Normal file
15
apps/myapp/overlays/staging/kustomization.yaml
Normal file
@@ -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
|
||||
@@ -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: |
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>Sample Web App</title></head>
|
||||
<body>
|
||||
<h1>Sample Web App</h1>
|
||||
<p>Managed by Argo CD - GitOps is working!</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user