// Copyright Istio Authors
//
// 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.

syntax = "proto3";

// $title: Kubernetes Env
// $description: Adapter that extracts information from a Kubernetes environment.
// $location: https://istio.io/docs/reference/config/policy-and-telemetry/adapters/kubernetesenv.html
// $supported_templates: kubernetes
// $aliases:
// $  - /docs/reference/config/adapters/kubernetesenv.html

// The `kubernetesenv` adapter extracts information from a Kubernetes environment
// and produces attributes that can be used in downstream adapters.
//
// This adapter supports the [kubernetes template](https://istio.io/docs/reference/config/policy-and-telemetry/templates/kubernetes/).
package adapter.kubernetesenv.config;

import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";

option go_package="config";
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = false;
option (gogoproto.gostring_all) = false;

// Configuration parameters for the kubernetes adapter. These params
// control the manner in which the kubernetes adapter discovers and
// generates values related to pod information.
//
// The adapter works by looking up pod information by UIDs (of the
// form: "kubernetes://pod.namespace"). It expects that the UIDs will be
// supplied in an input map for three distinct traffic classes (source,
// destination, and origin).
//
// For all valid UIDs supplied, this adapter generates output
// values containing information about the related pods.
message Params {

    reserved 3, 4, 5, 6;

    // File path to discover `kubeconfig`. For in-cluster configuration,
    // this should be left unset. For local configuration, this should
    // be set to the path of a `kubeconfig` file that can be used to
    // reach a kubernetes API server.
    //
    // NOTE: The `kubernetesenv` adapter will use the value of the `KUBECONFIG` environment variable
    // in the case where it is set (overriding any value configured
    // through this proto).
    //
    // Default: "" (unset)
    string kubeconfig_path = 1;

    // Controls the resync period of the Kubernetes cluster info cache.
    // The cache will watch for events and every so often completely resync.
    // This controls how frequently the complete resync occurs.
    //
    // Default: 5 minutes
    google.protobuf.Duration cache_refresh_duration = 2 [(gogoproto.nullable)=false,(gogoproto.stdduration) = true];

    // Namespace of the secret created for multicluster support.
    //
    // Details on multicluster and the Kubernetes secret required to
    // access the remote cluster's credentials can be found in
    // [multicluster install](https://istio.io/docs/setup/install/multicluster/).
    //
    // NOTE: If `cluster_registries_namespace` is not set then the environment
    // variable `POD_NAMESPACE` is checked/used. If `POD_NAMESPACE` is not
    // set then `cluster_registries_namespace` defaults to "istio-system".
    //
    // Default: "istio-system"
    string cluster_registries_namespace = 7;
}
