github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/kubecontrollersconfig.go (about)

     1  // Copyright (c) 2020-2021 Tigera, Inc. All rights reserved.
     2  
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package v3
    16  
    17  import (
    18  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    19  )
    20  
    21  const (
    22  	KindKubeControllersConfiguration     = "KubeControllersConfiguration"
    23  	KindKubeControllersConfigurationList = "KubeControllersConfigurationList"
    24  )
    25  
    26  // +genclient:nonNamespaced
    27  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    28  
    29  // KubeControllersConfigurationList contains a list of KubeControllersConfiguration object.
    30  type KubeControllersConfigurationList struct {
    31  	metav1.TypeMeta `json:",inline"`
    32  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    33  
    34  	Items []KubeControllersConfiguration `json:"items" protobuf:"bytes,2,rep,name=items"`
    35  }
    36  
    37  // +genclient
    38  // +genclient:nonNamespaced
    39  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    40  
    41  type KubeControllersConfiguration struct {
    42  	metav1.TypeMeta   `json:",inline"`
    43  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    44  
    45  	Spec   KubeControllersConfigurationSpec   `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    46  	Status KubeControllersConfigurationStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
    47  }
    48  
    49  // KubeControllersConfigurationSpec contains the values of the Kubernetes controllers configuration.
    50  type KubeControllersConfigurationSpec struct {
    51  	// LogSeverityScreen is the log severity above which logs are sent to the stdout. [Default: Info]
    52  	LogSeverityScreen string `json:"logSeverityScreen,omitempty" validate:"omitempty,logLevel"`
    53  
    54  	// HealthChecks enables or disables support for health checks [Default: Enabled]
    55  	HealthChecks string `json:"healthChecks,omitempty" validate:"omitempty,oneof=Enabled Disabled"`
    56  
    57  	// EtcdV3CompactionPeriod is the period between etcdv3 compaction requests. Set to 0 to disable. [Default: 10m]
    58  	EtcdV3CompactionPeriod *metav1.Duration `json:"etcdV3CompactionPeriod,omitempty" validate:"omitempty"`
    59  
    60  	// PrometheusMetricsPort is the TCP port that the Prometheus metrics server should bind to. Set to 0 to disable. [Default: 9094]
    61  	PrometheusMetricsPort *int `json:"prometheusMetricsPort,omitempty"`
    62  
    63  	// Controllers enables and configures individual Kubernetes controllers
    64  	Controllers ControllersConfig `json:"controllers"`
    65  
    66  	// DebugProfilePort configures the port to serve memory and cpu profiles on. If not specified, profiling
    67  	// is disabled.
    68  	DebugProfilePort *int32 `json:"debugProfilePort,omitempty"`
    69  }
    70  
    71  // ControllersConfig enables and configures individual Kubernetes controllers
    72  type ControllersConfig struct {
    73  	// Node enables and configures the node controller. Enabled by default, set to nil to disable.
    74  	Node *NodeControllerConfig `json:"node,omitempty"`
    75  
    76  	// Policy enables and configures the policy controller. Enabled by default, set to nil to disable.
    77  	Policy *PolicyControllerConfig `json:"policy,omitempty"`
    78  
    79  	// WorkloadEndpoint enables and configures the workload endpoint controller. Enabled by default, set to nil to disable.
    80  	WorkloadEndpoint *WorkloadEndpointControllerConfig `json:"workloadEndpoint,omitempty"`
    81  
    82  	// ServiceAccount enables and configures the service account controller. Enabled by default, set to nil to disable.
    83  	ServiceAccount *ServiceAccountControllerConfig `json:"serviceAccount,omitempty"`
    84  
    85  	// Namespace enables and configures the namespace controller. Enabled by default, set to nil to disable.
    86  	Namespace *NamespaceControllerConfig `json:"namespace,omitempty"`
    87  
    88  	// FederatedServices enables and configures the federatedservices controller. Disabled by default.
    89  	FederatedServices *FederatedServicesControllerConfig `json:"federatedServices,omitempty"`
    90  }
    91  
    92  // NodeControllerConfig configures the node controller, which automatically cleans up configuration
    93  // for nodes that no longer exist. Optionally, it can create host endpoints for all Kubernetes nodes.
    94  type NodeControllerConfig struct {
    95  	// ReconcilerPeriod is the period to perform reconciliation with the Calico datastore. [Default: 5m]
    96  	ReconcilerPeriod *metav1.Duration `json:"reconcilerPeriod,omitempty" validate:"omitempty"`
    97  
    98  	// SyncLabels controls whether to copy Kubernetes node labels to Calico nodes. [Default: Enabled]
    99  	SyncLabels string `json:"syncLabels,omitempty" validate:"omitempty,oneof=Enabled Disabled"`
   100  
   101  	// HostEndpoint controls syncing nodes to host endpoints. Disabled by default, set to nil to disable.
   102  	HostEndpoint *AutoHostEndpointConfig `json:"hostEndpoint,omitempty"`
   103  
   104  	// LeakGracePeriod is the period used by the controller to determine if an IP address has been leaked.
   105  	// Set to 0 to disable IP garbage collection. [Default: 15m]
   106  	// +optional
   107  	LeakGracePeriod *metav1.Duration `json:"leakGracePeriod,omitempty"`
   108  }
   109  
   110  type AutoHostEndpointConfig struct {
   111  	// AutoCreate enables automatic creation of host endpoints for every node. [Default: Disabled]
   112  	AutoCreate string `json:"autoCreate,omitempty" validate:"omitempty,oneof=Enabled Disabled"`
   113  }
   114  
   115  // PolicyControllerConfig configures the network policy controller, which syncs Kubernetes policies
   116  // to Calico policies (only used for etcdv3 datastore).
   117  type PolicyControllerConfig struct {
   118  	// ReconcilerPeriod is the period to perform reconciliation with the Calico datastore. [Default: 5m]
   119  	ReconcilerPeriod *metav1.Duration `json:"reconcilerPeriod,omitempty" validate:"omitempty"`
   120  }
   121  
   122  // WorkloadEndpointControllerConfig configures the workload endpoint controller, which syncs Kubernetes
   123  // labels to Calico workload endpoints (only used for etcdv3 datastore).
   124  type WorkloadEndpointControllerConfig struct {
   125  	// ReconcilerPeriod is the period to perform reconciliation with the Calico datastore. [Default: 5m]
   126  	ReconcilerPeriod *metav1.Duration `json:"reconcilerPeriod,omitempty" validate:"omitempty"`
   127  }
   128  
   129  // ServiceAccountControllerConfig configures the service account controller, which syncs Kubernetes
   130  // service accounts to Calico profiles (only used for etcdv3 datastore).
   131  type ServiceAccountControllerConfig struct {
   132  	// ReconcilerPeriod is the period to perform reconciliation with the Calico datastore. [Default: 5m]
   133  	ReconcilerPeriod *metav1.Duration `json:"reconcilerPeriod,omitempty" validate:"omitempty"`
   134  }
   135  
   136  // NamespaceControllerConfig configures the service account controller, which syncs Kubernetes
   137  // service accounts to Calico profiles (only used for etcdv3 datastore).
   138  type NamespaceControllerConfig struct {
   139  	// ReconcilerPeriod is the period to perform reconciliation with the Calico datastore. [Default: 5m]
   140  	ReconcilerPeriod *metav1.Duration `json:"reconcilerPeriod,omitempty" validate:"omitempty"`
   141  }
   142  
   143  // FederatedServicesControllerConfig configures the federated services controller, which syncs Kubernetes
   144  // services from remote clusters.
   145  type FederatedServicesControllerConfig struct {
   146  	// ReconcilerPeriod is the period to perform reconciliation. [Default: 5m]
   147  	ReconcilerPeriod *metav1.Duration `json:"reconcilerPeriod,omitempty" validate:"omitempty"`
   148  }
   149  
   150  // KubeControllersConfigurationStatus represents the status of the configuration. It's useful for admins to
   151  // be able to see the actual config that was applied, which can be modified by environment variables on the
   152  // kube-controllers process.
   153  type KubeControllersConfigurationStatus struct {
   154  	// RunningConfig contains the effective config that is running in the kube-controllers pod, after
   155  	// merging the API resource with any environment variables.
   156  	RunningConfig KubeControllersConfigurationSpec `json:"runningConfig,omitempty"`
   157  
   158  	// EnvironmentVars contains the environment variables on the kube-controllers that influenced
   159  	// the RunningConfig.
   160  	EnvironmentVars map[string]string `json:"environmentVars,omitempty"`
   161  }
   162  
   163  // New KubeControllersConfiguration creates a new (zeroed) KubeControllersConfiguration struct with
   164  // the TypeMetadata initialized to the current version.
   165  func NewKubeControllersConfiguration() *KubeControllersConfiguration {
   166  	return &KubeControllersConfiguration{
   167  		TypeMeta: metav1.TypeMeta{
   168  			Kind:       KindKubeControllersConfiguration,
   169  			APIVersion: GroupVersionCurrent,
   170  		},
   171  	}
   172  }