-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
config.go
760 lines (568 loc) · 30 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package option
import (
"time"
"github.com/spf13/viper"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/cilium/cilium/pkg/command"
"github.com/cilium/cilium/pkg/logging"
"github.com/cilium/cilium/pkg/logging/logfields"
"github.com/cilium/cilium/pkg/option"
)
var log = logging.DefaultLogger.WithField(logfields.LogSubsys, "option")
var IngressLBAnnotationsDefault = []string{"service.beta.kubernetes.io", "service.kubernetes.io", "cloud.google.com"}
const (
// EndpointGCIntervalDefault is the default time for the CEP GC
EndpointGCIntervalDefault = 5 * time.Minute
// PrometheusServeAddr is the default server address for operator metrics
PrometheusServeAddr = ":9963"
// CESMaxCEPsInCESDefault is the maximum number of cilium endpoints allowed in a CES
CESMaxCEPsInCESDefault = 100
// CESSlicingModeDefault is default method for grouping CEP in a CES.
CESSlicingModeDefault = "cesSliceModeIdentity"
// CESWriteQPSLimitDefault is the default rate limit for the CES work queue.
CESWriteQPSLimitDefault = 10
// CESWriteQPSLimitMax is the maximum rate limit for the CES work queue.
// CES work queue QPS limit cannot exceed this value, regardless of other config.
CESWriteQPSLimitMax = 50
// CESWriteQPSBurstDefault is the default burst rate for the CES work queue.
CESWriteQPSBurstDefault = 20
// CESWriteQPSBurstMax is the maximum burst rate for the CES work queue.
// CES work queue QPS burst cannot exceed this value, regardless of other config.
CESWriteQPSBurstMax = 100
// CNPStatusCleanupQPSDefault is the default rate for the CNP NodeStatus updates GC.
CNPStatusCleanupQPSDefault = 10
// CNPStatusCleanupBurstDefault is the default maximum burst for the CNP NodeStatus updates GC.
CNPStatusCleanupBurstDefault = 20
// PprofAddressOperator is the default value for pprof in the operator
PprofAddressOperator = "localhost"
// PprofPortOperator is the default value for pprof in the operator
PprofPortOperator = 6061
// DefaultProxyIdleTimeoutSeconds is the default value for the proxy idle timeout
DefaultProxyIdleTimeoutSeconds = 60
)
const (
// BGPAnnounceLBIP announces service IPs of type LoadBalancer via BGP beta (deprecated)
BGPAnnounceLBIP = "bgp-announce-lb-ip"
// BGPConfigPath is the file path to the BGP configuration. It is
// compatible with MetalLB's configuration.
BGPConfigPath = "bgp-config-path"
// CNPNodeStatusGCInterval is the GC interval for nodes which have been
// removed from the cluster in CiliumNetworkPolicy and
// CiliumClusterwideNetworkPolicy Status.
CNPNodeStatusGCInterval = "cnp-node-status-gc-interval"
// CNPStatusUpdateInterval is the interval between status updates
// being sent to the K8s apiserver for a given CNP.
CNPStatusUpdateInterval = "cnp-status-update-interval"
// SkipCNPStatusStartupClean specifies if the cleanup of all the CNP
// NodeStatus updates at startup must be skipped.
SkipCNPStatusStartupClean = "skip-cnp-status-startup-clean"
// CNPStatusCleanupQPS is the rate at which the cleanup operation of the status
// nodes updates in CNPs is carried out. It is expressed as queries per second,
// and for each query a single CNP status update will be deleted.
CNPStatusCleanupQPS = "cnp-status-cleanup-qps"
// CNPStatusCleanupBurst is the maximum burst of queries allowed for the cleanup
// operation of the status nodes updates in CNPs.
CNPStatusCleanupBurst = "cnp-status-cleanup-burst"
// EnableMetrics enables prometheus metrics.
EnableMetrics = "enable-metrics"
// EndpointGCInterval is the interval between attempts of the CEP GC
// controller.
// Note that only one node per cluster should run this, and most iterations
// will simply return.
EndpointGCInterval = "cilium-endpoint-gc-interval"
// NodesGCInterval is the duration for which the cilium nodes are GC.
NodesGCInterval = "nodes-gc-interval"
// OperatorPrometheusServeAddr IP:Port on which to serve prometheus
// metrics (pass ":Port" to bind on all interfaces, "" is off).
OperatorPrometheusServeAddr = "operator-prometheus-serve-addr"
// SyncK8sServices synchronizes k8s services into the kvstore
SyncK8sServices = "synchronize-k8s-services"
// SyncK8sNodes synchronizes k8s nodes into the kvstore
SyncK8sNodes = "synchronize-k8s-nodes"
// UnmanagedPodWatcherInterval is the interval to check for unmanaged kube-dns pods (0 to disable)
UnmanagedPodWatcherInterval = "unmanaged-pod-watcher-interval"
// IPAM options
// IPAMAPIBurst is the burst value allowed when accessing external IPAM APIs
IPAMAPIBurst = "limit-ipam-api-burst"
// IPAMAPIQPSLimit is the queries per second limit when accessing external IPAM APIs
IPAMAPIQPSLimit = "limit-ipam-api-qps"
// IPAMSubnetsIDs are optional subnets IDs used to filter subnets and interfaces listing
IPAMSubnetsIDs = "subnet-ids-filter"
// IPAMSubnetsTags are optional tags used to filter subnets, and interfaces within those subnets
IPAMSubnetsTags = "subnet-tags-filter"
// IPAMInstanceTagFilter are optional tags used to filter instances for ENI discovery ; only used with AWS IPAM mode for now
IPAMInstanceTags = "instance-tags-filter"
// IPAMAutoCreateCiliumPodIPPools contains pre-defined IP pools to be auto-created on startup.
IPAMAutoCreateCiliumPodIPPools = "auto-create-cilium-pod-ip-pools"
// ClusterPoolIPv4CIDR is the cluster's IPv4 CIDR to allocate
// individual PodCIDR ranges from when using the ClusterPool ipam mode.
ClusterPoolIPv4CIDR = "cluster-pool-ipv4-cidr"
// ClusterPoolIPv6CIDR is the cluster's IPv6 CIDR to allocate
// individual PodCIDR ranges from when using the ClusterPool ipam mode.
ClusterPoolIPv6CIDR = "cluster-pool-ipv6-cidr"
// NodeCIDRMaskSizeIPv4 is the IPv4 podCIDR mask size that will be used
// per node.
NodeCIDRMaskSizeIPv4 = "cluster-pool-ipv4-mask-size"
// NodeCIDRMaskSizeIPv6 is the IPv6 podCIDR mask size that will be used
// per node.
NodeCIDRMaskSizeIPv6 = "cluster-pool-ipv6-mask-size"
// AWS options
// AWSInstanceLimitMapping allows overwirting AWS instance limits defined in
// pkg/aws/eni/limits.go
// e.g. {"a1.medium": "2,4,4", "a2.custom2": "4,5,6"}
AWSInstanceLimitMapping = "aws-instance-limit-mapping"
// AWSReleaseExcessIPs allows releasing excess free IP addresses from ENI.
// Enabling this option reduces waste of IP addresses but may increase
// the number of API calls to AWS EC2 service.
AWSReleaseExcessIPs = "aws-release-excess-ips"
// ExcessIPReleaseDelay controls how long operator would wait before an IP previously marked as excess is released.
// Defaults to 180 secs
ExcessIPReleaseDelay = "excess-ip-release-delay"
// AWSEnablePrefixDelegation allows operator to allocate prefixes to ENIs on nitro instances instead of individual
// IP addresses. Allows for increased pod density on nodes.
AWSEnablePrefixDelegation = "aws-enable-prefix-delegation"
// ENITags are the tags that will be added to every ENI created by the
// AWS ENI IPAM.
ENITags = "eni-tags"
// ENIGarbageCollectionTags is a tag that will be added to every ENI
// created by the AWS ENI IPAM.
// Any stale and unattached ENIs with this tag will be garbage
// collected by the operator.
ENIGarbageCollectionTags = "eni-gc-tags"
// ENIGarbageCollectionInterval defines the interval of ENI GC
ENIGarbageCollectionInterval = "eni-gc-interval"
// ParallelAllocWorkers specifies the number of parallel workers to be used for IPAM allocation
ParallelAllocWorkers = "parallel-alloc-workers"
// UpdateEC2AdapterLimitViaAPI configures the operator to use the EC2
// API to fill out the instancetype to adapter limit mapping.
UpdateEC2AdapterLimitViaAPI = "update-ec2-adapter-limit-via-api"
// EC2APIEndpoint is the custom API endpoint to use for the EC2 AWS service,
// e.g. "ec2-fips.us-west-1.amazonaws.com" to use a FIPS endpoint in the us-west-1 region.
EC2APIEndpoint = "ec2-api-endpoint"
// AWSUsePrimaryAddress specifies whether an interface's primary address should be available for allocations on
// node
AWSUsePrimaryAddress = "aws-use-primary-address"
// Azure options
// AzureSubscriptionID is the subscription ID to use when accessing the Azure API
AzureSubscriptionID = "azure-subscription-id"
// AzureResourceGroup is the resource group of the nodes used for the cluster
AzureResourceGroup = "azure-resource-group"
// AzureUserAssignedIdentityID is the id of the user assigned identity used
// for retrieving Azure API credentials
AzureUserAssignedIdentityID = "azure-user-assigned-identity-id"
// AzureUsePrimaryAddress specifies whether we should use or ignore the interface's
// primary IPConfiguration
AzureUsePrimaryAddress = "azure-use-primary-address"
// LeaderElectionLeaseDuration is the duration that non-leader candidates will wait to
// force acquire leadership
LeaderElectionLeaseDuration = "leader-election-lease-duration"
// LeaderElectionRenewDeadline is the duration that the current acting master in HA deployment
// will retry refreshing leadership before giving up the lock.
LeaderElectionRenewDeadline = "leader-election-renew-deadline"
// LeaderElectionRetryPeriod is the duration the LeaderElector clients should wait between
// tries of the actions in operator HA deployment.
LeaderElectionRetryPeriod = "leader-election-retry-period"
// AlibabaCloud options
// AlibabaCloudVPCID allows user to specific vpc
AlibabaCloudVPCID = "alibaba-cloud-vpc-id"
// AlibabaCloudReleaseExcessIPs allows releasing excess free IP addresses from ENI.
// Enabling this option reduces waste of IP addresses but may increase
// the number of API calls to AlibabaCloud ECS service.
AlibabaCloudReleaseExcessIPs = "alibaba-cloud-release-excess-ips"
// CiliumEndpointSlice options
// CESMaxCEPsInCES is the maximum number of cilium endpoints allowed in single
// a CiliumEndpointSlice resource.
CESMaxCEPsInCES = "ces-max-ciliumendpoints-per-ces"
// CESSlicingMode instructs how CEPs are grouped in a CES.
CESSlicingMode = "ces-slice-mode"
// CESWriteQPSLimit is the rate limit per second for the CES work queue to
// process CES events that result in CES write (Create, Update, Delete)
// requests to the kube-apiserver.
CESWriteQPSLimit = "ces-write-qps-limit"
// CESWriteQPSBurst is the burst rate per second used with CESWriteQPSLimit
// for the CES work queue to process CES events that result in CES write
// (Create, Update, Delete) requests to the kube-apiserver.
CESWriteQPSBurst = "ces-write-qps-burst"
// LoadBalancerL7 enables loadbalancer capabilities for services via envoy proxy
LoadBalancerL7 = "loadbalancer-l7"
// LoadBalancerL7Ports is a list of service ports that will be automatically redirected to backend.
LoadBalancerL7Ports = "loadbalancer-l7-ports"
// LoadBalancerL7Algorithm is a default LB algorithm for services that do not specify related annotation
LoadBalancerL7Algorithm = "loadbalancer-l7-algorithm"
// EnableIngressController enables cilium ingress controller
// This must be enabled along with enable-envoy-config in cilium agent.
EnableIngressController = "enable-ingress-controller"
// EnforceIngressHttps enforces https for host having matching TLS host in Ingress.
// Incoming traffic to http listener will return 308 http error code with respective location in header.
EnforceIngressHttps = "enforce-ingress-https"
// EnableIngressSecretsSync enables fan-in TLS secrets from multiple namespaces to singular namespace (specified
// by ingress-secrets-namespace flag
EnableIngressSecretsSync = "enable-ingress-secrets-sync"
// EnableGatewayAPISecretsSync enables fan-in TLS secrets from multiple namespaces to singular namespace (specified
// by gateway-api-secrets-namespace flag
EnableGatewayAPISecretsSync = "enable-gateway-api-secrets-sync"
// IngressSecretsNamespace is the namespace having tls secrets used by Ingress and CEC.
IngressSecretsNamespace = "ingress-secrets-namespace"
// GatewayAPISecretsNamespace is the namespace having tls secrets used by GatewayAPI and CEC.
GatewayAPISecretsNamespace = "gateway-api-secrets-namespace"
// ProxyIdleTimeoutSeconds is the idle timeout for proxy connections to upstream clusters
ProxyIdleTimeoutSeconds = "proxy-idle-timeout-seconds"
// EnableGatewayAPI enables support of Gateway API
// This must be enabled along with enable-envoy-config in cilium agent.
EnableGatewayAPI = "enable-gateway-api"
// CiliumK8sNamespace is the namespace where Cilium pods are running.
CiliumK8sNamespace = "cilium-pod-namespace"
// CiliumPodLabels specifies the pod labels that Cilium pods is running
// with.
CiliumPodLabels = "cilium-pod-labels"
// RemoveCiliumNodeTaints is the flag to define if the Cilium node taint
// should be removed in Kubernetes nodes.
RemoveCiliumNodeTaints = "remove-cilium-node-taints"
// SetCiliumNodeTaints is whether or not to taint nodes that do not have
// a running Cilium instance.
SetCiliumNodeTaints = "set-cilium-node-taints"
// SetCiliumIsUpCondition sets the CiliumIsUp node condition in Kubernetes
// nodes.
SetCiliumIsUpCondition = "set-cilium-is-up-condition"
// IngressLBAnnotationPrefixes are the annotations which are needed to propagate
// from Ingress to the Load Balancer
IngressLBAnnotationPrefixes = "ingress-lb-annotation-prefixes"
// IngressSharedLBServiceName is the name of shared LB service name for Ingress.
IngressSharedLBServiceName = "ingress-shared-lb-service-name"
// IngressDefaultLoadbalancerMode is the default loadbalancer mode for Ingress.
// Applicable values: dedicated, shared
IngressDefaultLoadbalancerMode = "ingress-default-lb-mode"
// IngressDefaultSecretNamespace is the default secret namespace for Ingress.
IngressDefaultSecretNamespace = "ingress-default-secret-namespace"
// IngressDefaultSecretName is the default secret name for Ingress.
IngressDefaultSecretName = "ingress-default-secret-name"
// PodRestartSelector specify the labels contained in the pod that needs to be restarted before the node can be de-stained
// default values: k8s-app=kube-dns
PodRestartSelector = "pod-restart-selector"
)
// OperatorConfig is the configuration used by the operator.
type OperatorConfig struct {
// CNPNodeStatusGCInterval is the GC interval for nodes which have been
// removed from the cluster in CiliumNetworkPolicy and
// CiliumClusterwideNetworkPolicy Status.
CNPNodeStatusGCInterval time.Duration
// CNPStatusUpdateInterval is the interval between status updates
// being sent to the K8s apiserver for a given CNP.
CNPStatusUpdateInterval time.Duration
// NodesGCInterval is the GC interval for CiliumNodes
NodesGCInterval time.Duration
// SkipCNPStatusStartupClean disables the cleanup of all the CNP
// NodeStatus updates at startup.
SkipCNPStatusStartupClean bool
// CNPStatusCleanupQPS is the rate at which the cleanup operation of the status
// nodes updates in CNPs is carried out. It is expressed as queries per second,
// and for each query a single CNP status update will be deleted.
CNPStatusCleanupQPS float64
// CNPStatusCleanupBurst is the maximum burst of queries allowed for the cleanup
// operation of the status nodes updates in CNPs.
CNPStatusCleanupBurst int
// EnableMetrics enables prometheus metrics.
EnableMetrics bool
// EndpointGCInterval is the interval between attempts of the CEP GC
// controller.
// Note that only one node per cluster should run this, and most iterations
// will simply return.
EndpointGCInterval time.Duration
OperatorPrometheusServeAddr string
// SyncK8sServices synchronizes k8s services into the kvstore
SyncK8sServices bool
// SyncK8sNodes synchronizes k8s nodes into the kvstore
SyncK8sNodes bool
// UnmanagedPodWatcherInterval is the interval to check for unmanaged kube-dns pods (0 to disable)
UnmanagedPodWatcherInterval int
// LeaderElectionLeaseDuration is the duration that non-leader candidates will wait to
// force acquire leadership in Cilium Operator HA deployment.
LeaderElectionLeaseDuration time.Duration
// LeaderElectionRenewDeadline is the duration that the current acting master in HA deployment
// will retry refreshing leadership in before giving up the lock.
LeaderElectionRenewDeadline time.Duration
// LeaderElectionRetryPeriod is the duration that LeaderElector clients should wait between
// retries of the actions in operator HA deployment.
LeaderElectionRetryPeriod time.Duration
// BGPAnnounceLBIP announces service IPs of type LoadBalancer via BGP beta (deprecated)
BGPAnnounceLBIP bool
// BGPConfigPath is the file path to the BGP configuration. It is
// compatible with MetalLB's configuration.
BGPConfigPath string
// IPAM options
// IPAMAPIBurst is the burst value allowed when accessing external IPAM APIs
IPAMAPIBurst int
// IPAMAPIQPSLimit is the queries per second limit when accessing external IPAM APIs
IPAMAPIQPSLimit float64
// IPAMSubnetsIDs are optional subnets IDs used to filter subnets and interfaces listing
IPAMSubnetsIDs []string
// IPAMSubnetsTags are optional tags used to filter subnets, and interfaces within those subnets
IPAMSubnetsTags map[string]string
// IPAMUInstanceTags are optional tags used to filter AWS EC2 instances, and interfaces (ENI) attached to them
IPAMInstanceTags map[string]string
// IPAM Operator options
// ClusterPoolIPv4CIDR is the cluster IPv4 podCIDR that should be used to
// allocate pods in the node.
ClusterPoolIPv4CIDR []string
// ClusterPoolIPv6CIDR is the cluster IPv6 podCIDR that should be used to
// allocate pods in the node.
ClusterPoolIPv6CIDR []string
// NodeCIDRMaskSizeIPv4 is the IPv4 podCIDR mask size that will be used
// per node.
NodeCIDRMaskSizeIPv4 int
// NodeCIDRMaskSizeIPv6 is the IPv6 podCIDR mask size that will be used
// per node.
NodeCIDRMaskSizeIPv6 int
// IPAMAutoCreateCiliumPodIPPools contains pre-defined IP pools to be auto-created on startup.
IPAMAutoCreateCiliumPodIPPools map[string]string
// AWS options
// ENITags are the tags that will be added to every ENI created by the AWS ENI IPAM
ENITags map[string]string
// ENIGarbageCollectionTags is a tag that will be added to every ENI
// created by the AWS ENI IPAM.
// Any stale and unattached ENIs with this tag will be garbage
// collected by the operator.
ENIGarbageCollectionTags map[string]string
// ENIGarbageCollectionInterval defines the interval of ENI GC
ENIGarbageCollectionInterval time.Duration
// ParallelAllocWorkers specifies the number of parallel workers to be used for accessing cloud provider APIs .
ParallelAllocWorkers int64
// AWSInstanceLimitMapping allows overwriting AWS instance limits defined in
// pkg/aws/eni/limits.go
// e.g. {"a1.medium": "2,4,4", "a2.custom2": "4,5,6"}
AWSInstanceLimitMapping map[string]string
// AWSReleaseExcessIps allows releasing excess free IP addresses from ENI.
// Enabling this option reduces waste of IP addresses but may increase
// the number of API calls to AWS EC2 service.
AWSReleaseExcessIPs bool
// AWSEnablePrefixDelegation allows operator to allocate prefixes to ENIs on nitro instances instead of individual
// IP addresses. Allows for increased pod density on nodes.
AWSEnablePrefixDelegation bool
// AWSUsePrimaryAddress specifies whether an interface's primary address should be available for allocations on
// node
AWSUsePrimaryAddress bool
// UpdateEC2AdapterLimitViaAPI configures the operator to use the EC2 API to fill out the
// instancetype to adapter limit mapping.
UpdateEC2AdapterLimitViaAPI bool
// ExcessIPReleaseDelay controls how long operator would wait before an IP previously marked as excess is released.
// Defaults to 180 secs
ExcessIPReleaseDelay int
// EC2APIEndpoint is the custom API endpoint to use for the EC2 AWS service,
// e.g. "ec2-fips.us-west-1.amazonaws.com" to use a FIPS endpoint in the us-west-1 region.
EC2APIEndpoint string
// Azure options
// AzureSubscriptionID is the subscription ID to use when accessing the Azure API
AzureSubscriptionID string
// AzureResourceGroup is the resource group of the nodes used for the cluster
AzureResourceGroup string
// AzureUserAssignedIdentityID is the id of the user assigned identity used
// for retrieving Azure API credentials
AzureUserAssignedIdentityID string
// AzureUsePrimaryAddress specify wether we should use or ignore the interface's
// primary IPConfiguration
AzureUsePrimaryAddress bool
// AlibabaCloud options
// AlibabaCloudVPCID allow user to specific vpc
AlibabaCloudVPCID string
// AlibabaCloudReleaseExcessIPs allows releasing excess free IP addresses from ENI.
// Enabling this option reduces waste of IP addresses but may increase
// the number of API calls to AlibabaCloud ECS service.
AlibabaCloudReleaseExcessIPs bool
// CiliumEndpointSlice options
// CESMaxCEPsInCES is the maximum number of CiliumEndpoints allowed in single
// a CiliumEndpointSlice resource.
// The default value of maximum CiliumEndpoints allowed in a CiliumEndpointSlice resource is 100.
CESMaxCEPsInCES int
// CESSlicingMode instructs how CEPs are grouped in a CES.
CESSlicingMode string
// CESWriteQPSLimit is the rate limit per second for the CES work queue to
// process CES events that result in CES write (Create, Update, Delete)
// requests to the kube-apiserver.
CESWriteQPSLimit float64
// CESWriteQPSBurst is the burst rate per second used with CESWriteQPSLimit
// for the CES work queue to process CES events that result in CES write
// (Create, Update, Delete) requests to the kube-apiserver.
CESWriteQPSBurst int
// LoadBalancerL7 enables loadbalancer capabilities for services.
LoadBalancerL7 string
// EnvoyLoadBalancerPorts is a list of service ports that will be automatically redirected to Envoy
LoadBalancerL7Ports []string
// LoadBalancerL7Algorithm is a default LB algorithm for services that do not specify related annotation
LoadBalancerL7Algorithm string
// EnableIngressController enables cilium ingress controller
EnableIngressController bool
// EnableGatewayAPI enables support of Gateway API
EnableGatewayAPI bool
// EnforceIngressHTTPS enforces https if required
EnforceIngressHTTPS bool
// EnableIngressSecretsSync enables background TLS secret sync for Ingress
EnableIngressSecretsSync bool
// EnableGatewayAPISecretsSync enables background TLS secret sync for Gateway API
EnableGatewayAPISecretsSync bool
// IngressSecretsNamespace is the namespace having tls secrets used by CEC for Ingress.
IngressSecretsNamespace string
// GatewayAPISecretsNamespace is the namespace having tls secrets used by CEC for Gateway API.
GatewayAPISecretsNamespace string
// ProxyIdleTimeoutSeconds is the idle timeout for the proxy to upstream cluster
ProxyIdleTimeoutSeconds int
// CiliumK8sNamespace is the namespace where Cilium pods are running.
CiliumK8sNamespace string
// CiliumPodLabels specifies the pod labels that Cilium pods is running
// with.
CiliumPodLabels string
// RemoveCiliumNodeTaints is the flag to define if the Cilium node taint
// should be removed in Kubernetes nodes.
RemoveCiliumNodeTaints bool
// SetCiliumNodeTaints is whether or not to set taints on nodes that do not
// have a running Cilium pod.
SetCiliumNodeTaints bool
// SetCiliumIsUpCondition sets the CiliumIsUp node condition in Kubernetes
// nodes.
SetCiliumIsUpCondition bool
// IngressLBAnnotationPrefixes IngressLBAnnotations are the annotation prefixes,
// which are used to filter annotations to propagate from Ingress to the Load Balancer
IngressLBAnnotationPrefixes []string
// IngressSharedLBServiceName is the name of shared LB service name for Ingress.
IngressSharedLBServiceName string
// IngressDefaultLoadbalancerMode is the default loadbalancer mode for Ingress.
// Applicable values: dedicated, shared
IngressDefaultLoadbalancerMode string
// IngressDefaultLSecretNamespace is the default secret namespace for Ingress.
IngressDefaultSecretNamespace string
// IngressDefaultLSecretName is the default secret name for Ingress.
IngressDefaultSecretName string
// PodRestartSelector specify the labels contained in the pod that needs to be restarted before the node can be de-stained
PodRestartSelector string
}
// Populate sets all options with the values from viper.
func (c *OperatorConfig) Populate(vp *viper.Viper) {
c.CNPNodeStatusGCInterval = vp.GetDuration(CNPNodeStatusGCInterval)
c.CNPStatusUpdateInterval = vp.GetDuration(CNPStatusUpdateInterval)
c.NodesGCInterval = vp.GetDuration(NodesGCInterval)
c.SkipCNPStatusStartupClean = vp.GetBool(SkipCNPStatusStartupClean)
c.CNPStatusCleanupQPS = vp.GetFloat64(CNPStatusCleanupQPS)
c.CNPStatusCleanupBurst = vp.GetInt(CNPStatusCleanupBurst)
c.EnableMetrics = vp.GetBool(EnableMetrics)
c.EndpointGCInterval = vp.GetDuration(EndpointGCInterval)
c.OperatorPrometheusServeAddr = vp.GetString(OperatorPrometheusServeAddr)
c.SyncK8sServices = vp.GetBool(SyncK8sServices)
c.SyncK8sNodes = vp.GetBool(SyncK8sNodes)
c.UnmanagedPodWatcherInterval = vp.GetInt(UnmanagedPodWatcherInterval)
c.NodeCIDRMaskSizeIPv4 = vp.GetInt(NodeCIDRMaskSizeIPv4)
c.NodeCIDRMaskSizeIPv6 = vp.GetInt(NodeCIDRMaskSizeIPv6)
c.ClusterPoolIPv4CIDR = vp.GetStringSlice(ClusterPoolIPv4CIDR)
c.ClusterPoolIPv6CIDR = vp.GetStringSlice(ClusterPoolIPv6CIDR)
c.LeaderElectionLeaseDuration = vp.GetDuration(LeaderElectionLeaseDuration)
c.LeaderElectionRenewDeadline = vp.GetDuration(LeaderElectionRenewDeadline)
c.LeaderElectionRetryPeriod = vp.GetDuration(LeaderElectionRetryPeriod)
c.BGPAnnounceLBIP = vp.GetBool(BGPAnnounceLBIP)
c.BGPConfigPath = vp.GetString(BGPConfigPath)
c.LoadBalancerL7 = vp.GetString(LoadBalancerL7)
c.LoadBalancerL7Ports = vp.GetStringSlice(LoadBalancerL7Ports)
c.LoadBalancerL7Algorithm = vp.GetString(LoadBalancerL7Algorithm)
c.EnableIngressController = vp.GetBool(EnableIngressController)
c.EnableGatewayAPI = vp.GetBool(EnableGatewayAPI)
c.EnforceIngressHTTPS = vp.GetBool(EnforceIngressHttps)
c.IngressSecretsNamespace = vp.GetString(IngressSecretsNamespace)
c.GatewayAPISecretsNamespace = vp.GetString(GatewayAPISecretsNamespace)
c.ProxyIdleTimeoutSeconds = vp.GetInt(ProxyIdleTimeoutSeconds)
if c.ProxyIdleTimeoutSeconds == 0 {
c.ProxyIdleTimeoutSeconds = DefaultProxyIdleTimeoutSeconds
}
c.EnableIngressSecretsSync = vp.GetBool(EnableIngressSecretsSync)
c.EnableGatewayAPISecretsSync = vp.GetBool(EnableGatewayAPISecretsSync)
c.CiliumPodLabels = vp.GetString(CiliumPodLabels)
c.RemoveCiliumNodeTaints = vp.GetBool(RemoveCiliumNodeTaints)
c.SetCiliumNodeTaints = vp.GetBool(SetCiliumNodeTaints)
c.SetCiliumIsUpCondition = vp.GetBool(SetCiliumIsUpCondition)
c.IngressLBAnnotationPrefixes = vp.GetStringSlice(IngressLBAnnotationPrefixes)
c.IngressSharedLBServiceName = vp.GetString(IngressSharedLBServiceName)
c.IngressDefaultLoadbalancerMode = vp.GetString(IngressDefaultLoadbalancerMode)
c.IngressDefaultSecretNamespace = vp.GetString(IngressDefaultSecretNamespace)
c.IngressDefaultSecretName = vp.GetString(IngressDefaultSecretName)
c.PodRestartSelector = vp.GetString(PodRestartSelector)
c.CiliumK8sNamespace = vp.GetString(CiliumK8sNamespace)
if c.CiliumK8sNamespace == "" {
if option.Config.K8sNamespace == "" {
c.CiliumK8sNamespace = metav1.NamespaceDefault
} else {
c.CiliumK8sNamespace = option.Config.K8sNamespace
}
}
if c.BGPAnnounceLBIP {
c.SyncK8sServices = true
log.Infof("Auto-set %q to `true` because BGP support requires synchronizing services.",
SyncK8sServices)
}
// IPAM options
c.IPAMAPIQPSLimit = vp.GetFloat64(IPAMAPIQPSLimit)
c.IPAMAPIBurst = vp.GetInt(IPAMAPIBurst)
c.ParallelAllocWorkers = vp.GetInt64(ParallelAllocWorkers)
// AWS options
c.AWSReleaseExcessIPs = vp.GetBool(AWSReleaseExcessIPs)
c.AWSEnablePrefixDelegation = vp.GetBool(AWSEnablePrefixDelegation)
c.AWSUsePrimaryAddress = vp.GetBool(AWSUsePrimaryAddress)
c.UpdateEC2AdapterLimitViaAPI = vp.GetBool(UpdateEC2AdapterLimitViaAPI)
c.EC2APIEndpoint = vp.GetString(EC2APIEndpoint)
c.ExcessIPReleaseDelay = vp.GetInt(ExcessIPReleaseDelay)
c.ENIGarbageCollectionInterval = vp.GetDuration(ENIGarbageCollectionInterval)
// Azure options
c.AzureSubscriptionID = vp.GetString(AzureSubscriptionID)
c.AzureResourceGroup = vp.GetString(AzureResourceGroup)
c.AzureUsePrimaryAddress = vp.GetBool(AzureUsePrimaryAddress)
c.AzureUserAssignedIdentityID = vp.GetString(AzureUserAssignedIdentityID)
// AlibabaCloud options
c.AlibabaCloudVPCID = vp.GetString(AlibabaCloudVPCID)
c.AlibabaCloudReleaseExcessIPs = vp.GetBool(AlibabaCloudReleaseExcessIPs)
// CiliumEndpointSlice options
c.CESMaxCEPsInCES = vp.GetInt(CESMaxCEPsInCES)
c.CESSlicingMode = vp.GetString(CESSlicingMode)
c.CESWriteQPSLimit = vp.GetFloat64(CESWriteQPSLimit)
c.CESWriteQPSBurst = vp.GetInt(CESWriteQPSBurst)
// Option maps and slices
if m := vp.GetStringSlice(IPAMSubnetsIDs); len(m) != 0 {
c.IPAMSubnetsIDs = m
}
if m, err := command.GetStringMapStringE(vp, IPAMSubnetsTags); err != nil {
log.Fatalf("unable to parse %s: %s", IPAMSubnetsTags, err)
} else {
c.IPAMSubnetsTags = m
}
if m, err := command.GetStringMapStringE(vp, IPAMInstanceTags); err != nil {
log.Fatalf("unable to parse %s: %s", IPAMInstanceTags, err)
} else {
c.IPAMInstanceTags = m
}
if m, err := command.GetStringMapStringE(vp, AWSInstanceLimitMapping); err != nil {
log.Fatalf("unable to parse %s: %s", AWSInstanceLimitMapping, err)
} else {
c.AWSInstanceLimitMapping = m
}
if m, err := command.GetStringMapStringE(vp, ENITags); err != nil {
log.Fatalf("unable to parse %s: %s", ENITags, err)
} else {
c.ENITags = m
}
if m, err := command.GetStringMapStringE(vp, ENIGarbageCollectionTags); err != nil {
log.Fatalf("unable to parse %s: %s", ENIGarbageCollectionTags, err)
} else {
c.ENIGarbageCollectionTags = m
}
if m, err := command.GetStringMapStringE(vp, IPAMAutoCreateCiliumPodIPPools); err != nil {
log.Fatalf("unable to parse %s: %s", IPAMAutoCreateCiliumPodIPPools, err)
} else {
c.IPAMAutoCreateCiliumPodIPPools = m
}
}
// Config represents the operator configuration.
var Config = &OperatorConfig{
IPAMSubnetsIDs: make([]string, 0),
IPAMSubnetsTags: make(map[string]string),
IPAMInstanceTags: make(map[string]string),
IPAMAutoCreateCiliumPodIPPools: make(map[string]string),
AWSInstanceLimitMapping: make(map[string]string),
ENITags: make(map[string]string),
ENIGarbageCollectionTags: make(map[string]string),
}