Skip to content

staging: Deploy swh.counters template in dynamic infra (cronjob, rpc, ...)

Antoine R. Dumont requested to merge update-counters into staging

This adds:

  • the refresh counters cache cronjob which will replace the current cron on counters0.staging
  • an init-container to the rpc deployment to conditionally go and fetch the static historical data (for production, on staging, it will be disabled)
  • the last commit actually triggers the deployment of the counters' cronjob and rpc service deployment in staging.

Tested through minikube.

There will be probably some firewall rules to adapt when deploying this (e.g. opening access from the staging cluster to the admin cluster for the thanos.internal.admin.swh.network node)

make swh-helm-diff
[swh] Generate config in production branch for environment staging, namespace swh...
[swh] Generate config in production branch for environment staging, namespace swh-cassandra...
[swh] Generate config in production branch for environment staging, namespace swh-cassandra-next-version...
Switched to branch 'update-counters'
[swh] Generate config in update-counters branch for environment staging...
[swh] Generate config in update-counters branch for environment staging...
[swh] Generate config in update-counters branch for environment staging...
Switched to branch 'production'
Your branch is up to date with 'origin/production'.
[swh] Generate config in production branch for environment production, namespace swh...
[swh] Generate config in production branch for environment production, namespace swh-cassandra...
[swh] Generate config in production branch for environment production, namespace swh-cassandra-next-version...
Switched to branch 'update-counters'
[swh] Generate config in update-counters branch for environment production...
[swh] Generate config in update-counters branch for environment production...
[swh] Generate config in update-counters branch for environment production...


------------- diff for environment staging namespace swh -------------

--- /tmp/swh-chart.swh.a3oKG4Y0/staging-swh.before      2023-12-11 16:37:36.784901482 +0100
+++ /tmp/swh-chart.swh.a3oKG4Y0/staging-swh.after       2023-12-11 16:37:37.488901318 +0100
@@ -14243,20 +14243,30 @@
     port: 443
     protocol: TCP
     targetPort: 9443
   selector:
     app: keda-admission-webhooks
 ---
 # Source: swh/templates/external-services/cname.yaml
 apiVersion: v1
 kind: Service
 metadata:
+  name: counters-rpc-ingress
+  namespace: swh
+spec:
+  type: ExternalName
+  externalName: archive-staging-rke2-ingress-nginx-controller.ingress-nginx.svc.cluster.local
+---
+# Source: swh/templates/external-services/cname.yaml
+apiVersion: v1
+kind: Service
+metadata:
   name: deposit-rpc-ingress
   namespace: swh
 spec:
   type: ExternalName
   externalName: archive-staging-rke2-ingress-nginx-controller.ingress-nginx.svc.cluster.local
 ---
 # Source: swh/templates/external-services/cname.yaml
 apiVersion: v1
 kind: Service
 metadata:


------------- diff for environment staging namespace swh-cassandra -------------

--- /tmp/swh-chart.swh.a3oKG4Y0/staging-swh-cassandra.before    2023-12-11 16:37:37.012901429 +0100
+++ /tmp/swh-chart.swh.a3oKG4Y0/staging-swh-cassandra.after     2023-12-11 16:37:37.716901264 +0100
@@ -363,20 +363,86 @@
       - directory
       - origin
       - origin_visit
       - origin_visit_status
       - release
       - revision
       - skipped_content
       - snapshot
       prefix: swh.journal.objects
 ---
+# Source: swh/templates/counters/rpc-configmap.yaml
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  namespace: swh-cassandra
+  name: counters-rpc-configuration-template
+data:
+  config.yml.template: |
+    counters:
+      cls: redis
+      host: counters0.internal.staging.swh.network:6379
+    history:
+      cls: prometheus
+      interval: 12h
+      labels:
+        environment: staging
+      live_data_start: 0
+      prometheus_host: thanos.internal.admin.swh.network
+      prometheus_port: 19191
+      cache_base_directory: /srv/softwareheritage/counters
+---
+# Source: swh/templates/counters/script-utils.yaml
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: script-utils
+  namespace: swh-cassandra
+data:
+  refresh-counters-cache.sh: |
+    #!/bin/bash
+
+    set -ex
+
+    cache_file=$1
+    static_file=$2
+
+    static_file_stanza=""
+    if [ -n "${static_file}" ]; then
+        static_file_stanza=", \"static_file\": \"${static_file}\""
+    fi
+
+    tmp_file=$(mktemp)
+
+    trap "rm -f ${tmp_file}" EXIT
+
+    cat >"${tmp_file}" <<EOF
+    {
+        "cache_file": "${cache_file}",
+        "objects": ["content", "origin", "revision"]
+        ${static_file_stanza}
+    }
+    EOF
+
+    curl -s -XPOST -H 'Content-Type: application/json' http://counters0.internal.staging.swh.network:5011//refresh_history -d @"${tmp_file}"
+
+  fetch-static-history.sh: |
+    #!/bin/bash
+
+    set -ex
+
+    static_history_path=$1
+
+    url="https://gitlab.softwareheritage.org/swh/devel/swh-counters/-/snippets/1617/raw/main/snippetfile1.txt?inline=false"
+
+    curl -s $url > $static_history_path
+---
 # Source: swh/templates/deposit/configmap.yaml
 apiVersion: v1
 kind: ConfigMap
 metadata:
   namespace: swh-cassandra
   name: deposit-configuration-template
 data:
   config.yml.template: |
     instance_name: deposit-rpc-ingress
     allowed_hosts:
@@ -14129,20 +14195,35 @@
   namespace: default
 spec:
   ports:
   - name: http
     port: 443
     protocol: TCP
     targetPort: 9443
   selector:
     app: keda-admission-webhooks
 ---
+# Source: swh/templates/counters/rpc-service.yaml
+apiVersion: v1
+kind: Service
+metadata:
+  name: counters-rpc
+  namespace: swh-cassandra
+spec:
+  type: ClusterIP
+  selector:
+    app: counters-rpc
+  ports:
+    - port: 5011
+      targetPort: 5011
+      name: rpc
+---
 # Source: swh/templates/deposit/service.yaml
 apiVersion: v1
 kind: Service
 metadata:
   name: deposit
   namespace: swh-cassandra
 spec:
   type: ClusterIP
   selector:
     app: deposit
@@ -14152,20 +14233,30 @@
       name: rpc

     - port: 80
       targetPort: 80
       name: webstatic
 ---
 # Source: swh/templates/external-services/cname.yaml
 apiVersion: v1
 kind: Service
 metadata:
+  name: counters-rpc-ingress
+  namespace: swh-cassandra
+spec:
+  type: ExternalName
+  externalName: archive-staging-rke2-ingress-nginx-controller.ingress-nginx.svc.cluster.local
+---
+# Source: swh/templates/external-services/cname.yaml
+apiVersion: v1
+kind: Service
+metadata:
   name: deposit-rpc-ingress
   namespace: swh-cassandra
 spec:
   type: ExternalName
   externalName: archive-staging-rke2-ingress-nginx-controller.ingress-nginx.svc.cluster.local
 ---
 # Source: swh/templates/external-services/cname.yaml
 apiVersion: v1
 kind: Service
 metadata:
@@ -15020,21 +15111,21 @@
         nodeAffinity:
           requiredDuringSchedulingIgnoredDuringExecution:
             nodeSelectorTerms:
             - matchExpressions:
               - key: swh/journal_client
                 operator: In
                 values:
                 - "true"
       initContainers:
         - name: prepare-configuration
-          image: debian:bullseye
+          image: container-registry.softwareheritage.org/swh/infra/swh-apps/utils:20231211.1
           imagePullPolicy: IfNotPresent
           command:
           - /entrypoints/prepare-configuration.sh
           volumeMounts:
           - name: configuration
             mountPath: /etc/swh
           - name: configuration-template
             mountPath: /etc/swh/configuration-template
           - name: config-utils
             mountPath: /entrypoints
@@ -15079,20 +15170,136 @@
         configMap:
           name: counters-journal-client-configuration-template
           items:
           - key: "config.yml.template"
             path: "config.yml.template"
       - name: config-utils
         configMap:
           name: config-utils
           defaultMode: 0555
 ---
+# Source: swh/templates/counters/rpc-deployment.yaml
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  namespace: swh-cassandra
+  name: counters-rpc
+  labels:
+    app: counters-rpc
+spec:
+  revisionHistoryLimit: 2
+  selector:
+    matchLabels:
+      app: counters-rpc
+  strategy:
+    type: RollingUpdate
+    rollingUpdate:
+      maxSurge: 1
+  template:
+    metadata:
+      labels:
+        app: counters-rpc
+      annotations:
+        checksum/configmap: d974568e5cc0e38a7f87d277d3b43fd143eb758c1b94089ed5755b4d353d802b
+        checksum/script-utils: d03e38335b3ef317dd10c9e7e4065a6fa7a43f8fa7a6c0d10bea4a9cdc6ac3ba
+    spec:
+      affinity:
+        nodeAffinity:
+          requiredDuringSchedulingIgnoredDuringExecution:
+            nodeSelectorTerms:
+            - matchExpressions:
+              - key: swh/rpc
+                operator: In
+                values:
+                - "true"
+      priorityClassName: swh-cassandra-frontend-rpc
+
+      initContainers:
+        - name: prepare-configuration
+          image: container-registry.softwareheritage.org/swh/infra/swh-apps/utils:20231211.1
+          imagePullPolicy: IfNotPresent
+          command:
+          - /entrypoints/prepare-configuration.sh
+          volumeMounts:
+          - name: configuration
+            mountPath: /etc/swh
+          - name: configuration-template
+            mountPath: /etc/swh/configuration-template
+          - name: config-utils
+            mountPath: /entrypoints
+            readOnly: true
+          env:
+
+
+      containers:
+        - name: counters-rpc
+          resources:
+            requests:
+              memory: 512Mi
+              cpu: 500m
+          image: container-registry.softwareheritage.org/swh/infra/swh-apps/counters:20231205.1
+          imagePullPolicy: IfNotPresent
+          ports:
+            - containerPort: 5011
+              name: rpc
+          readinessProbe:
+            httpGet:
+              path: /
+              port: rpc
+            initialDelaySeconds: 15
+            failureThreshold: 30
+            periodSeconds: 5
+          livenessProbe:
+            httpGet:
+              path: /
+              port: rpc
+            initialDelaySeconds: 10
+            periodSeconds: 5
+          command:
+          - /bin/bash
+          args:
+          - -c
+          - /opt/swh/entrypoint.sh
+          env:
+            - name: THREADS
+              value: "1"
+            - name: WORKERS
+              value: "1"
+            - name: TIMEOUT
+              value: "10"
+            - name: STATSD_HOST
+              value: prometheus-statsd-exporter
+            - name: STATSD_PORT
+              value: "9125"
+            - name: LOG_LEVEL
+              value: INFO
+          volumeMounts:
+          - name: configuration
+            mountPath: /etc/swh
+          - name: staticdata
+            mountPath: /srv/softwareheritage/counters
+      volumes:
+      - name: configuration
+        emptyDir: {}
+      - name: staticdata
+        emptyDir: {}
+      - name: configuration-template
+        configMap:
+          name: counters-rpc-configuration-template
+          items:
+          - key: "config.yml.template"
+            path: "config.yml.template"
+      - name: config-utils
+        configMap:
+          name: config-utils
+          defaultMode: 0555
+---
 # Source: swh/templates/deposit/deployment.yaml
 apiVersion: apps/v1
 kind: Deployment
 metadata:
   namespace: swh-cassandra
   name: deposit
   labels:
     app: deposit
 spec:
   revisionHistoryLimit: 2
@@ -23030,20 +23237,43 @@
       - name: configuration
         emptyDir: {}
       - name: configuration-template
         configMap:
           name: webhooks-origin-visit-status-template
           defaultMode: 0777
           items:
           - key: "config.yml.template"
             path: "config.yml.template"
 ---
+# Source: swh/templates/counters/rpc-autoscale.yaml
+apiVersion: autoscaling/v2
+kind: HorizontalPodAutoscaler
+metadata:
+  namespace: swh-cassandra
+  name: counters-rpc
+  labels:
+    app: counters-rpc
+spec:
+  scaleTargetRef:
+    apiVersion: apps/v1
+    kind: Deployment
+    name: counters-rpc
+  minReplicas: 2
+  maxReplicas: 4
+  metrics:
+  - type: Resource
+    resource:
+      name: cpu
+      target:
+        type: Utilization
+        averageUtilization: 100
+---
 # Source: swh/templates/deposit/autoscaling.yaml
 apiVersion: autoscaling/v2
 kind: HorizontalPodAutoscaler
 metadata:
   namespace: swh-cassandra
   name: deposit
   labels:
     app: deposit
 spec:
   scaleTargetRef:
@@ -23166,20 +23396,78 @@
   minReplicas: 2
   maxReplicas: 4
   metrics:
   - type: Resource
     resource:
       name: cpu
       target:
         type: Utilization
         averageUtilization: 1000
 ---
+# Source: swh/templates/counters/refresh-counters-cache-cronjob.yaml
+apiVersion: batch/v1
+kind: CronJob
+metadata:
+  name: counters-refresh-counters-cache-cronjob
+spec:
+  # By default, every 4h
+  schedule: "0 */1 * * *"
+  concurrencyPolicy: Forbid
+  jobTemplate:
+    spec:
+      template:
+        spec:
+          containers:
+            - name: counters-refresh-counters-cache
+              resources:
+                requests:
+                  memory: 512Mi
+                  cpu: 500m
+              image: container-registry.softwareheritage.org/swh/infra/swh-apps/counters:20231205.1
+              command:
+              - /cron/bin/refresh-counters-cache.sh
+              args:
+              - history.json
+              - static_history.json
+              env:
+                - name: STATSD_HOST
+                  value: prometheus-statsd-exporter
+                - name: STATSD_PORT
+                  value: "9125"
+                - name: SWH_CONFIG_FILENAME
+                  value: /etc/swh/config.yml
+                - name: LOG_LEVEL
+                  value: INFO
+              imagePullPolicy: IfNotPresent
+              volumeMounts:
+              - name: configuration
+                mountPath: /etc/swh
+              - name: script-utils
+                mountPath: /cron/bin/
+          volumes:
+          - name: configuration
+            emptyDir: {}
+          - name: configuration-template
+            configMap:
+              name: counters-refresh-counters-cache-configuration-template
+              items:
+              - key: "config.yml.template"
+                path: "config.yml.template"
+          - name: script-utils
+            configMap:
+              name: script-utils
+              defaultMode: 0555
+              items:
+              - key: "refresh-counters-cache.sh"
+                path: "refresh-counters-cache.sh"
+          restartPolicy: OnFailure
+---
 # Source: swh/templates/web/sync-mailmaps-cronjob.yaml
 apiVersion: batch/v1
 kind: CronJob
 metadata:
   name: sync-mailmaps-cronjob
 spec:
   schedule: "15 * * * *"
   concurrencyPolicy: Forbid
   jobTemplate:
     spec:
@@ -23344,20 +23632,46 @@
                 path: "config.yml.template"
           - name: pgservice-configuration-template
             configMap:
               name: pgservice-configuration-template
               items:
               - key: "pg-service-conf"
                 path: "pg_service.conf"

           restartPolicy: OnFailure
 ---
+# Source: swh/templates/counters/rpc-ingress.yaml
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  namespace: swh-cassandra
+  name: counters-rpc-ingress-default
+  annotations:
+    nginx.ingress.kubernetes.io/proxy-body-size: 4G
+    nginx.ingress.kubernetes.io/proxy-connect-timeout: "90"
+    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
+    nginx.ingress.kubernetes.io/proxy-request-buffering: "on"
+    nginx.ingress.kubernetes.io/proxy-send-timeout: "90"
+
+spec:
+  rules:
+  - host: counters-rpc-ingress
+    http:
+      paths:
+      - path: /
+        pathType: Prefix
+        backend:
+          service:
+            name: counters-rpc
+            port:
+              number: 5011
+---
 # Source: swh/templates/deposit/ingress.yaml
 apiVersion: networking.k8s.io/v1
 kind: Ingress
 metadata:
   namespace: swh-cassandra
   name: deposit-ingress-authenticated
   annotations:
     cert-manager.io/cluster-issuer: letsencrypt-production-gandi
     kubernetes.io/ingress.class: nginx
     kubernetes.io/tls-acme: "true"


------------- diff for environment staging namespace swh-cassandra-next-version -------------

--- /tmp/swh-chart.swh.a3oKG4Y0/staging-swh-cassandra-next-version.before       2023-12-11 16:37:37.236901377 +0100
+++ /tmp/swh-chart.swh.a3oKG4Y0/staging-swh-cassandra-next-version.after        2023-12-11 16:37:37.940901212 +0100
@@ -363,20 +363,86 @@
       - directory
       - origin
       - origin_visit
       - origin_visit_status
       - release
       - revision
       - skipped_content
       - snapshot
       prefix: swh.journal.objects
 ---
+# Source: swh/templates/counters/rpc-configmap.yaml
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  namespace: swh-cassandra-next-version
+  name: counters-rpc-configuration-template
+data:
+  config.yml.template: |
+    counters:
+      cls: redis
+      host: counters0.internal.staging.swh.network:6379
+    history:
+      cls: prometheus
+      interval: 12h
+      labels:
+        environment: staging
+      live_data_start: 0
+      prometheus_host: thanos.internal.admin.swh.network
+      prometheus_port: 19191
+      cache_base_directory: /srv/softwareheritage/counters
+---
+# Source: swh/templates/counters/script-utils.yaml
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: script-utils
+  namespace: swh-cassandra-next-version
+data:
+  refresh-counters-cache.sh: |
+    #!/bin/bash
+
+    set -ex
+
+    cache_file=$1
+    static_file=$2
+
+    static_file_stanza=""
+    if [ -n "${static_file}" ]; then
+        static_file_stanza=", \"static_file\": \"${static_file}\""
+    fi
+
+    tmp_file=$(mktemp)
+
+    trap "rm -f ${tmp_file}" EXIT
+
+    cat >"${tmp_file}" <<EOF
+    {
+        "cache_file": "${cache_file}",
+        "objects": ["content", "origin", "revision"]
+        ${static_file_stanza}
+    }
+    EOF
+
+    curl -s -XPOST -H 'Content-Type: application/json' http://counters0.internal.staging.swh.network:5011//refresh_history -d @"${tmp_file}"
+
+  fetch-static-history.sh: |
+    #!/bin/bash
+
+    set -ex
+
+    static_history_path=$1
+
+    url="https://gitlab.softwareheritage.org/swh/devel/swh-counters/-/snippets/1617/raw/main/snippetfile1.txt?inline=false"
+
+    curl -s $url > $static_history_path
+---
 # Source: swh/templates/graphql/configmap.yaml
 apiVersion: v1
 kind: ConfigMap
 metadata:
   name: graphql
   namespace: swh-cassandra-next-version
 data:
   # TODO: rename to not have a dot in the name to allow testing
   config.yml: |
     storage:
@@ -13619,20 +13685,45 @@
   namespace: default
 spec:
   ports:
   - name: http
     port: 443
     protocol: TCP
     targetPort: 9443
   selector:
     app: keda-admission-webhooks
 ---
+# Source: swh/templates/counters/rpc-service.yaml
+apiVersion: v1
+kind: Service
+metadata:
+  name: counters-rpc
+  namespace: swh-cassandra-next-version
+spec:
+  type: ClusterIP
+  selector:
+    app: counters-rpc
+  ports:
+    - port: 5011
+      targetPort: 5011
+      name: rpc
+---
+# Source: swh/templates/external-services/cname.yaml
+apiVersion: v1
+kind: Service
+metadata:
+  name: counters-rpc-ingress
+  namespace: swh-cassandra-next-version
+spec:
+  type: ExternalName
+  externalName: archive-staging-rke2-ingress-nginx-controller.ingress-nginx.svc.cluster.local
+---
 # Source: swh/templates/external-services/cname.yaml
 apiVersion: v1
 kind: Service
 metadata:
   name: deposit-rpc-ingress
   namespace: swh-cassandra-next-version
 spec:
   type: ExternalName
   externalName: archive-staging-rke2-ingress-nginx-controller.ingress-nginx.svc.cluster.local
 ---
@@ -14461,21 +14552,21 @@
         nodeAffinity:
           requiredDuringSchedulingIgnoredDuringExecution:
             nodeSelectorTerms:
             - matchExpressions:
               - key: swh/journal_client
                 operator: In
                 values:
                 - "true"
       initContainers:
         - name: prepare-configuration
-          image: debian:bullseye
+          image: container-registry.softwareheritage.org/swh/infra/swh-apps/utils:20231211.1
           imagePullPolicy: IfNotPresent
           command:
           - /entrypoints/prepare-configuration.sh
           volumeMounts:
           - name: configuration
             mountPath: /etc/swh
           - name: configuration-template
             mountPath: /etc/swh/configuration-template
           - name: config-utils
             mountPath: /entrypoints
@@ -14520,20 +14611,136 @@
         configMap:
           name: counters-journal-client-configuration-template
           items:
           - key: "config.yml.template"
             path: "config.yml.template"
       - name: config-utils
         configMap:
           name: config-utils
           defaultMode: 0555
 ---
+# Source: swh/templates/counters/rpc-deployment.yaml
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  namespace: swh-cassandra-next-version
+  name: counters-rpc
+  labels:
+    app: counters-rpc
+spec:
+  revisionHistoryLimit: 2
+  selector:
+    matchLabels:
+      app: counters-rpc
+  strategy:
+    type: RollingUpdate
+    rollingUpdate:
+      maxSurge: 1
+  template:
+    metadata:
+      labels:
+        app: counters-rpc
+      annotations:
+        checksum/configmap: c09a1ed2efd89f46b09f8353e42e2135afbc1c6aaa9ee9fc8ac33992c359a49d
+        checksum/script-utils: 5c95764c23110e4be51e081ef12725bd48ec8f5ab51dfd443d29e5d918de9a2b
+    spec:
+      affinity:
+        nodeAffinity:
+          requiredDuringSchedulingIgnoredDuringExecution:
+            nodeSelectorTerms:
+            - matchExpressions:
+              - key: swh/rpc
+                operator: In
+                values:
+                - "true"
+      priorityClassName: swh-cassandra-next-version-frontend-rpc
+
+      initContainers:
+        - name: prepare-configuration
+          image: container-registry.softwareheritage.org/swh/infra/swh-apps/utils:20231211.1
+          imagePullPolicy: IfNotPresent
+          command:
+          - /entrypoints/prepare-configuration.sh
+          volumeMounts:
+          - name: configuration
+            mountPath: /etc/swh
+          - name: configuration-template
+            mountPath: /etc/swh/configuration-template
+          - name: config-utils
+            mountPath: /entrypoints
+            readOnly: true
+          env:
+
+
+      containers:
+        - name: counters-rpc
+          resources:
+            requests:
+              memory: 512Mi
+              cpu: 500m
+          image: container-registry.softwareheritage.org/swh/infra/swh-apps/counters:20231205.1
+          imagePullPolicy: IfNotPresent
+          ports:
+            - containerPort: 5011
+              name: rpc
+          readinessProbe:
+            httpGet:
+              path: /
+              port: rpc
+            initialDelaySeconds: 15
+            failureThreshold: 30
+            periodSeconds: 5
+          livenessProbe:
+            httpGet:
+              path: /
+              port: rpc
+            initialDelaySeconds: 10
+            periodSeconds: 5
+          command:
+          - /bin/bash
+          args:
+          - -c
+          - /opt/swh/entrypoint.sh
+          env:
+            - name: THREADS
+              value: "1"
+            - name: WORKERS
+              value: "1"
+            - name: TIMEOUT
+              value: "10"
+            - name: STATSD_HOST
+              value: prometheus-statsd-exporter
+            - name: STATSD_PORT
+              value: "9125"
+            - name: LOG_LEVEL
+              value: INFO
+          volumeMounts:
+          - name: configuration
+            mountPath: /etc/swh
+          - name: staticdata
+            mountPath: /srv/softwareheritage/counters
+      volumes:
+      - name: configuration
+        emptyDir: {}
+      - name: staticdata
+        emptyDir: {}
+      - name: configuration-template
+        configMap:
+          name: counters-rpc-configuration-template
+          items:
+          - key: "config.yml.template"
+            path: "config.yml.template"
+      - name: config-utils
+        configMap:
+          name: config-utils
+          defaultMode: 0555
+---
 # Source: swh/templates/graphql/deployment.yaml
 apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: graphql
   namespace: swh-cassandra-next-version
   labels:
     app: graphql
 spec:
   revisionHistoryLimit: 2
@@ -21097,20 +21304,43 @@
         emptyDir: {}
       - name: configuration-template
         configMap:
          name: web-configuration-template
          items:
          - key: "config.yml.template"
            path: "config.yml.template"
       - name: static
         emptyDir: {}
 ---
+# Source: swh/templates/counters/rpc-autoscale.yaml
+apiVersion: autoscaling/v2
+kind: HorizontalPodAutoscaler
+metadata:
+  namespace: swh-cassandra-next-version
+  name: counters-rpc
+  labels:
+    app: counters-rpc
+spec:
+  scaleTargetRef:
+    apiVersion: apps/v1
+    kind: Deployment
+    name: counters-rpc
+  minReplicas: 2
+  maxReplicas: 4
+  metrics:
+  - type: Resource
+    resource:
+      name: cpu
+      target:
+        type: Utilization
+        averageUtilization: 100
+---
 # Source: swh/templates/storage/autoscaling.yaml
 apiVersion: autoscaling/v2
 kind: HorizontalPodAutoscaler
 metadata:
   namespace: swh-cassandra-next-version
   name: storage-cassandra
   labels:
     app: storage-cassandra
 spec:
   scaleTargetRef:
@@ -21166,20 +21396,104 @@
   minReplicas: 1
   maxReplicas: 1
   metrics:
   - type: Resource
     resource:
       name: cpu
       target:
         type: Utilization
         averageUtilization: 1000
 ---
+# Source: swh/templates/counters/refresh-counters-cache-cronjob.yaml
+apiVersion: batch/v1
+kind: CronJob
+metadata:
+  name: counters-refresh-counters-cache-cronjob
+spec:
+  # By default, every 4h
+  schedule: "0 */1 * * *"
+  concurrencyPolicy: Forbid
+  jobTemplate:
+    spec:
+      template:
+        spec:
+          containers:
+            - name: counters-refresh-counters-cache
+              resources:
+                requests:
+                  memory: 512Mi
+                  cpu: 500m
+              image: container-registry.softwareheritage.org/swh/infra/swh-apps/counters:20231205.1
+              command:
+              - /cron/bin/refresh-counters-cache.sh
+              args:
+              - history.json
+              - static_history.json
+              env:
+                - name: STATSD_HOST
+                  value: prometheus-statsd-exporter
+                - name: STATSD_PORT
+                  value: "9125"
+                - name: SWH_CONFIG_FILENAME
+                  value: /etc/swh/config.yml
+                - name: LOG_LEVEL
+                  value: INFO
+              imagePullPolicy: IfNotPresent
+              volumeMounts:
+              - name: configuration
+                mountPath: /etc/swh
+              - name: script-utils
+                mountPath: /cron/bin/
+          volumes:
+          - name: configuration
+            emptyDir: {}
+          - name: configuration-template
+            configMap:
+              name: counters-refresh-counters-cache-configuration-template
+              items:
+              - key: "config.yml.template"
+                path: "config.yml.template"
+          - name: script-utils
+            configMap:
+              name: script-utils
+              defaultMode: 0555
+              items:
+              - key: "refresh-counters-cache.sh"
+                path: "refresh-counters-cache.sh"
+          restartPolicy: OnFailure
+---
+# Source: swh/templates/counters/rpc-ingress.yaml
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  namespace: swh-cassandra-next-version
+  name: counters-rpc-ingress-default
+  annotations:
+    nginx.ingress.kubernetes.io/proxy-body-size: 4G
+    nginx.ingress.kubernetes.io/proxy-connect-timeout: "90"
+    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
+    nginx.ingress.kubernetes.io/proxy-request-buffering: "on"
+    nginx.ingress.kubernetes.io/proxy-send-timeout: "90"
+
+spec:
+  rules:
+  - host: counters-rpc-ingress
+    http:
+      paths:
+      - path: /
+        pathType: Prefix
+        backend:
+          service:
+            name: counters-rpc
+            port:
+              number: 5011
+---
 # Source: swh/templates/graphql/ingress.yaml
 apiVersion: networking.k8s.io/v1
 kind: Ingress
 metadata:
   namespace: swh-cassandra-next-version
   name: graphql-ingress-default
   annotations:
     nginx.ingress.kubernetes.io/whitelist-source-range: 10.42.0.0/16,10.43.0.0/16,192.168.101.0/24,192.168.130.0/24,192.168.50.0/24
     nginx.ingress.kubernetes.io/rewrite-target: /



------------- diff for environment production namespace swh -------------

No differences


------------- diff for environment production namespace swh-cassandra -------------

No differences

Refs. swh/infra/sysadm-environment#5179 (closed)

Edited by Antoine R. Dumont

Merge request reports