# Copyright 2023 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
#
#      https://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.

resources:
  - namespace.yaml
  - frontend.yaml
  - grafana.yaml
  - ingress.yaml
  - custom-stackdriver-metrics-adapter.yaml
  - kube-state-metrics.yaml
configMapGenerator:
- name: k8s-grafana-dashboards
  namespace: monitoring
  options:
    disableNameSuffixHash: true
  files:
  - dashboards/k8s-global.json
  - dashboards/k8s-namespaces.json
  - dashboards/k8s-nodes.json
  - dashboards/k8s-pods.json
- name: locust-grafana-dashboards
  namespace: monitoring
  options:
    disableNameSuffixHash: true
  files:
  - dashboards/locust.json
- name: nginx-grafana-dashboards
  namespace: monitoring
  options:
    disableNameSuffixHash: true
  files:
  - dashboards/nginx.json  
patches:
  - target:
      version: v1
      kind: ServiceAccount
      name: frontend
      namespace: monitoring
    patch: |-
      - op: add
        path: /metadata/annotations/iam.gke.io~1gcp-service-account
        value: sa-monitoring@{{ project_id }}.iam.gserviceaccount.com
  - target:
      version: v1
      kind: ServiceAccount
      name: custom-metrics-stackdriver-adapter
      namespace: monitoring
    patch: |-
      - op: add
        path: /metadata/annotations/iam.gke.io~1gcp-service-account
        value: sa-monitoring@{{ project_id }}.iam.gserviceaccount.com        
  - target:
      group: apps
      version: v1
      kind: Deployment
      name: frontend
      namespace: monitoring
    patch: |-
      - op: add
        path: /spec/template/spec/containers/0/args/-
        value: "--query.project-id={{ project_id }}"