From 991b38d7bd0b278d71440483e20f650c2a001077 Mon Sep 17 00:00:00 2001 From: Ashley Felton Date: Mon, 23 Oct 2023 12:22:53 +0800 Subject: [PATCH] Added Kustomize base and UAT overlays. --- .gitignore | 3 +- kustomize/README.md | 26 ++++++++++ kustomize/base/deployment.yaml | 51 ++++++++++++++++++++ kustomize/base/kustomization.yaml | 3 ++ kustomize/base/service.yaml | 11 +++++ kustomize/overlays/uat/deployment_patch.yaml | 28 +++++++++++ kustomize/overlays/uat/ingress.yaml | 17 +++++++ kustomize/overlays/uat/kustomization.yaml | 18 +++++++ kustomize/overlays/uat/pdb.yaml | 10 ++++ kustomize/overlays/uat/service_patch.yaml | 9 ++++ 10 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 kustomize/README.md create mode 100644 kustomize/base/deployment.yaml create mode 100644 kustomize/base/kustomization.yaml create mode 100644 kustomize/base/service.yaml create mode 100644 kustomize/overlays/uat/deployment_patch.yaml create mode 100644 kustomize/overlays/uat/ingress.yaml create mode 100644 kustomize/overlays/uat/kustomization.yaml create mode 100644 kustomize/overlays/uat/pdb.yaml create mode 100644 kustomize/overlays/uat/service_patch.yaml diff --git a/.gitignore b/.gitignore index d549501..efdaa43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ -mapproxy.yaml +.env +config.yaml .python-version __pycache__/ diff --git a/kustomize/README.md b/kustomize/README.md new file mode 100644 index 0000000..f37bf13 --- /dev/null +++ b/kustomize/README.md @@ -0,0 +1,26 @@ +# MapProxy Kubernetes Kustomize overlay configuration + +Declarative management of MapProxy Kubernetes resources using Kustomize. + +# How to use + +Within an overlay directory, create a `config.yaml` file to configure the +proxied tile layers. + +Review the built resource output using `kustomize`: + +```bash +kustomize build kustomize/overlays/uat/ | less +``` + +Run `kubectl` with the `-k` flag to generate resources for a given overlay: + +```bash +kubectl apply -k kustomize/overlays/uat --namespace sss --dry-run=client +``` + +# References: + +* https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/ +* https://github.com/kubernetes-sigs/kustomize +* https://github.com/kubernetes-sigs/kustomize/tree/master/examples diff --git a/kustomize/base/deployment.yaml b/kustomize/base/deployment.yaml new file mode 100644 index 0000000..6f1bfcf --- /dev/null +++ b/kustomize/base/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mapproxy-deployment +spec: + replicas: 2 + strategy: + type: RollingUpdate + template: + spec: + containers: + - name: mapproxy + env: + - name: TZ + value: "Australia/Perth" + resources: + requests: + memory: "64Mi" + cpu: "10m" + limits: + memory: "4096Mi" + cpu: "1000m" + livenessProbe: + httpGet: + path: /demo/ + port: 8080 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 3 + failureThreshold: 3 + successThreshold: 1 + timeoutSeconds: 3 + readinessProbe: + httpGet: + path: /demo/ + port: 8080 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 3 + failureThreshold: 3 + successThreshold: 1 + timeoutSeconds: 3 + securityContext: + runAsNonRoot: true + privileged: false + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + readOnlyRootFilesystem: false + restartPolicy: Always diff --git a/kustomize/base/kustomization.yaml b/kustomize/base/kustomization.yaml new file mode 100644 index 0000000..a944d00 --- /dev/null +++ b/kustomize/base/kustomization.yaml @@ -0,0 +1,3 @@ +resources: +- deployment.yaml +- service.yaml diff --git a/kustomize/base/service.yaml b/kustomize/base/service.yaml new file mode 100644 index 0000000..bc29e85 --- /dev/null +++ b/kustomize/base/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: mapproxy-clusterip +spec: + type: ClusterIP + ports: + - name: wsgi + port: 8080 + protocol: TCP + targetPort: 8080 diff --git a/kustomize/overlays/uat/deployment_patch.yaml b/kustomize/overlays/uat/deployment_patch.yaml new file mode 100644 index 0000000..1c490b8 --- /dev/null +++ b/kustomize/overlays/uat/deployment_patch.yaml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mapproxy-deployment + labels: + app: mapproxy-uat +spec: + selector: + matchLabels: + app: mapproxy-uat + template: + metadata: + labels: + app: mapproxy-uat + spec: + containers: + - name: mapproxy + image: ghcr.io/dbca-wa/mapproxy + imagePullPolicy: Always + volumeMounts: + - mountPath: /app/config + name: mapproxy-configmap + volumes: + - configMap: + name: mapproxy-configmap-uat + defaultMode: 292 + optional: false + name: mapproxy-configmap diff --git a/kustomize/overlays/uat/ingress.yaml b/kustomize/overlays/uat/ingress.yaml new file mode 100644 index 0000000..cd78b26 --- /dev/null +++ b/kustomize/overlays/uat/ingress.yaml @@ -0,0 +1,17 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: mapproxy-ingress +spec: + ingressClassName: nginx + rules: + - host: mapproxy-uat.dbca.wa.gov.au + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: mapproxy-clusterip-uat + port: + number: 8080 diff --git a/kustomize/overlays/uat/kustomization.yaml b/kustomize/overlays/uat/kustomization.yaml new file mode 100644 index 0000000..9b7bda5 --- /dev/null +++ b/kustomize/overlays/uat/kustomization.yaml @@ -0,0 +1,18 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +nameSuffix: -uat +resources: + - ../../base + - ingress.yaml + - pdb.yaml +labels: + - includeSelectors: true + pairs: + variant: uat +patches: + - path: deployment_patch.yaml + - path: service_patch.yaml +configMapGenerator: + - name: mapproxy-configmap + files: + - config.yaml diff --git a/kustomize/overlays/uat/pdb.yaml b/kustomize/overlays/uat/pdb.yaml new file mode 100644 index 0000000..07f2472 --- /dev/null +++ b/kustomize/overlays/uat/pdb.yaml @@ -0,0 +1,10 @@ +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: mapproxy-pdb +spec: + minAvailable: 1 + selector: + matchLabels: + app: mapproxy-uat + variant: uat diff --git a/kustomize/overlays/uat/service_patch.yaml b/kustomize/overlays/uat/service_patch.yaml new file mode 100644 index 0000000..b5ddbd0 --- /dev/null +++ b/kustomize/overlays/uat/service_patch.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Service +metadata: + name: mapproxy-clusterip +spec: + type: ClusterIP + selector: + app: mapproxy-uat + variant: uat