Skip to content

Commit 4b4da2b

Browse files
mselim00annapoornanarayan
authored andcommitted
feat(eksapi): optionally deploy CW infra (aws#660)
1 parent 028778b commit 4b4da2b

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

internal/deployers/eksapi/deployer.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type deployerOptions struct {
6464
CapacityReservation bool `flag:"capacity-reservation" desc:"Use capacity reservation for the unmanaged nodegroup"`
6565
ClusterCreationTimeout time.Duration `flag:"cluster-creation-timeout" desc:"Time to wait for cluster to be created and become active."`
6666
ClusterRoleServicePrincipal string `flag:"cluster-role-service-principal" desc:"Additional service principal that can assume the cluster role"`
67+
DeployCloudwatchInfra bool `flag:"deploy-cloudwatch-infra" desc:"Deploy required infrastructure for emitting metrics to CloudWatch"`
6768
EFA bool `flag:"efa" desc:"Create EFA interfaces on the node of an unmanaged nodegroup. One instance type must be passed if set. Requires --unmanaged-nodes and --instance-types."`
6869
EKSEndpointURL string `flag:"endpoint-url" desc:"Endpoint URL for the EKS API"`
6970
EmitMetrics bool `flag:"emit-metrics" desc:"Record and emit metrics to CloudWatch"`
@@ -210,11 +211,6 @@ func (d *deployer) Up() error {
210211
d.ExpectedAMI = d.AMI
211212
}
212213

213-
// TODO: add the pod identity agent addons because it is required for
214-
// cloudwatch infrastructure. cloudwatch infra might want to be optional.
215-
// this must be prepended to the list in order to respect user overrides.
216-
d.deployerOptions.Addons = slices.Insert(d.deployerOptions.Addons, 0, "eks-pod-identity-agent:default")
217-
218214
if err := d.addonManager.createAddons(d.infra, d.cluster, &d.deployerOptions); err != nil {
219215
return err
220216
}
@@ -241,21 +237,23 @@ func (d *deployer) Up() error {
241237
}
242238
}
243239

244-
klog.Infof("Setting up CloudWatch infrastructure...")
245-
if roleArn, err := d.infraManager.createCloudWatchInfrastructureStack(d.cluster.name); err != nil {
246-
klog.Errorf("CloudWatch infrastructure setup failed: %v", err)
247-
return err
248-
} else {
249-
d.infra.cloudwatchRoleArn = roleArn
250-
klog.Infof("CloudWatch infrastructure setup completed")
251-
}
252-
// Apply CloudWatch infrastructure manifest
253-
manifest := templates.CloudWatchAgentRbac
254-
if err := fwext.ApplyManifests(d.k8sClient.config, manifest); err != nil {
255-
klog.Errorf("CloudWatch infrastructure manifest failed: %v", err)
256-
return err
240+
if d.DeployCloudwatchInfra {
241+
klog.Infof("Setting up CloudWatch infrastructure...")
242+
if roleArn, err := d.infraManager.createCloudWatchInfrastructureStack(d.cluster.name); err != nil {
243+
klog.Errorf("CloudWatch infrastructure setup failed: %v", err)
244+
return err
245+
} else {
246+
d.infra.cloudwatchRoleArn = roleArn
247+
klog.Infof("CloudWatch infrastructure setup completed")
248+
}
249+
// Apply CloudWatch infrastructure manifest
250+
manifest := templates.CloudWatchAgentRbac
251+
if err := fwext.ApplyManifests(d.k8sClient.config, manifest); err != nil {
252+
klog.Errorf("CloudWatch infrastructure manifest failed: %v", err)
253+
return err
254+
}
255+
klog.Infof("CloudWatch infrastructure manifest applied successfully")
257256
}
258-
klog.Infof("CloudWatch infrastructure manifest applied successfully")
259257
return nil
260258
}
261259

@@ -331,6 +329,11 @@ func (d *deployer) verifyUpFlags() error {
331329
klog.Infof("Using default AMI type: %s", d.AMIType)
332330
}
333331
}
332+
if d.DeployCloudwatchInfra {
333+
klog.Infof("Prepending pod identity agent to the list of addons because cloudwatch infrastructure deployment was enabled")
334+
// this must be prepended to the list in order to respect user overrides.
335+
d.deployerOptions.Addons = slices.Insert(d.deployerOptions.Addons, 0, "eks-pod-identity-agent:default")
336+
}
334337
return nil
335338
}
336339

0 commit comments

Comments
 (0)