// Copyright 2017 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";

package adapter.kubernetes.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 a map of output
// values containing information about the related pods. The generated map
// is keyed by value names generated by concatenating a pod identifier
// prefix with a value name. For example, for the pod corresponding to a
// sourceUID and the output value of pod ip, this adapter will output a map
// that includes a key of "sourcePodIP" (assuming parameter defaults).
message Params {
    reserved 17;
    // next field id: 26

    // 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 kubernetes adapter will use the value of the env var
    // KUBECONFIG 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];

    // Configures how the UID for the source pod for traffic is identified
    // in the input map.
    //
    // Default: sourceUID
    string source_uid_input_name = 3;

    // Configures how the UID for the destination pod for traffic is identified
    // in the input map.
    //
    // Default: destinationUID
    string destination_uid_input_name = 4;

    // Configures how the UID for the origin pod for traffic is identified
    // in the input map.
    //
    // Default: originUID
    string origin_uid_input_name = 5;

    // Configures how the IP for the source pod for traffic is identified
    // in the input map.
    //
    // Default: sourceIP
    string source_ip_input_name = 20;

    // Configures how the IP for the destination pod for traffic is identified
    // in the input map.
    //
    // Default: destinationIP
    string destination_ip_input_name = 21;

    // Configures how the IP for the origin pod for traffic is identified
    // in the input map.
    //
    // Default: originIP
    string origin_ip_input_name = 23;

    // Configures the cluster domain name to use for service name normalization.
    //
    // Default: svc.cluster.local
    string cluster_domain_name = 18;

    // In order to extract the service associated with a source, destination, or
    // origin, this adapter relies on pod labels. In particular, it looks for
    // the value of a specific label, as specified by this parameter.
    //
    // Default: app
    string pod_label_for_service = 6;

    // In order to extract the service associated with a source, destination, or
    // origin, this adapter relies on pod labels. In particular, it looks for
    // the value of a specific label for istio component services, as specified 
    // by this parameter.
    //
    // Default: istio
    string pod_label_for_istio_component_service = 19;

    // The prefix used for source pod output value names.
    //
    // Default: source
    string source_prefix = 7;

    // The prefix used for destination pod output value names.
    //
    // Default: destination
    string destination_prefix = 8;

    // The prefix used for origin pod output value names.
    //
    // Default: origin
    string origin_prefix = 9;

    // The value name for the pod labels output value.
    //
    // Default: Labels
    string labels_value_name = 10;

    // The value name for the pod name output value.
    //
    // Default: PodName
    string pod_name_value_name = 11;

    // The value name for the pod ip address output value.
    //
    // Default: PodIP
    string pod_ip_value_name = 12;

    // The value name for the pod host ip address output value.
    //
    // Default: HostIP
    string host_ip_value_name = 13;

    // The value name for the pod namespace output value.
    //
    // Default: Namespace
    string namespace_value_name = 14;

    // The value name for the pod service account name output value.
    //
    // Default: ServiceAccountName
    string service_account_value_name = 15;

    // The value name for the service output value.
    //
    // Default: Service
    string service_value_name = 16;

    // Whether or not to execute source and origin value lookup
    // for Mixer requests when Istio ingress is the destination
    // service.
    //
    // Default: false
    bool lookup_ingress_source_and_origin_values = 24;

    // Istio ingress service string. This is used to identify the
    // ingress service in requests.
    //
    // Default: "ingress.istio-system.svc.cluster.local"
    string fully_qualified_istio_ingress_service_name = 25;
}
