cluster

Infrastructure files for Nordgedanken and Midnightthoughts.
git clone git://archive.git.mtrnord.blog/MTRNord/cluster.git
Log | Files | Refs | README

commit fab1eed7b65d43a007c8ae407b735b4b9eaf1f3f
parent 4ebacb116d9ba8fffdf1fb5f64e63a0c818edcdf
Author: MTRNord <MTRNord@users.noreply.github.com>
Date:   Sat, 28 Jun 2025 19:58:41 +0200

Try canary deployments

Diffstat:
Mapps/2024_cluster/namespaces/flagger.yaml | 1-
Mapps/base/flagger/release.yaml | 2+-
Mapps/base/flagger/repository.yaml | 1-
Mapps/base/matrix/connectivity-tester/deployment.yaml | 125+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mapps/base/matrix/connectivity-tester/kustomization.yaml | 4++--
Mapps/base/matrix/connectivity-tester/service.yaml | 28+++++++++-------------------
6 files changed, 137 insertions(+), 24 deletions(-)

diff --git a/apps/2024_cluster/namespaces/flagger.yaml b/apps/2024_cluster/namespaces/flagger.yaml @@ -1,4 +1,3 @@ ---- apiVersion: v1 kind: Namespace metadata: diff --git a/apps/base/flagger/release.yaml b/apps/base/flagger/release.yaml @@ -1,4 +1,3 @@ ---- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: @@ -27,6 +26,7 @@ spec: metricsServer: "http://vmselect-vm-victoria-metrics-k8s-stack.monitoring.svc:8481/select/0/prometheus" serviceMonitor: enabled: true + meshProvider: "gatewayapi:v1" --- apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 kind: Kustomization diff --git a/apps/base/flagger/repository.yaml b/apps/base/flagger/repository.yaml @@ -1,4 +1,3 @@ ---- apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: HelmRepository metadata: diff --git a/apps/base/matrix/connectivity-tester/deployment.yaml b/apps/base/matrix/connectivity-tester/deployment.yaml @@ -1,3 +1,4 @@ +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -90,3 +91,127 @@ spec: - name: tmp emptyDir: sizeLimit: 2048Mi +--- +apiVersion: flagger.app/v1beta1 +kind: MetricTemplate +metadata: + name: connectivity-tester-latency + namespace: flagger-system +spec: + provider: + type: prometheus + address: "http://vmselect-vm-victoria-metrics-k8s-stack.monitoring.svc:8481/select/0/prometheus" + query: | + histogram_quantile(0.99, + sum( + irate( + envoy_cluster_upstream_rq_time_bucket{ + envoy_cluster_name=~".*{{ namespace }}/{{ target }}.*", + }[{{ interval }}] + ) + ) by (le) + ) +--- +apiVersion: flagger.app/v1beta1 +kind: MetricTemplate +metadata: + name: connectivity-tester-error-rate + namespace: flagger-system +spec: + provider: + type: prometheus + address: "http://vmselect-vm-victoria-metrics-k8s-stack.monitoring.svc:8481/select/0/prometheus" + query: | + sum( + rate( + envoy_cluster_upstream_rq{ + envoy_cluster_name=~".*{{ namespace }}/{{ target }}.*", + envoy_response_code!~"5.*" + }[{{ interval }}] + ) + ) + / + sum( + rate( + envoy_cluster_upstream_rq_total{ + envoy_cluster_name=~".*{{ namespace }}/{{ target }}.*", + }[{{ interval }}] + ) + ) +--- +apiVersion: flagger.app/v1beta1 +kind: Canary +metadata: + name: connectivity-tester + namespace: matrix +spec: + # deployment reference + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: connectivity-tester + # the maximum time in seconds for the canary deployment + # to make progress before it is rollback (default 600s) + progressDeadlineSeconds: 60 + # HPA reference (optional) + #autoscalerRef: + # apiVersion: autoscaling/v2 + # kind: HorizontalPodAutoscaler + # name: connectivity-tester + service: + # service port number + port: 3000 + # container port number or name (optional) + targetPort: 3000 + portDiscovery: true + # Gateway API HTTPRoute host names + hosts: + - connectivity-tester.mtrnord.blog + - federationtester.mtrnord.blog + # Reference to the Gateway that the generated HTTPRoute would attach to. + gatewayRefs: + - name: envoy-gateway + namespace: envoy-gateway + analysis: + # schedule interval (default 60s) + interval: 1m + # max number of failed metric checks before rollback + threshold: 5 + # max traffic percentage routed to canary + # percentage (0-100) + maxWeight: 50 + # canary increment step + # percentage (0-100) + stepWeight: 10 + metrics: + - name: error-rate + # max error rate (5xx responses) + # percentage (0-100) + templateRef: + name: connectivity-tester-error-rate + namespace: flagger-system + thresholdRange: + max: 1 + interval: 1m + - name: latency + templateRef: + name: connectivity-tester-latency + namespace: flagger-system + # seconds + thresholdRange: + max: 0.5 + interval: 30s + # testing (optional) + webhooks: + - name: smoke-test + type: pre-rollout + url: http://flagger-loadtester.flagger-system/ + timeout: 15s + metadata: + type: bash + cmd: "curl -s http://connectivity-tester.matrix:3000 && curl -s http://connectivity-tester.matrix:8080/healthz | grep 'OK'" + - name: load-test + url: http://flagger-loadtester.flagger-system/ + timeout: 5s + metadata: + cmd: "hey -z 2m -q 10 -c 2 -host connectivity-tester.mtrnord.blog http://connectivity-tester.matrix:3000/" diff --git a/apps/base/matrix/connectivity-tester/kustomization.yaml b/apps/base/matrix/connectivity-tester/kustomization.yaml @@ -3,9 +3,9 @@ kind: Kustomization namespace: matrix resources: - deployment.yaml - - service.yaml + #- service.yaml configMapGenerator: - name: connectivity-tester-config namespace: matrix files: - - config.json=config.json + - config.json=config.json diff --git a/apps/base/matrix/connectivity-tester/service.yaml b/apps/base/matrix/connectivity-tester/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: connectivity-tester + name: connectivity-tester-api namespace: matrix labels: app: connectivity-tester @@ -13,15 +13,11 @@ spec: targetPort: api protocol: TCP name: api - - port: 3000 - targetPort: web - protocol: TCP - name: web --- apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: connectivity-tester + name: connectivity-tester-api namespace: matrix spec: parentRefs: @@ -32,18 +28,12 @@ spec: - federationtester.mtrnord.blog rules: - matches: - - path: - value: /api - type: PathPrefix + - path: + value: /api + type: PathPrefix backendRefs: - - name: connectivity-tester - port: 8080 - timeouts: - request: 240s - backendRequest: 0s - - backendRefs: - - name: connectivity-tester - port: 3000 + - name: connectivity-tester + port: 8080 timeouts: - request: 240s - backendRequest: 0s + request: 240s + backendRequest: 0s