# Copyright 2021 Team Special Weekend
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dashboard-server-deployment
spec:
  selector:
    matchLabels:
      app: dashboard-server
  replicas: 3
  template:
    metadata:
      labels:
        app: dashboard-server
    spec:
      serviceAccountName: dashboard-sa
      containers:
        - name: dashboard-server
          image: gcr.io/special-weekend-2021/dashboard-server:latest
          imagePullPolicy: Always
          args:
            - '--ui_server=http://ui-server.default.svc.cluster.local'
          envFrom:
            - secretRef:
                name: icfpc
            - secretRef:
                name: cloudsql-secret
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8080
            initialDelaySeconds: 3
            periodSeconds: 3
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8080
            initialDelaySeconds: 3
            periodSeconds: 3
          ports:
            - name: http
              containerPort: 8080
          resources:
            requests:
              memory: "64Mi"
              cpu: "250m"
            limits:
              memory: "512Mi"
              cpu: "500m"
        - name: cloud-sql-proxy
          image: gcr.io/cloudsql-docker/gce-proxy:1.17
          command:
            - "/cloud_sql_proxy"
            - "-instances=special-weekend-2021:asia-east1:flex=tcp:3306"
          securityContext:
            runAsNonRoot: true
          resources:
            requests:
              memory: "2Gi"
              cpu:    "1"
