cluster

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

commit c8e4a594a2cc4f9063f57a8de6a3f6ed7138df4e
parent d0a12cdda34300c57f57559cd2038c2a3c4a2363
Author: MTRNord <MTRNord@users.noreply.github.com>
Date:   Mon,  4 Aug 2025 14:51:39 +0200

Migrate connectivity-tester

Diffstat:
Aapps/talos_cluster/connectivity-tester/config.json | 3+++
Aapps/talos_cluster/connectivity-tester/deployment.yaml | 363+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aapps/talos_cluster/connectivity-tester/kustomization.yaml | 16++++++++++++++++
Aapps/talos_cluster/connectivity-tester/service.yaml | 23+++++++++++++++++++++++
Aapps/talos_cluster/connectivity-tester/staging_config.json | 3+++
Aapps/talos_cluster/connectivity-tester/staging_deployment.yaml | 173+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mapps/talos_cluster/kustomization.yaml | 1+
7 files changed, 582 insertions(+), 0 deletions(-)

diff --git a/apps/talos_cluster/connectivity-tester/config.json b/apps/talos_cluster/connectivity-tester/config.json @@ -0,0 +1,3 @@ +{ + "api_server_url": "https://api.connectivity-tester.mtrnord.blog" +} diff --git a/apps/talos_cluster/connectivity-tester/deployment.yaml b/apps/talos_cluster/connectivity-tester/deployment.yaml @@ -0,0 +1,363 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: connectivity-tester + namespace: matrix +spec: + progressDeadlineSeconds: 120 + strategy: + rollingUpdate: + maxUnavailable: 0 + type: RollingUpdate + selector: + matchLabels: + app: connectivity-tester + template: + metadata: + labels: + app: connectivity-tester + spec: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - connectivity-tester + topologyKey: "kubernetes.io/hostname" + imagePullSecrets: + - name: ghcr-pull + hostNetwork: false + containers: + - name: connection-checker-ui + image: ghcr.io/mtrnord/matrix-connection-tester-ui:v0.2.0 + imagePullPolicy: Always + lifecycle: + preStop: + exec: + command: + - sleep + - "10" + resources: + limits: {} + requests: + memory: "344Mi" + cpu: "252m" + ports: + - containerPort: 3000 + name: web + protocol: TCP + volumeMounts: + - name: configs + mountPath: "/usr/share/nginx/html/config.json" + subPath: config.json + readOnly: true + - mountPath: /tmp + name: tmp + livenessProbe: + httpGet: + path: / + port: web + scheme: HTTP + readinessProbe: + httpGet: + path: / + port: web + scheme: HTTP + startupProbe: + httpGet: + path: / + port: web + volumes: + - name: configs + configMap: + name: connectivity-tester-config + - name: tmp + emptyDir: + sizeLimit: 2048Mi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: connectivity-tester-api + namespace: matrix +spec: + progressDeadlineSeconds: 120 + strategy: + rollingUpdate: + maxUnavailable: 0 + type: RollingUpdate + selector: + matchLabels: + app: connectivity-tester-api + template: + metadata: + labels: + app: connectivity-tester-api + spec: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - connectivity-tester-api + topologyKey: "kubernetes.io/hostname" + imagePullSecrets: + - name: ghcr-pull + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + containers: + - name: federation-tester-api + image: ghcr.io/mtrnord/rust-federation-tester:v0.2.2 + imagePullPolicy: IfNotPresent + resources: + limits: {} + requests: + memory: "344Mi" + cpu: "252m" + volumeMounts: + - name: api-config + mountPath: /app/config.yaml + subPath: config.yaml + readOnly: true + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + readOnlyRootFilesystem: true + ports: + - containerPort: 8080 + name: api + protocol: TCP + readinessProbe: + httpGet: + path: /healthz + port: api + scheme: HTTP + livenessProbe: + httpGet: + path: /healthz + port: api + scheme: HTTP + startupProbe: + httpGet: + path: /healthz + port: api + volumes: + - name: api-config + secret: + secretName: connectivity-tester-config +--- +apiVersion: flagger.app/v1beta1 +kind: MetricTemplate +metadata: + name: connectivity-tester-latency + namespace: matrix +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) + )/1000 +--- +apiVersion: flagger.app/v1beta1 +kind: MetricTemplate +metadata: + name: connectivity-tester-error-rate + namespace: matrix +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 }}] + ) + ) / 100 +--- +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 + # 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 + retries: + attempts: 10 + perTryTimeout: 5s + retryOn: "gateway-error,connect-failure,refused-stream" + 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: matrix + thresholdRange: + max: 2 + interval: 1m + - name: latency + templateRef: + name: connectivity-tester-latency + namespace: matrix + # seconds + thresholdRange: + max: 1 + interval: 30s + sessionAffinity: + cookieName: flagger-cookie + # 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-canary.matrix:3000" + - name: load-test + url: http://flagger-loadtester.flagger-system/ + timeout: 10m + metadata: + cmd: "hey -z 10m -q 10 -c 2 http://connectivity-tester-canary.matrix/?serverName=mtrnord.blog" +--- +apiVersion: flagger.app/v1beta1 +kind: Canary +metadata: + name: connectivity-tester-api + namespace: matrix +spec: + # deployment reference + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: connectivity-tester-api + # 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: 8080 + # container port number or name (optional) + targetPort: 8080 + # Gateway API HTTPRoute host names + hosts: + - api.connectivity-tester.mtrnord.blog + # Reference to the Gateway that the generated HTTPRoute would attach to. + gatewayRefs: + - name: envoy-gateway + namespace: envoy-gateway + retries: + attempts: 10 + perTryTimeout: 5s + retryOn: "gateway-error,connect-failure,refused-stream" + 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: matrix + thresholdRange: + max: 2 + interval: 1m + - name: latency + templateRef: + name: connectivity-tester-latency + namespace: matrix + # seconds + thresholdRange: + max: 1 + interval: 30s + sessionAffinity: + cookieName: flagger-cookie + # 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-api-canary.matrix:8080/healthz | grep 'ok'" + - name: load-test + url: http://flagger-loadtester.flagger-system/ + timeout: 10m + metadata: + cmd: "hey -z 10m -q 10 -c 2 http://connectivity-tester-api-canary.matrix/api/federation/federation-ok?serverName=mtrnord.blog&no_cache=true" diff --git a/apps/talos_cluster/connectivity-tester/kustomization.yaml b/apps/talos_cluster/connectivity-tester/kustomization.yaml @@ -0,0 +1,16 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: matrix +resources: + - staging_deployment.yaml + - deployment.yaml + - service.yaml +configMapGenerator: + - name: connectivity-tester-config + namespace: matrix + files: + - config.json=config.json + - name: connectivity-tester-stage-config + namespace: matrix + files: + - config.json=staging_config.json diff --git a/apps/talos_cluster/connectivity-tester/service.yaml b/apps/talos_cluster/connectivity-tester/service.yaml @@ -0,0 +1,23 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: connectivity-tester-api-temp + namespace: matrix +spec: + parentRefs: + - name: envoy-gateway + namespace: envoy-gateway + hostnames: + - connectivity-tester.mtrnord.blog + - federationtester.mtrnord.blog + rules: + - matches: + - path: + value: /api + type: PathPrefix + backendRefs: + - name: connectivity-tester-api-primary + port: 8080 + timeouts: + request: 240s + backendRequest: 0s diff --git a/apps/talos_cluster/connectivity-tester/staging_config.json b/apps/talos_cluster/connectivity-tester/staging_config.json @@ -0,0 +1,3 @@ +{ + "api_server_url": "https://stage.connectivity-tester.mtrnord.blog" +} diff --git a/apps/talos_cluster/connectivity-tester/staging_deployment.yaml b/apps/talos_cluster/connectivity-tester/staging_deployment.yaml @@ -0,0 +1,173 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: connectivity-tester-stage + namespace: matrix +spec: + progressDeadlineSeconds: 120 + strategy: + rollingUpdate: + maxUnavailable: 0 + type: RollingUpdate + selector: + matchLabels: + app: connectivity-tester-stage + template: + metadata: + labels: + app: connectivity-tester-stage + spec: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - connectivity-tester-stage + topologyKey: "kubernetes.io/hostname" + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - connectivity-tester-api + topologyKey: "kubernetes.io/hostname" + imagePullSecrets: + - name: ghcr-pull + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + containers: + - name: federation-tester-api + image: ghcr.io/mtrnord/rust-federation-tester:main + imagePullPolicy: Always + resources: + limits: {} + requests: + memory: "344Mi" + cpu: "252m" + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + readOnlyRootFilesystem: true + volumeMounts: + - name: api-config + mountPath: /app/config.yaml + subPath: config.yaml + readOnly: true + ports: + - containerPort: 8080 + name: api + protocol: TCP + readinessProbe: + httpGet: + path: /healthz + port: api + scheme: HTTP + livenessProbe: + httpGet: + path: /healthz + port: api + scheme: HTTP + startupProbe: + httpGet: + path: /healthz + port: api + - name: connection-checker-ui + image: ghcr.io/mtrnord/matrix-connection-tester-ui:main + imagePullPolicy: Always + lifecycle: + preStop: + exec: + command: + - sleep + - "10" + resources: + limits: {} + requests: + memory: "344Mi" + cpu: "252m" + ports: + - containerPort: 3000 + name: web + protocol: TCP + volumeMounts: + - name: configs + mountPath: "/usr/share/nginx/html/config.json" + subPath: config.json + readOnly: true + - mountPath: /tmp + name: tmp + livenessProbe: + httpGet: + path: / + port: web + scheme: HTTP + readinessProbe: + httpGet: + path: / + port: web + scheme: HTTP + startupProbe: + httpGet: + path: / + port: web + volumes: + - name: configs + configMap: + name: connectivity-tester-stage-config + - name: tmp + emptyDir: + sizeLimit: 2048Mi + - name: api-config + secret: + secretName: connectivity-tester-stage-config +--- +apiVersion: v1 +kind: Service +metadata: + name: connectivity-tester-stage +spec: + selector: + app: connectivity-tester-stage + ports: + - name: api + port: 8080 + targetPort: 8080 + - name: web + port: 3000 + targetPort: 3000 +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: connectivity-tester-stage + namespace: matrix +spec: + parentRefs: + - name: envoy-gateway + namespace: envoy-gateway + hostnames: + - stage.connectivity-tester.mtrnord.blog + rules: + - matches: + - path: + value: /api + type: PathPrefix + backendRefs: + - name: connectivity-tester-stage + port: 8080 + timeouts: + request: 240s + backendRequest: 0s + - matches: + - path: + value: / + type: PathPrefix + backendRefs: + - name: connectivity-tester-stage + port: 3000 + timeouts: + request: 240s + backendRequest: 0s diff --git a/apps/talos_cluster/kustomization.yaml b/apps/talos_cluster/kustomization.yaml @@ -12,3 +12,4 @@ resources: - ./collabora - ./flagger - ./gotosocial + - ./connectivity-tester