# Copyright 2020 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.

# Define deployment and service for hydra.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hydra-ic
  labels:
    name: hydra-ic
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hydra-ic
      tier: web
  template:
    metadata:
      labels:
        app: hydra-ic
        tier: web
    spec:
      containers:
        - name: hydra-ic
          image: gcr.io/${YOUR_PROJECT_ID}/hcls-fa-gke-hydra-ic:latest
          ports:
            - containerPort: 4444
            - containerPort: 4445
          env:
            - name: URL
              value: https://${DOMAIN_FOR_IC}
            - name: DSN
              value: postgres://hydra:hydra@${PRIVATE_IP_OF_CLOUDSQL}/ic?sslmode=disable
          readinessProbe:
            httpGet:
              port: 4444
              path: /health/ready
---
apiVersion: v1
kind: Service
metadata:
  name: hydra-ic-service
  labels:
    app: hydra-ic
spec:
  type: NodePort
  selector:
    app: hydra-ic
    tier: web
  ports:
    - name: public
      port: 4444
      targetPort: 4444
    - name: admin
      port: 4445
      targetPort: 4445
