swh/production: deploy gogs lister
Related to swh/infra/sysadm-environment#4949 (closed)
> make helm-diff
Switched to branch 'production'
cd swh && ./helm-diff.sh
Comparing changes between branches production and gogs_lister...
Your branch is up to date with 'origin/production'.
Generate config in production branch for values/default.yaml...
Generate config in production branch for values/production-cassandra.yaml...
Generate config in production branch for values/production.yaml...
Generate config in production branch for values/staging-cassandra.yaml...
Generate config in production branch for values/staging.yaml...
Switched to branch 'gogs_lister'
Your branch is up to date with 'origin/gogs_lister'.
Generate config in gogs_lister branch for values/default.yaml...
Generate config in gogs_lister branch for values/production-cassandra.yaml...
Generate config in gogs_lister branch for values/production.yaml...
Generate config in gogs_lister branch for values/staging-cassandra.yaml...
Generate config in gogs_lister branch for values/staging.yaml...
------------- diff for values/default.yaml -------------
No differences
------------- diff for values/production-cassandra.yaml -------------
No differences
------------- diff for values/production.yaml -------------
--- /tmp/swh-chart.uc53sykV/production.yaml.before 2023-06-22 12:27:39.841642317 +0200
+++ /tmp/swh-chart.uc53sykV/production.yaml.after 2023-06-22 12:27:40.117646854 +0200
@@ -78,20 +78,117 @@
fi
# Set useJsonLogger to false to let the logs be plain text
---
# Source: swh/templates/listers/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
+ name: lister-gogs-full-template
+ namespace: swh
+data:
+ config.yml.template: |
+ storage:
+ cls: pipeline
+ steps:
+ - cls: retry
+ - cls: remote
+ url: http://saam.internal.softwareheritage.org:5002
+
+ scheduler:
+ cls: remote
+ url: http://saatchi.internal.softwareheritage.org:5008/
+
+ celery:
+ task_broker: amqp://${AMQP_USERNAME}:${AMQP_PASSWORD}@rabbitmq.internal.softwareheritage.org:/
+ task_acks_late: true
+ task_queues:
+ - swh.lister.gogs.tasks.FullGogsRelister
+ sentry_settings_for_celery_tasks:
+ __sentry-settings-for-celery-tasks__
+ credentials:
+ __lister-credentials__
+ init-container-entrypoint.sh: |
+ #!/bin/bash
+
+ set -e
+
+ CONFIG_FILE=/etc/swh/config.yml
+ CONFIG_FILE_WIP=/tmp/wip-config.yml
+
+ # substitute environment variables when creating the default config.yml
+ eval echo \""$(</etc/swh/configuration-template/config.yml.template)"\" \
+ > $CONFIG_FILE
+
+ SENTRY_SETTINGS_PATH=/etc/credentials/sentry-settings/sentry_settings_for_celery_tasks
+ if [ -f $SENTRY_SETTINGS_PATH ]; then
+ awk "/__sentry-settings-for-celery-tasks__/{system(\"sed 's/^/ /g' $SENTRY_SETTINGS_PATH\");next}1" $CONFIG_FILE > $CONFIG_FILE_WIP
+ mv $CONFIG_FILE_WIP $CONFIG_FILE
+ else
+ sed -i '/__sentry-settings-for-celery-tasks__//g' $CONFIG_FILE
+ fi
+
+ CREDS_LISTER_PATH=/etc/credentials/listers/credentials
+ if [ -f $CREDS_LISTER_PATH ]; then
+ awk "/__lister-credentials__/{system(\"sed 's/^/ /g' $CREDS_LISTER_PATH\");next}1" $CONFIG_FILE > $CONFIG_FILE_WIP
+ mv $CONFIG_FILE_WIP $CONFIG_FILE
+ else
+ sed -i '/__lister-credentials__//g' $CONFIG_FILE
+ fi
+
+ exit 0
+
+
+ logging-configuration.yml: |
+ version: 1
+
+ handlers:
+ console:
+ class: logging.StreamHandler
+ formatter: json
+ stream: ext://sys.stdout
+
+ formatters:
+ json:
+ class: pythonjsonlogger.jsonlogger.JsonFormatter
+ # python-json-logger parses the format argument to get the variables it actually expands into the json
+ format: "%(asctime)s:%(threadName)s:%(pathname)s:%(lineno)s:%(funcName)s:%(task_name)s:%(task_id)s:%(name)s:%(levelname)s:%(message)s"
+
+ loggers:
+ celery:
+ level: "INFO"
+ amqp:
+ level: WARNING
+ urllib3:
+ level: WARNING
+ azure.core.pipeline.policies.http_logging_policy:
+ level: WARNING
+ swh:
+ level: "INFO"
+ celery.task:
+ level: "INFO"
+
+ root:
+ level: "INFO"
+ handlers:
+ - console
+
+
+
+# Set useJsonLogger to false to let the logs be plain text
+---
+# Source: swh/templates/listers/configmap.yaml
+apiVersion: v1
+kind: ConfigMap
+metadata:
name: lister-pubdev-template
namespace: swh
data:
config.yml.template: |
storage:
cls: pipeline
steps:
- cls: retry
- cls: remote
url: http://saam.internal.softwareheritage.org:5002
@@ -1129,40 +1226,201 @@
volumes:
- name: config
configMap:
name: graphql
defaultMode: 0444
---
# Source: swh/templates/listers/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
+ name: lister-gogs-full
+ namespace: swh
+ labels:
+ app: lister-gogs-full
+spec:
+ revisionHistoryLimit: 2
+ selector:
+ matchLabels:
+ app: lister-gogs-full
+ strategy:
+ type: RollingUpdate
+ rollingUpdate:
+ maxSurge: 1
+ template:
+ metadata:
+ labels:
+ app: lister-gogs-full
+ annotations:
+ # Force a rollout upgrade if the configuration changes
+ checksum/config: 3c06f74096f96c0fec96555c35dedc95650341cce669251f3a2d531e66e09fcc
+ spec:
+ affinity:
+
+ nodeAffinity:
+ requiredDuringSchedulingIgnoredDuringExecution:
+ nodeSelectorTerms:
+ - matchExpressions:
+ - key: swh/lister
+ operator: In
+ values:
+ - "true"
+ initContainers:
+ - name: prepare-configuration
+ image: debian:bullseye
+ imagePullPolicy: Always
+ env:
+ - name: AMQP_USERNAME
+ valueFrom:
+ secretKeyRef:
+ name: common-secrets
+ key: rabbitmq-amqp-username
+ # 'name' secret must exist & include that ^ key
+ optional: false
+ - name: AMQP_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: common-secrets
+ key: rabbitmq-amqp-password
+ # 'name' secret must exist & include that ^ key
+ optional: false
+ command:
+ - /entrypoint.sh
+ volumeMounts:
+ - name: configuration-template
+ mountPath: /entrypoint.sh
+ subPath: "init-container-entrypoint.sh"
+ readOnly: true
+ - name: configuration
+ mountPath: /etc/swh
+ - name: configuration-template
+ mountPath: /etc/swh/configuration-template
+ - name: lister-credentials-secrets
+ mountPath: /etc/credentials/listers
+ readOnly: true
+ - name: sentry-settings-for-celery-tasks
+ mountPath: /etc/credentials/sentry-settings
+ readOnly: true
+ containers:
+ - name: listers
+ resources:
+ requests:
+ memory: 256Mi
+ cpu: 250m
+ image: container-registry.softwareheritage.org/swh/infra/swh-apps/lister:20230608.2
+ imagePullPolicy: Always
+ command:
+ - /bin/bash
+ args:
+ - -c
+ - /opt/swh/entrypoint.sh
+ lifecycle:
+ preStop:
+ exec:
+ command: ["/pre-stop.sh"]
+ env:
+ - name: STATSD_HOST
+ value: prometheus-statsd-exporter
+ - name: STATSD_PORT
+ value: "9125"
+ - name: MAX_TASKS_PER_CHILD
+ value: "1"
+ - name: LOGLEVEL
+ value: "INFO"
+ - name: SWH_CONFIG_FILENAME
+ value: /etc/swh/config.yml
+
+ - name: SWH_LOG_CONFIG
+ value: /etc/swh/logging-configuration.yml
+
+ - name: SWH_SENTRY_ENVIRONMENT
+ value: production
+ volumeMounts:
+ - name: lister-utils
+ mountPath: /pre-stop.sh
+ subPath: "pre-stop.sh"
+ - name: configuration
+ mountPath: /etc/swh
+
+ - name: configuration-template
+ mountPath: /etc/swh/logging-configuration.yml
+ subPath: "logging-configuration.yml"
+ readOnly: true
+
+ volumes:
+ - name: configuration
+ ephemeral:
+ volumeClaimTemplate:
+ metadata:
+ labels:
+ type: ephemeral-volume
+ spec:
+ accessModes:
+ - ReadWriteOnce
+ resources:
+ requests:
+ storage: 100Gi
+ storageClassName: local-path
+ - name: configuration-template
+ configMap:
+ name: lister-gogs-full-template
+ defaultMode: 0777
+ items:
+ - key: "config.yml.template"
+ path: "config.yml.template"
+ - key: "init-container-entrypoint.sh"
+ path: "init-container-entrypoint.sh"
+
+ - key: "logging-configuration.yml"
+ path: "logging-configuration.yml"
+
+ - name: lister-utils
+ configMap:
+ name: lister-utils
+ defaultMode: 0777
+ items:
+ - key: "pre-stop-idempotent.sh"
+ path: "pre-stop.sh"
+ - name: lister-credentials-secrets
+ secret:
+ secretName: lister-credentials-secrets
+ optional: true
+ - name: sentry-settings-for-celery-tasks
+ secret:
+ secretName: sentry-settings-for-celery-tasks
+ optional: true
+# Set useJsonLogger to false to let the logs be plain text
+---
+# Source: swh/templates/listers/deployment.yaml
+apiVersion: apps/v1
+kind: Deployment
+metadata:
name: lister-pubdev
namespace: swh
labels:
app: lister-pubdev
spec:
revisionHistoryLimit: 2
selector:
matchLabels:
app: lister-pubdev
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
template:
metadata:
labels:
app: lister-pubdev
annotations:
# Force a rollout upgrade if the configuration changes
- checksum/config: f9dabb7a231715f1b4a0ad6e1e5c5e20c1dd27c970b5a4949ca8a11414da2efc
+ checksum/config: 3c06f74096f96c0fec96555c35dedc95650341cce669251f3a2d531e66e09fcc
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: swh/lister
operator: In
values:
@@ -2550,20 +2808,60 @@
---
# Source: swh/templates/loaders/deployment.yaml
# if defined at the "typed" loader level
# otherwise use the global image is defined First this needs to replace - in
# $loader_type with "" to find the proper image name.
---
# Source: swh/templates/listers/keda-autoscaling.yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
+ name: lister-gogs-full-operators
+ namespace: swh
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1 # Optional. Default: apps/v1
+ kind: Deployment # Optional. Default: Deployment
+ # Mandatory. Must be in same namespace as ScaledObject
+ name: lister-gogs-full
+ # envSourceContainerName: {container-name} # Optional. Default:
+ # .spec.template.spec.containers[0]
+ pollingInterval: 30 # Optional. Default: 30 seconds
+ cooldownPeriod: 3600 # Optional. Default: 300 seconds
+ idleReplicaCount: 0 # Optional. Must be less than
+ # minReplicaCount
+ minReplicaCount: 0
+ maxReplicaCount: 1
+ triggers:
+ - type: rabbitmq
+ authenticationRef:
+ name: amqp-authentication-lister-gogs-full
+ metadata:
+ protocol: auto # Optional. Specifies protocol to use,
+ # either amqp or http, or auto to
+ # autodetect based on the `host` value.
+ # Default value is auto.
+ mode: QueueLength # QueueLength to trigger on number of msgs in queue
+ excludeUnacknowledged: "false" # QueueLength should include unacked messages
+ # Implies "http" protocol is used
+ value: "1"
+ queueName: swh.lister.gogs.tasks.FullGogsRelister
+ vhostName: / # Optional. If not specified, use the vhost in the
+ # `host` connection string. Alternatively, you can
+ # use existing environment variables to read
+ # configuration from: See details in "Parameter
+ # list" section hostFromEnv: RABBITMQ_HOST%
+---
+# Source: swh/templates/listers/keda-autoscaling.yaml
+apiVersion: keda.sh/v1alpha1
+kind: ScaledObject
+metadata:
name: lister-pubdev-operators
namespace: swh
spec:
scaleTargetRef:
apiVersion: apps/v1 # Optional. Default: apps/v1
kind: Deployment # Optional. Default: Deployment
# Mandatory. Must be in same namespace as ScaledObject
name: lister-pubdev
# envSourceContainerName: {container-name} # Optional. Default:
# .spec.template.spec.containers[0]
@@ -3006,20 +3304,32 @@
selector:
matchLabels:
app: prometheus-statsd-exporter
namespaceSelector:
any: true
---
# Source: swh/templates/listers/keda-autoscaling.yaml
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
+ name: amqp-authentication-lister-gogs-full
+ namespace: swh
+spec:
+ secretTargetRef:
+ - parameter: host # "host" is required by the scalerObject trigger metadata
+ name: common-secrets
+ key: rabbitmq-http-host
+---
+# Source: swh/templates/listers/keda-autoscaling.yaml
+apiVersion: keda.sh/v1alpha1
+kind: TriggerAuthentication
+metadata:
name: amqp-authentication-lister-pubdev
namespace: swh
spec:
secretTargetRef:
- parameter: host # "host" is required by the scalerObject trigger metadata
name: common-secrets
key: rabbitmq-http-host
---
# Source: swh/templates/loader-metadata/keda-secrets.yaml
apiVersion: keda.sh/v1alpha1
------------- diff for values/staging-cassandra.yaml -------------
No differences
------------- diff for values/staging.yaml -------------
No differences