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

# Obtain client TLS certificates for the host (developer workstation)
# by launching a pod with workload TLS cerificates, copying them from the pod to the host,
# and then shutting down the pod.

# Kustomize paths are relative to the `grpc-xds` directory. Use the `make copy-certs` target.

apiVersion: skaffold/v3
kind: Config
metadata:
  name: host-certs
  annotations:
    config.kubernetes.io/local-config: "true"
build: {} # No images to build.
deploy:
  kubectl:
    defaultNamespace: host-certs
    hooks:
      after:
      - host:
          command: ["k8s/host-certs/copy-certs.sh", "certs"]
manifests:
  kustomize:
    buildArgs: ["--load-restrictor=LoadRestrictionsNone"]
    paths: ["k8s/host-certs/base"]
profiles:
- name: tls-cert-manager
  activation:
  - kubeContext: kind.*
  manifests:
    kustomize:
      buildArgs: ["--load-restrictor=LoadRestrictionsNone"]
      paths: ["k8s/host-certs/overlays/tls-cert-manager"]
- name: tls-gke-workload-certs
  activation:
  - kubeContext: gke.*
  manifests:
    kustomize:
      buildArgs: ["--load-restrictor=LoadRestrictionsNone"]
      paths: ["k8s/host-certs/overlays/tls-gke-workload-certs"]
