• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zalando-incubator / kube-ingress-aws-controller / 14970015720

12 May 2025 10:34AM UTC coverage: 72.217% (-0.8%) from 72.989%
14970015720

push

github

web-flow
upgrade: migrate to aws sdk go v2 (#742)

This change migrates the controller to aws sdk go v2 version as the
support for sdk v1 is ending on July 31, 2025

Fixes #723

---------
Signed-off-by: speruri <surya.srikar.peruri@zalando.de>

369 of 473 new or added lines in 17 files covered. (78.01%)

2 existing lines in 2 files now uncovered.

3062 of 4240 relevant lines covered (72.22%)

11.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.41
/controller.go
1
package main
2

3
import (
4
        "context"
5
        "fmt"
6
        "os"
7
        "os/signal"
8
        "path"
9
        "strconv"
10
        "strings"
11
        "syscall"
12
        "time"
13

14
        kingpin "github.com/alecthomas/kingpin/v2"
15
        elbv2Types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
16
        log "github.com/sirupsen/logrus"
17
        "github.com/zalando-incubator/kube-ingress-aws-controller/aws"
18
        "github.com/zalando-incubator/kube-ingress-aws-controller/certs"
19
        "github.com/zalando-incubator/kube-ingress-aws-controller/kubernetes"
20
)
21

22
const (
23
        defaultDisableSNISupport      = "false"
24
        defaultInstrumentedHttpClient = "false"
25
        defaultHTTPRedirectToHTTPS    = "false"
26
        defaultCertTTL                = "1h"
27
        customTagFilterEnvVarName     = "CUSTOM_FILTERS"
28
)
29

30
var (
31
        buildstamp                    = "Not set"
32
        githash                       = "Not set"
33
        version                       = "Not set"
34
        versionFlag                   bool
35
        apiServerBaseURL              string
36
        pollingInterval               time.Duration
37
        creationTimeout               time.Duration
38
        certPollingInterval           time.Duration
39
        healthCheckPath               string
40
        healthCheckPort               uint
41
        healthCheckInterval           time.Duration
42
        healthCheckTimeout            time.Duration
43
        albHealthyThresholdCount      uint
44
        albUnhealthyThresholdCount    uint
45
        nlbHealthyThresholdCount      uint
46
        targetPort                    uint
47
        albHTTPTargetPort             uint
48
        nlbHTTPTargetPort             uint
49
        targetHTTPS                   bool
50
        metricsAddress                string
51
        disableSNISupport             bool
52
        disableInstrumentedHttpClient bool
53
        certTTL                       time.Duration
54
        certFilterTag                 string
55
        stackTerminationProtection    bool
56
        additionalStackTags           = make(map[string]string)
57
        idleConnectionTimeout         time.Duration
58
        deregistrationDelayTimeout    time.Duration
59
        ingressClassFilters           string
60
        controllerID                  string
61
        clusterID                     string
62
        vpcID                         string
63
        clusterLocalDomain            string
64
        maxCertsPerALB                int
65
        sslPolicy                     string
66
        blacklistCertARNs             []string
67
        blacklistCertArnMap           map[string]bool
68
        ipAddressType                 string
69
        albLogsS3Bucket               string
70
        albLogsS3Prefix               string
71
        wafWebAclId                   string
72
        httpRedirectToHTTPS           bool
73
        debugFlag                     bool
74
        quietFlag                     bool
75
        firstRun                      bool = true
76
        cwAlarmConfigMap              string
77
        cwAlarmConfigMapLocation      *kubernetes.ResourceLocation
78
        loadBalancerType              string
79
        nlbZoneAffinity               string
80
        nlbCrossZone                  bool
81
        nlbHTTPEnabled                bool
82
        ingressAPIVersion             string
83
        internalDomains               []string
84
        targetAccessMode              string
85
        targetCNINamespace            string
86
        targetCNIPodLabelSelector     string
87
        denyInternalDomains           bool
88
        denyInternalRespBody          string
89
        denyInternalRespContentType   string
90
        denyInternalRespStatusCode    int
91
        defaultInternalDomains        = fmt.Sprintf("*%s", kubernetes.DefaultClusterLocalDomain)
92
)
93

94
func init() {
1✔
95
        registerMetrics()
1✔
96
}
1✔
97

98
func loadSettings() error {
1✔
99
        kingpin.Flag("version", "Print version and exit").Default("false").BoolVar(&versionFlag)
1✔
100
        kingpin.Flag("debug", "Enables debug logging level").Default("false").BoolVar(&debugFlag)
1✔
101
        kingpin.Flag("quiet", "Enables quiet logging").Default("false").BoolVar(&quietFlag)
1✔
102
        kingpin.Flag("api-server-base-url", "sets the kubernetes api server base url. If empty will try to use the configuration from the running cluster, else it will use InsecureConfig, that does not use encryption or authentication (use case to develop with kubectl proxy).").
1✔
103
                Envar("API_SERVER_BASE_URL").StringVar(&apiServerBaseURL)
1✔
104
        kingpin.Flag("polling-interval", "sets the polling interval for ingress resources. The flag accepts a value acceptable to time.ParseDuration").
1✔
105
                Envar("POLLING_INTERVAL").Default("30s").DurationVar(&pollingInterval)
1✔
106
        kingpin.Flag("creation-timeout", "sets the stack creation timeout. The flag accepts a value acceptable to time.ParseDuration. Should be >= 1min").
1✔
107
                Envar("CREATION_TIMEOUT").Default(aws.DefaultCreationTimeout.String()).DurationVar(&creationTimeout)
1✔
108
        kingpin.Flag("cert-polling-interval", "sets the polling interval for the certificates cache refresh. The flag accepts a value acceptable to time.ParseDuration").
1✔
109
                Envar("CERT_POLLING_INTERVAL").Default(aws.DefaultCertificateUpdateInterval.String()).DurationVar(&certPollingInterval)
1✔
110
        kingpin.Flag("disable-sni-support", "disables SNI support limiting the number of certificates per ALB to 1.").
1✔
111
                Default(defaultDisableSNISupport).BoolVar(&disableSNISupport)
1✔
112
        kingpin.Flag("disable-instrumented-http-client", "disables instrumented http client.").
1✔
113
                Default(defaultInstrumentedHttpClient).BoolVar(&disableInstrumentedHttpClient)
1✔
114
        kingpin.Flag("stack-termination-protection", "enables stack termination protection for the stacks managed by the controller.").
1✔
115
                Default("false").BoolVar(&stackTerminationProtection)
1✔
116
        kingpin.Flag("additional-stack-tags", "set additional custom tags on the Cloudformation Stacks managed by the controller.").
1✔
117
                StringMapVar(&additionalStackTags)
1✔
118
        kingpin.Flag("cert-ttl-timeout", "sets the timeout of how long a certificate is kept on an old ALB to be decommissioned.").
1✔
119
                Default(defaultCertTTL).DurationVar(&certTTL)
1✔
120

1✔
121
        kingpin.Flag("cert-filter-tag", "sets a tag so the ingress controller only consider ACM or IAM certificates that have this tag set when adding a certificate to a load balancer.").
1✔
122
                Default("").StringVar(&certFilterTag)
1✔
123
        kingpin.Flag("health-check-path", "sets the health check path for the created target groups").
1✔
124
                Default(aws.DefaultHealthCheckPath).StringVar(&healthCheckPath)
1✔
125
        kingpin.Flag("health-check-port", "sets the health check port for the created target groups").
1✔
126
                Default(strconv.FormatUint(aws.DefaultHealthCheckPort, 10)).UintVar(&healthCheckPort)
1✔
127
        kingpin.Flag("target-port", "sets the target port for the created target groups").
1✔
128
                Default(strconv.FormatUint(aws.DefaultTargetPort, 10)).UintVar(&targetPort)
1✔
129
        kingpin.Flag("alb-http-target-port", "Sets the target port for ALB HTTP listener different from --target-port.").
1✔
130
                UintVar(&albHTTPTargetPort)
1✔
131
        kingpin.Flag("nlb-http-target-port", "Sets the target port for NLB HTTP listener different from --target-port. Requires --nlb-http-enabled.").
1✔
132
                UintVar(&nlbHTTPTargetPort)
1✔
133
        kingpin.Flag("target-https", "sets the target protocol to https").
1✔
134
                Default("false").BoolVar(&targetHTTPS)
1✔
135
        kingpin.Flag("health-check-interval", "sets the health check interval for the created target groups. The flag accepts a value acceptable to time.ParseDuration").
1✔
136
                Default(aws.DefaultHealthCheckInterval.String()).DurationVar(&healthCheckInterval)
1✔
137
        kingpin.Flag("health-check-timeout", "sets the health check timeout for the created target groups. The flag accepts a value acceptable to time.ParseDuration").
1✔
138
                Default(aws.DefaultHealthCheckTimeout.String()).DurationVar(&healthCheckTimeout)
1✔
139
        kingpin.Flag("alb-healthy-threshold-count", "The number of consecutive successful health checks required before considering an unhealthy target healthy. The range is 2–10. (ALB only)").
1✔
140
                Default(strconv.FormatUint(aws.DefaultAlbHealthyThresholdCount, 10)).UintVar(&albHealthyThresholdCount)
1✔
141
        kingpin.Flag("alb-unhealthy-threshold-count", "The number of consecutive failed health checks required before considering a target unhealthy. The range is 2–10. (ALB only)").
1✔
142
                Default(strconv.FormatUint(aws.DefaultAlbUnhealthyThresholdCount, 10)).UintVar(&albUnhealthyThresholdCount)
1✔
143
        kingpin.Flag("nlb-healthy-threshold-count", "The number of consecutive successful or failed health checks required before considering a target healthy or unhealthy. The range is 2–10. (NLB only)").
1✔
144
                Default(strconv.FormatUint(aws.DefaultNlbHealthyThresholdCount, 10)).UintVar(&nlbHealthyThresholdCount)
1✔
145
        kingpin.Flag("idle-connection-timeout", "sets the idle connection timeout of all ALBs. The flag accepts a value acceptable to time.ParseDuration and are between 1s and 4000s.").
1✔
146
                Default(aws.DefaultIdleConnectionTimeout.String()).DurationVar(&idleConnectionTimeout)
1✔
147
        kingpin.Flag("deregistration-delay-timeout", "sets the deregistration delay timeout of all target groups.  The flag accepts a value acceptable to time.ParseDuration that is between 1s and 3600s.").
1✔
148
                Default(aws.DefaultDeregistrationTimeout.String()).DurationVar(&deregistrationDelayTimeout)
1✔
149
        kingpin.Flag("metrics-address", "defines where to serve metrics").Default(":7979").StringVar(&metricsAddress)
1✔
150
        kingpin.Flag("ingress-class-filter", "optional comma-seperated list of kubernetes.io/ingress.class annotation values to filter behaviour on.").
1✔
151
                StringVar(&ingressClassFilters)
1✔
152
        kingpin.Flag("controller-id", "controller ID used to differentiate resources from multiple aws ingress controller instances").
1✔
153
                Default(aws.DefaultControllerID).StringVar(&controllerID)
1✔
154
        kingpin.Flag("cluster-id", "ID of the Kubernetes cluster used to lookup cluster related resources tagged with `kubernetes.io/cluster/<cluster-id>` tags. Auto discovered from the EC2 instance where the controller is running if not specified.").
1✔
155
                StringVar(&clusterID)
1✔
156
        kingpin.Flag("vpc-id", "VPC ID for where the cluster is running. Used to lookup relevant subnets. Auto discovered from the EC2 instance where the controller is running if not specified.").
1✔
157
                StringVar(&vpcID)
1✔
158
        kingpin.Flag("cluster-local-domain", "Cluster local domain is used to detect hostnames, that won't trigger a creation of an AWS load balancer, empty string will not change the default behavior. In Kubernetes you might want to pass cluster.local").
1✔
159
                Default("").StringVar(&clusterLocalDomain)
1✔
160
        kingpin.Flag("max-certs-alb", fmt.Sprintf("sets the maximum number of certificates to be attached to an ALB. Cannot be higher than %d", aws.DefaultMaxCertsPerALB)).
1✔
161
                Default(strconv.Itoa(aws.DefaultMaxCertsPerALB)).IntVar(&maxCertsPerALB) // TODO: max
1✔
162
        kingpin.Flag("ssl-policy", "Security policy that will define the protocols/ciphers accepts by the SSL listener").
1✔
163
                Default(aws.DefaultSslPolicy).EnumVar(&sslPolicy, aws.SSLPoliciesList...)
1✔
164
        kingpin.Flag("blacklist-certificate-arns", "Certificate ARNs to not consider by the controller.").StringsVar(&blacklistCertARNs)
1✔
165
        kingpin.Flag("ip-addr-type", "IP Address type to use.").
1✔
166
                Default(aws.DefaultIpAddressType).EnumVar(&ipAddressType, aws.IPAddressTypeIPV4, aws.IPAddressTypeDualstack)
1✔
167
        kingpin.Flag("logs-s3-bucket", "S3 bucket to be used for ALB logging").
1✔
168
                Default(aws.DefaultAlbS3LogsBucket).StringVar(&albLogsS3Bucket)
1✔
169
        kingpin.Flag("logs-s3-prefix", "Prefix within S3 bucket to be used for ALB logging").
1✔
170
                Default(aws.DefaultAlbS3LogsPrefix).StringVar(&albLogsS3Prefix)
1✔
171
        kingpin.Flag("aws-waf-web-acl-id", "WAF web acl id to be associated with the ALB. For WAF v2 it is possible to specify the WebACL ARN arn:aws:wafv2:<region>:<account>:regional/webacl/<name>/<id>").
1✔
172
                Default("").StringVar(&wafWebAclId)
1✔
173
        kingpin.Flag("cloudwatch-alarms-config-map", "ConfigMap location of the form 'namespace/config-map-name' where to read CloudWatch Alarm configuration from. Ignored if empty.").
1✔
174
                StringVar(&cwAlarmConfigMap)
1✔
175
        kingpin.Flag("redirect-http-to-https", "Configure HTTP listener to redirect to HTTPS").
1✔
176
                Default(defaultHTTPRedirectToHTTPS).BoolVar(&httpRedirectToHTTPS)
1✔
177
        kingpin.Flag("load-balancer-type", "Sets default Load Balancer type (application or network).").
1✔
178
                Default(aws.LoadBalancerTypeApplication).EnumVar(&loadBalancerType, aws.LoadBalancerTypeApplication, aws.LoadBalancerTypeNetwork)
1✔
179
        kingpin.Flag("nlb-zone-affinity", "Specify whether Route53 should return zone aware Network Load Balancers IPs. It configures dns_record.client_routing_policy NLB configuration. This setting only apply to 'network' Load Balancers.").
1✔
180
                Default(aws.DefaultZoneAffinity).StringVar(&nlbZoneAffinity)
1✔
181
        kingpin.Flag("nlb-cross-zone", "Specify whether Network Load Balancers should balance cross availablity zones. This setting only apply to 'network' Load Balancers.").
1✔
182
                Default("false").BoolVar(&nlbCrossZone)
1✔
183
        kingpin.Flag("nlb-http-enabled", "Enable HTTP (port 80) for Network Load Balancers. By default this is disabled as NLB can't provide HTTP -> HTTPS redirect.").
1✔
184
                Default("false").BoolVar(&nlbHTTPEnabled)
1✔
185
        kingpin.Flag("deny-internal-domains", "Sets a rule on ALB's Listeners that denies requests with the Host header as a internal domain. Domains can be set with the -internal-domains flag.").
1✔
186
                Default("false").BoolVar(&denyInternalDomains)
1✔
187
        kingpin.Flag("internal-domains", "Define the internal domains to be blocked when -deny-internal-domains is set to true. Set it multiple times for multiple domains. The maximum size of each name is 128 characters. The following wildcard characters are supported: * (matches 0 or more characters) and ? (matches exactly 1 character).").
1✔
188
                Default(defaultInternalDomains).StringsVar(&internalDomains)
1✔
189
        kingpin.Flag("deny-internal-domains-response", "Defines the response body for a request identified as to an internal domain when -deny-internal-domains is set.").
1✔
190
                Default("Unauthorized").StringVar(&denyInternalRespBody)
1✔
191
        kingpin.Flag("deny-internal-domains-response-content-type", "Defines the response conten-type for a request identified as to an internal domain when -deny-internal-domains is set.").
1✔
192
                Default("text/plain").StringVar(&denyInternalRespContentType)
1✔
193
        kingpin.Flag("deny-internal-domains-response-status-code", "Defines the response status code for a request identified as to an internal domain when -deny-internal-domains is set.").
1✔
194
                Default("401").IntVar(&denyInternalRespStatusCode)
1✔
195
        kingpin.Flag("target-access-mode", "Defines target type of the target groups in CloudFormation and how loadbalancer targets are discovered. "+
1✔
196
                "HostPort sets target type to 'instance' and discovers EC2 instances using AWS API and instance filters. "+
1✔
197
                "AWSCNI sets target type to 'ip' and discovers target IPs using Kubernetes API and Pod label selector. "+
1✔
198
                "Legacy is the same as HostPort but does not set target type and relies on CloudFormation to use 'instance' as a default value. "+
1✔
199
                "Changing value from 'Legacy' to 'HostPort' will change target type in CloudFormation and trigger target group recreation and downtime.").
1✔
200
                Required().EnumVar(&targetAccessMode, aws.TargetAccessModeHostPort, aws.TargetAccessModeAWSCNI, aws.TargetAccessModeLegacy)
1✔
201
        kingpin.Flag("target-cni-namespace", "AWS VPC CNI only. Defines the namespace for ingress pods that should be linked to target group.").StringVar(&targetCNINamespace)
1✔
202
        // LabelSelector semantics https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
1✔
203
        kingpin.Flag("target-cni-pod-labelselector", "AWS VPC CNI only. Defines the labelselector for ingress pods that should be linked to target group. Supports simple equality and multi value form (a=x,b=y) as well as complex forms (a IN (x,y,z).").StringVar(&targetCNIPodLabelSelector)
1✔
204
        kingpin.Parse()
1✔
205

1✔
206
        // We currently only support one Ingress API Version
1✔
207
        ingressAPIVersion = kubernetes.IngressAPIVersionNetworking
1✔
208

1✔
209
        blacklistCertArnMap = make(map[string]bool)
1✔
210
        for _, s := range blacklistCertARNs {
1✔
211
                blacklistCertArnMap[s] = true
×
212
        }
×
213

214
        if targetAccessMode == aws.TargetAccessModeAWSCNI {
1✔
215
                if targetCNINamespace == "" {
×
216
                        return fmt.Errorf("target-cni-namespace is required when target-access-mode is set to %s", aws.TargetAccessModeAWSCNI)
×
217
                }
×
218
                // complex selector formats possible, late validation by the k8s client
219
                if targetCNIPodLabelSelector == "" {
×
220
                        return fmt.Errorf("target-cni-pod-labelselector definition cannot be empty when target-access-mode is set to %s", aws.TargetAccessModeAWSCNI)
×
221
                }
×
222
        }
223

224
        if creationTimeout < 1*time.Minute {
1✔
225
                return fmt.Errorf("invalid creation timeout %d. please specify a value > 1min", creationTimeout)
×
226
        }
×
227

228
        if healthCheckPort == 0 || healthCheckPort > 65535 {
1✔
229
                return fmt.Errorf("invalid health check port: %d. please use a valid TCP port", healthCheckPort)
×
230
        }
×
231

232
        for _, v := range []uint{albHealthyThresholdCount, albUnhealthyThresholdCount, nlbHealthyThresholdCount} {
4✔
233
                if v < 2 || v > 10 {
3✔
234
                        return fmt.Errorf("invalid (un)healthy threshold: %d. must be between 2 and 10", v)
×
235
                }
×
236
        }
237

238
        if targetPort == 0 || targetPort > 65535 {
1✔
239
                return fmt.Errorf("invalid target port: %d. please use a valid TCP port", targetPort)
×
240
        }
×
241

242
        if albHTTPTargetPort > 65535 { // default 0
1✔
243
                return fmt.Errorf("invalid ALB HTTP target port: %d. please use a valid TCP port", albHTTPTargetPort)
×
244
        }
×
245

246
        if nlbHTTPTargetPort > 65535 { // default 0
1✔
247
                return fmt.Errorf("invalid NLB HTTP target port: %d. please use a valid TCP port", nlbHTTPTargetPort)
×
248
        }
×
249

250
        if nlbHTTPTargetPort > 0 && !nlbHTTPEnabled {
1✔
251
                return fmt.Errorf("NLB HTTP is not enabled")
×
252
        }
×
253

254
        if maxCertsPerALB > aws.DefaultMaxCertsPerALB {
1✔
255
                return fmt.Errorf("invalid max number of certificates per ALB: %d. AWS does not allow more than %d", maxCertsPerALB, aws.DefaultMaxCertsPerALB)
×
256
        }
×
257

258
        if cwAlarmConfigMap != "" {
1✔
259
                loc, err := kubernetes.ParseResourceLocation(cwAlarmConfigMap)
×
260
                if err != nil {
×
261
                        return fmt.Errorf("failed to parse cloudwatch alarm config map location: %w", err)
×
262
                }
×
263

264
                cwAlarmConfigMapLocation = loc
×
265
        }
266

267
        if kv := strings.Split(certFilterTag, "="); len(kv) != 2 && certFilterTag != "" {
1✔
268
                log.Errorf("Certificate filter tag should be in the format \"key=value\", instead it is set to: %s", certFilterTag)
×
269
        }
×
270

271
        if quietFlag && debugFlag {
1✔
272
                log.Warn("--quiet and --debug flags are both set. Debug will be used as logging level.")
×
273
        }
×
274

275
        if quietFlag {
1✔
276
                log.SetLevel(log.WarnLevel)
×
277
        }
×
278

279
        if debugFlag {
1✔
280
                log.SetLevel(log.DebugLevel)
×
281
        }
×
282

283
        log.SetOutput(os.Stdout)
1✔
284

1✔
285
        return nil
1✔
286
}
287

288
func main() {
×
289
        log.Infof("Starting %s %s", os.Args[0], version)
×
290
        var (
×
291
                awsAdapter  *aws.Adapter
×
292
                kubeAdapter *kubernetes.Adapter
×
293
                kubeConfig  *kubernetes.Config
×
294
                err         error
×
295
        )
×
296
        if err = loadSettings(); err != nil {
×
297
                log.Fatal(err)
×
298
        }
×
299

300
        if versionFlag {
×
301
                log.Infof(`%s
×
302
===========================
×
303
  Version: %s
×
304
  Buildtime: %s
×
305
  GitHash: %s
×
306
`, path.Base(os.Args[0]), version, buildstamp, githash)
×
307
                os.Exit(0)
×
308
        }
×
309
        ctx, cancel := context.WithCancel(context.Background())
×
310
        defer cancel()
×
311
        log.Debug("aws.NewAdapter")
×
312
        awsAdapter, err = aws.NewAdapter(clusterID, controllerID, vpcID, debugFlag, disableInstrumentedHttpClient)
×
313
        if err != nil {
×
314
                log.Fatal(err)
×
315
        }
×
316

317
        customFilter, ok := os.LookupEnv(customTagFilterEnvVarName)
×
318
        if !ok {
×
319
                customFilter = ""
×
320
        }
×
321

322
        awsAdapter = awsAdapter.
×
323
                WithHealthCheckPath(healthCheckPath).
×
324
                WithHealthCheckPort(healthCheckPort).
×
325
                WithHealthCheckInterval(healthCheckInterval).
×
326
                WithHealthCheckTimeout(healthCheckTimeout).
×
327
                WithAlbHealthyThresholdCount(albHealthyThresholdCount).
×
328
                WithAlbUnhealthyThresholdCount(albUnhealthyThresholdCount).
×
329
                WithNlbHealthyThresholdCount(nlbHealthyThresholdCount).
×
330
                WithTargetPort(targetPort).
×
331
                WithALBHTTPTargetPort(albHTTPTargetPort).
×
332
                WithNLBHTTPTargetPort(nlbHTTPTargetPort).
×
333
                WithTargetHTTPS(targetHTTPS).
×
334
                WithCreationTimeout(creationTimeout).
×
335
                WithStackTerminationProtection(stackTerminationProtection).
×
336
                WithIdleConnectionTimeout(idleConnectionTimeout).
×
337
                WithDeregistrationDelayTimeout(deregistrationDelayTimeout).
×
338
                WithControllerID(controllerID).
×
339
                WithSslPolicy(sslPolicy).
×
340
                WithIpAddressType(ipAddressType).
×
341
                WithAlbLogsS3Bucket(albLogsS3Bucket).
×
342
                WithAlbLogsS3Prefix(albLogsS3Prefix).
×
343
                WithHTTPRedirectToHTTPS(httpRedirectToHTTPS).
×
344
                WithNLBCrossZone(nlbCrossZone).
×
345
                WithNLBZoneAffinity(nlbZoneAffinity).
×
346
                WithNLBHTTPEnabled(nlbHTTPEnabled).
×
347
                WithCustomFilter(customFilter).
×
348
                WithStackTags(additionalStackTags).
×
349
                WithInternalDomains(internalDomains).
×
350
                WithDenyInternalDomains(denyInternalDomains).
×
351
                WithInternalDomainsDenyResponse(denyInternalRespBody).
×
352
                WithInternalDomainsDenyResponseStatusCode(denyInternalRespStatusCode).
×
353
                WithInternalDomainsDenyResponseContenType(denyInternalRespContentType).
×
354
                WithTargetAccessMode(targetAccessMode)
×
355

×
356
        log.Debug("certs.NewCachingProvider")
×
357
        certificatesProvider, err := certs.NewCachingProvider(
×
358
                certPollingInterval,
×
359
                blacklistCertArnMap,
×
360
                awsAdapter.NewACMCertificateProvider(certFilterTag),
×
361
                awsAdapter.NewIAMCertificateProvider(certFilterTag),
×
362
        )
×
363
        if err != nil {
×
364
                log.Fatal(err)
×
365
        }
×
366

367
        if apiServerBaseURL == "" {
×
368
                log.Debug("kubernetes.InClusterConfig")
×
369
                kubeConfig, err = kubernetes.InClusterConfig()
×
370
                if err != nil {
×
371
                        log.Fatal(err)
×
372
                }
×
373
        } else {
×
374
                log.Debug("kubernetes.InsecureConfig")
×
375
                kubeConfig = kubernetes.InsecureConfig(apiServerBaseURL)
×
376
        }
×
377

378
        ingressClassFiltersList := []string{}
×
379
        if ingressClassFilters != "" {
×
380
                ingressClassFiltersList = strings.Split(ingressClassFilters, ",")
×
381
        }
×
382

383
        log.Debug("kubernetes.NewAdapter")
×
384
        kubeAdapter, err = kubernetes.NewAdapter(kubeConfig, ingressAPIVersion, ingressClassFiltersList, awsAdapter.SecurityGroupID(), sslPolicy, loadBalancerType, clusterLocalDomain, disableInstrumentedHttpClient)
×
385
        if err != nil {
×
386
                log.Fatal(err)
×
387
        }
×
388
        if targetAccessMode == aws.TargetAccessModeAWSCNI {
×
389
                if err = kubeAdapter.NewInclusterConfigClientset(ctx); err != nil {
×
390
                        log.Fatal(err)
×
391
                }
×
392
                kubeAdapter.WithTargetCNIPodSelector(targetCNINamespace, targetCNIPodLabelSelector)
×
393
        }
394

395
        certificatesPerALB := maxCertsPerALB
×
396
        if disableSNISupport {
×
397
                certificatesPerALB = 1
×
398
        }
×
399

400
        log.Infof("Kubernetes API server: %s", apiServerBaseURL)
×
401
        log.Infof("Cluster ID: %s", awsAdapter.ClusterID())
×
402
        log.Infof("VPC ID: %s", awsAdapter.VpcID())
×
403
        log.Infof("Instance ID: %s", awsAdapter.InstanceID())
×
404
        log.Infof("Security group ID: %s", awsAdapter.SecurityGroupID())
×
NEW
405
        log.Infof("Internal subnet IDs: %s", awsAdapter.FindLBSubnets(string(elbv2Types.LoadBalancerSchemeEnumInternal)))
×
NEW
406
        log.Infof("Public subnet IDs: %s", awsAdapter.FindLBSubnets(string(elbv2Types.LoadBalancerSchemeEnumInternetFacing)))
×
407
        log.Infof("EC2 filters: %s", awsAdapter.FiltersString())
×
408
        log.Infof("Certificates per ALB: %d (SNI: %t)", certificatesPerALB, certificatesPerALB > 1)
×
409
        log.Infof("Blacklisted Certificate ARNs (%d): %s", len(blacklistCertARNs), strings.Join(blacklistCertARNs, ","))
×
410
        log.Infof("Ingress class filters: %s", kubeAdapter.IngressFiltersString())
×
411
        log.Infof("ALB Logging S3 Bucket: %s", awsAdapter.S3Bucket())
×
412
        log.Infof("ALB Logging S3 Prefix: %s", awsAdapter.S3Prefix())
×
413
        log.Infof("CloudWatch Alarm ConfigMap: %s", cwAlarmConfigMapLocation)
×
414
        log.Infof("Default LoadBalancer type: %s", loadBalancerType)
×
415
        log.Infof("Target access mode: %s", targetAccessMode)
×
416
        log.Infof("NLB Cross Zone: %t", nlbCrossZone)
×
417
        log.Infof("NLB Zone Affinity: %s", nlbZoneAffinity)
×
418

×
419
        go handleTerminationSignals(cancel, syscall.SIGTERM, syscall.SIGQUIT)
×
420
        go serveMetrics(metricsAddress)
×
421
        if awsAdapter.TargetCNI.Enabled {
×
422
                go cniEventHandler(ctx, awsAdapter.TargetCNI, awsAdapter.SetTargetsOnCNITargetGroups, kubeAdapter.PodInformer)
×
423
        }
×
424
        startPolling(
×
425
                ctx,
×
426
                certificatesProvider,
×
427
                certificatesPerALB,
×
428
                certTTL,
×
429
                awsAdapter,
×
430
                kubeAdapter,
×
431
                pollingInterval,
×
432
                wafWebAclId,
×
433
        )
×
434

×
435
        log.Infof("Terminating %s", os.Args[0])
×
436
}
437

438
func handleTerminationSignals(cancelFunc func(), signals ...os.Signal) {
×
439
        sigsc := make(chan os.Signal, 1)
×
440
        signal.Notify(sigsc, signals...)
×
441
        <-sigsc
×
442
        cancelFunc()
×
443
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc