apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-account
  labels:
    app: nowchess-account
spec:
  selector:
    matchLabels:
      app: nowchess-account
  template:
    metadata:
      labels:
        app: nowchess-account
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8083"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-account
          image: ghcr.io/now-chess/now-chess-systems/account:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: REDIS_HOST
              value: redis-master.redis.svc.cluster.local
            - name: REDIS_PORT
              value: "6379"
            - name: CORE_SERVICE_URL
              value: http://nowchess-core-active:8080
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: ACCOUNT_DB_USER
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: ACCOUNT_DB_PASSWORD
            - name: DB_URL
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: ACCOUNT_DB_URL
            - name: JWT_PUBLIC_KEY_PATH
              value: /secrets/jwt/public.pem
            - name: JWT_PRIVATE_KEY_PATH
              value: /secrets/jwt/private.pem
          volumeMounts:
            - name: jwt-keys
              mountPath: /secrets/jwt
              readOnly: true
          ports:
            - containerPort: 8083
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8083
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8083
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
      volumes:
        - name: jwt-keys
          secret:
            secretName: ncs-jwt-keys
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-account-active
      previewService: nowchess-account-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-bot-platform
  labels:
    app: nowchess-bot-platform
spec:
  selector:
    matchLabels:
      app: nowchess-bot-platform
  template:
    metadata:
      labels:
        app: nowchess-bot-platform
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8087"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-bot-platform
          image: ghcr.io/now-chess/now-chess-systems/bot-platform:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: REDIS_HOST
              value: redis-master.redis.svc.cluster.local
            - name: REDIS_PORT
              value: "6379"
          ports:
            - containerPort: 8087
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8087
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8087
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-bot-platform-active
      previewService: nowchess-bot-platform-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-coordinator
  labels:
    app: nowchess-coordinator
spec:
  selector:
    matchLabels:
      app: nowchess-coordinator
  template:
    metadata:
      labels:
        app: nowchess-coordinator
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8086"
    spec:
      serviceAccountName: default
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-coordinator
          image: ghcr.io/now-chess/now-chess-systems/coordinator:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: NOWCHESS_COORDINATOR_K8S_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: REDIS_HOST
              value: redis-master.redis.svc.cluster.local
            - name: REDIS_PORT
              value: "6379"
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
          ports:
            - containerPort: 8086
              name: http
              protocol: TCP
            - containerPort: 9086
              name: grpc
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8086
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8086
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "20m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-coordinator-active
      previewService: nowchess-coordinator-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-core
  labels:
    app: nowchess-core
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nowchess-core
  template:
    metadata:
      labels:
        app: nowchess-core
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "q/metrics"
        k8s.grafana.com/metrics_portNumber: "8080"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-core
          image: ghcr.io/now-chess/now-chess-systems/core:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: REDIS_HOST
              value: redis-master.redis.svc.cluster.local
            - name: REDIS_PORT
              value: "6379"
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
            - name: JWT_PUBLIC_KEY_PATH
              value: /secrets/jwt/public.pem
            - name: RULE_SERVICE_HOST
              value: nowchess-rule-active
            - name: RULE_SERVICE_GRPC_PORT
              value: "8082"
            - name: RULE_SERVICE_URL
              value: http://nowchess-rule-active:8082
            - name: IO_SERVICE_HOST
              value: nowchess-io-active
            - name: IO_SERVICE_GRPC_PORT
              value: "8081"
            - name: IO_SERVICE_URL
              value: http://nowchess-io-active:8081
            - name: COORDINATOR_SERVICE_HOST
              value: nowchess-coordinator-active
            - name: COORDINATOR_SERVICE_GRPC_PORT
              value: "9086"
            - name: STORE_SERVICE_URL
              value: http://nowchess-store-active:8085
          volumeMounts:
            - name: jwt-keys
              mountPath: /secrets/jwt
              readOnly: true
          ports:
            - containerPort: 8080
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8080
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8080
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "15m"
              memory: "256Mi"
            limits:
              cpu: "1000m"
              memory: "512Mi"
      volumes:
        - name: jwt-keys
          secret:
            secretName: ncs-jwt-keys
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-core-active
      previewService: nowchess-core-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-io
  labels:
    app: nowchess-io
spec:
  selector:
    matchLabels:
      app: nowchess-io
  template:
    metadata:
      labels:
        app: nowchess-io
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8081"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-io
          image: ghcr.io/now-chess/now-chess-systems/io:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
          ports:
            - containerPort: 8081
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8081
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8081
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-io-active
      previewService: nowchess-io-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-official-bots
  labels:
    app: nowchess-official-bots
spec:
  selector:
    matchLabels:
      app: nowchess-official-bots
  template:
    metadata:
      labels:
        app: nowchess-official-bots
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8088"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-official-bots
          image: ghcr.io/now-chess/now-chess-systems/official-bots:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: REDIS_HOST
              value: redis-master.redis.svc.cluster.local
            - name: REDIS_PORT
              value: "6379"
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
            - name: ACCOUNT_SERVICE_URL
              value: http://nowchess-account:8083
            - name: MP_JWT_VERIFY_PUBLICKEY_LOCATION
              value: /secrets/jwt/public.pem
            - name: MP_JWT_VERIFY_ISSUER
              value: nowchess
          volumeMounts:
            - name: jwt-keys
              mountPath: /secrets/jwt
              readOnly: true
          ports:
            - containerPort: 8088
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8088
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8088
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
      volumes:
        - name: jwt-keys
          secret:
            secretName: ncs-jwt-keys
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-official-bots-active
      previewService: nowchess-official-bots-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-rule
  labels:
    app: nowchess-rule
spec:
  selector:
    matchLabels:
      app: nowchess-rule
  template:
    metadata:
      labels:
        app: nowchess-rule
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8082"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-rule
          image: ghcr.io/now-chess/now-chess-systems/rule:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
          ports:
            - containerPort: 8082
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8082
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8082
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
  strategy:
    blueGreen:
      activeService: nowchess-rule-active
      previewService: nowchess-rule-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-store
  labels:
    app: nowchess-store
spec:
  selector:
    matchLabels:
      app: nowchess-store
  template:
    metadata:
      labels:
        app: nowchess-store
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8085"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-store
          image: ghcr.io/now-chess/now-chess-systems/store:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: REDIS_HOST
              value: redis-master.redis.svc.cluster.local
            - name: REDIS_PORT
              value: "6379"
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: STORE_DB_USER
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: STORE_DB_PASSWORD
            - name: DB_URL
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: STORE_DB_URL
          ports:
            - containerPort: 8085
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8085
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8085
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-store-active
      previewService: nowchess-store-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-ws
  labels:
    app: nowchess-ws
spec:
  selector:
    matchLabels:
      app: nowchess-ws
  template:
    metadata:
      labels:
        app: nowchess-ws
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8084"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-ws
          image: ghcr.io/now-chess/now-chess-systems/ws:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: REDIS_HOST
              value: redis-master.redis.svc.cluster.local
            - name: REDIS_PORT
              value: "6379"
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
            - name: JWT_PUBLIC_KEY_PATH
              value: /secrets/jwt/public.pem
          volumeMounts:
            - name: jwt-keys
              mountPath: /secrets/jwt
              readOnly: true
          ports:
            - containerPort: 8084
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8084
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8084
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "48Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
      volumes:
        - name: jwt-keys
          secret:
            secretName: ncs-jwt-keys
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-ws-active
      previewService: nowchess-ws-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-frontend
  labels:
    app: nowchess-ws
spec:
  selector:
    matchLabels:
      app: nowchess-frontend
  template:
    metadata:
      labels:
        app: nowchess-frontend
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-frontend
          image: ghcr.io/now-chess/now-chess-systems/frontend:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-frontend-env-config
          ports:
            - containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 10
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 5
          resources:
            requests:
              cpu: "10m"
              memory: "64Mi"
            limits:
              cpu: "100m"
              memory: "96Mi"
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-frontend-active
      previewService: nowchess-frontend-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-analysis
  labels:
    app: nowchess-analysis
    app.kubernetes.io/name: nowchess-analysis
    app.kubernetes.io/part-of: nowchess
spec:
  selector:
    matchLabels:
      app: nowchess-analysis
  template:
    metadata:
      labels:
        app: nowchess-analysis
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8087"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-analysis
          image: ghcr.io/now-chess/now-chess-systems/analysis:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
          ports:
            - containerPort: 8087
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8087
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8087
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-analysis-active
      previewService: nowchess-analysis-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nowchess-tournament
  labels:
    app: nowchess-tournament
spec:
  selector:
    matchLabels:
      app: nowchess-tournament
  template:
    metadata:
      labels:
        app: nowchess-tournament
      annotations:
        k8s.grafana.com/scrape: "true"
        k8s.grafana.com/metrics_path: "/q/metrics"
        k8s.grafana.com/metrics_portNumber: "8088"
    spec:
      imagePullSecrets:
        - name: ghcr-pull-secret
      containers:
        - name: nowchess-tournament
          image: ghcr.io/now-chess/now-chess-systems/tournament:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: nowchess-env-config
          env:
            - name: REDIS_HOST
              value: redis-master.redis.svc.cluster.local
            - name: REDIS_PORT
              value: "6379"
            - name: INTERNAL_SECRET
              valueFrom:
                secretKeyRef:
                  name: ncs-internal-secret
                  key: INTERNAL_SECRET
            - name: QUARKUS_REST_CLIENT_CORE_SERVICE_URL
              value: http://nowchess-core-active:8080
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: ACCOUNT_DB_USER
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: ACCOUNT_DB_PASSWORD
            - name: DB_URL
              valueFrom:
                secretKeyRef:
                  name: ncs-db-secrets
                  key: ACCOUNT_DB_URL
            - name: MP_JWT_VERIFY_PUBLICKEY_LOCATION
              value: /secrets/jwt/public.pem
          volumeMounts:
            - name: jwt-keys
              mountPath: /secrets/jwt
              readOnly: true
          ports:
            - containerPort: 8088
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /q/health/live
              port: 8088
            initialDelaySeconds: 0
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /q/health/ready
              port: 8088
            initialDelaySeconds: 0
            periodSeconds: 5
          resources:
            requests:
              cpu: "5m"
              memory: "96Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
      volumes:
        - name: jwt-keys
          secret:
            secretName: ncs-jwt-keys
  rollbackWindow:
    revisions: 3
  strategy:
    blueGreen:
      activeService: nowchess-tournament-active
      previewService: nowchess-tournament-preview
      autoPromotionEnabled: true
      previewReplicaCount: 1
