Skip to content

Commit

Permalink
feat(eks): expose FargateCluster's defaultProfile (aws#17130)
Browse files Browse the repository at this point in the history
Expose FargateCluster's defaultProfile.

Fixes aws#16149

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kaylanm authored and TikiTDO committed Feb 21, 2022
1 parent 09bb9ad commit d889575
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-eks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ const cluster = new eks.FargateCluster(this, 'MyCluster', {
});
```

`FargateCluster` will create a default `FargateProfile` which can be accessed via the cluster's `defaultProfile` property. The created profile can also be customized by passing options as with `addFargateProfile`.

**NOTE**: Classic Load Balancers and Network Load Balancers are not supported on
pods running on Fargate. For ingress, we recommend that you use the [ALB Ingress
Controller](https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html)
Expand Down
9 changes: 7 additions & 2 deletions packages/@aws-cdk/aws-eks/lib/fargate-cluster.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Construct } from 'constructs';
import { Cluster, ClusterOptions, CoreDnsComputeType } from './cluster';
import { FargateProfileOptions } from './fargate-profile';
import { FargateProfile, FargateProfileOptions } from './fargate-profile';

/**
* Configuration props for EKS Fargate.
Expand All @@ -23,6 +23,11 @@ export interface FargateClusterProps extends ClusterOptions {
* `addFargateProfile`.
*/
export class FargateCluster extends Cluster {
/**
* Fargate Profile that was created with the cluster.
*/
public readonly defaultProfile: FargateProfile;

constructor(scope: Construct, id: string, props: FargateClusterProps) {
super(scope, id, {
...props,
Expand All @@ -31,7 +36,7 @@ export class FargateCluster extends Cluster {
version: props.version,
});

this.addFargateProfile(
this.defaultProfile = this.addFargateProfile(
props.defaultProfile?.fargateProfileName ?? (props.defaultProfile ? 'custom' : 'default'),
props.defaultProfile ?? {
selectors: [
Expand Down

0 comments on commit d889575

Please sign in to comment.