Ctrl K
ComunidadGuías…

helm/templates/console.yaml

Rama newjitsu · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
{{- if gt (int .Values.scaling.console.replicas) 0 }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: console
  labels:
    {{- include "jitsu-dev.labels" . | nindent 4 }}
    app.kubernetes.io/name: console
spec:
  replicas: {{ .Values.scaling.console.replicas }}
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: console
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: console
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
        - name: console
          image: node:24-bookworm
          workingDir: /cache/workspace/webapps/console
          command:
            - sh
            - -c
            - |
              apt-get update -qq && apt-get install -y -qq rsync > /dev/null 2>&1

              # Background rsync: every 2s, sync only actually changed files
              (while true; do
                sleep 2
                rsync -a --checksum \
                  --exclude='node_modules' --exclude='.next' --exclude='.turbo' \
                  --exclude='docker/data' --exclude='*.log' \
                  /project/webapps/ /cache/workspace/webapps/
                rsync -a --checksum \
                  --exclude='node_modules' \
                  /project/libs/ /cache/workspace/libs/
                rsync -a --checksum \
                  --exclude='node_modules' \
                  /project/types/ /cache/workspace/types/
              done) &

              cd /cache/workspace/webapps/console
              # On a fresh install the db-push job may still be applying the
              # schema — retry seed until it succeeds instead of silently
              # starting without a seeded admin user.
              until npx tsx scripts/manage.ts seed; do
                echo "seed failed (database schema not ready yet?), retrying in 5s..."
                sleep 5
              done
              # Create the events-log ClickHouse tables (powers Live Events).
              # Nothing else runs this in the dev chart — in prod the
              # admin/events-log-init route does. Best-effort: retry a few times
              # for a not-yet-ready ClickHouse, then continue so a disabled or
              # broken ClickHouse can't wedge console startup.
              for i in $(seq 1 12); do
                npx tsx scripts/manage.ts events-log-init && break
                echo "events-log-init failed (clickhouse not ready yet?), retry $i/12 in 5s..."
                sleep 5
              done
              exec npx next dev -H 0.0.0.0 -p 3000
          ports:
            - name: http
              containerPort: 3000
              protocol: TCP
          envFrom:
            - secretRef:
                name: jitsu-secrets
            # Connection URLs of the in-cluster dependencies (helm-deps chart).
            # Listed after jitsu-secrets so its keys win over any legacy URL
            # keys there; explicit env entries below still take precedence.
            - secretRef:
                name: jitsu-deps-urls
                optional: true
          env:
            # Empty *_PORT entries override K8s-injected service-link vars
            # (tcp://...) that break zod number coercion.
            # MAINTENANCE_CONFIG_FILE: maintenance descriptor mounted from
            # `jitsu-console-maintenance` (optional ConfigMap, key
            # `maintenance.json`). Manage via
            # webapps/console/scripts/maintenance-mode.sh.
            {{- include "jitsu-dev.env" (dict "ctx" . "service" "console"
                  "extra" (dict
                    "BULKER_PORT" ""
                    "ROTOR_PORT" ""
                    "SYNCCTL_PORT" ""
                    "INGMGR_PORT" ""
                    "MAINTENANCE_CONFIG_FILE" "/etc/jitsu/maintenance/maintenance.json")) | nindent 12 }}
          volumeMounts:
            - name: project
              mountPath: /project
              readOnly: true
            - name: node-cache
              mountPath: /cache
            - name: maintenance
              mountPath: /etc/jitsu/maintenance
              readOnly: true
          livenessProbe:
            httpGet:
              path: /api/healthcheck
              port: http
            initialDelaySeconds: 120
            periodSeconds: 15
            timeoutSeconds: 10
          readinessProbe:
            httpGet:
              path: /api/healthcheck
              port: http
            initialDelaySeconds: 60
            periodSeconds: 10
            timeoutSeconds: 10
          startupProbe:
            httpGet:
              path: /api/healthcheck
              port: http
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 10
            failureThreshold: 30
      volumes:
        - name: project
          hostPath:
            path: {{ include "jitsu-dev.projectRoot" . }}
            type: Directory
        - name: node-cache
          persistentVolumeClaim:
            claimName: node-cache
        # `optional: true` so the pod boots cleanly when no maintenance window
        # is configured (the volume mounts as an empty dir; missing config
        # file → load() returns "no maintenance"). Create the CM via
        # `webapps/console/scripts/maintenance-mode.sh start` to enable
        # maintenance — propagates to running pods within ~1min via kubelet
        # sync; no restart needed.
        - name: maintenance
          configMap:
            name: jitsu-console-maintenance
            optional: true
---
apiVersion: v1
kind: Service
metadata:
  name: console
  labels:
    {{- include "jitsu-dev.labels" . | nindent 4 }}
    app.kubernetes.io/name: console
spec:
  type: LoadBalancer
  ports:
    - port: 3000
      targetPort: http
      protocol: TCP
      name: http
  selector:
    app.kubernetes.io/name: console
    app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}