Skip to content

Commit

Permalink
feat(eks): Support bootstrap.sh --dns-cluster-ip arg (aws#13890)
Browse files Browse the repository at this point in the history
Add support for EKS customized AMI's `--dns-cluster-ip` arg to
`bootstrap.sh`

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
anguslees authored and hollanddd committed Aug 26, 2021
1 parent d492f8c commit 2b1c1e5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/cluster.ts
Expand Up @@ -1637,6 +1637,16 @@ export interface BootstrapOptions {
*/
readonly dockerConfigJson?: string;

/**
* Overrides the IP address to use for DNS queries within the
* cluster.
*
* @default - 10.100.0.10 or 172.20.0.10 based on the IP
* address of the primary interface.
*/
readonly dnsClusterIp?: string;

/**
* Extra arguments to add to the kubelet. Useful for adding labels or taints.
*
Expand Down
4 changes: 4 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/user-data.ts
Expand Up @@ -27,6 +27,10 @@ export function renderAmazonLinuxUserData(clusterName: string, autoScalingGroup:
extraArgs.push(`--docker-config-json '${options.dockerConfigJson}'`);
}

if (options.dnsClusterIp) {
extraArgs.push(`--dns-cluster-ip ${options.dnsClusterIp}`);
}

if (options.additionalArgs) {
extraArgs.push(options.additionalArgs);
}
Expand Down
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-eks/test/test.user-data.ts
Expand Up @@ -66,6 +66,20 @@ export = {
test.done();
},

'--dns-cluster-ip'(test: Test) {
// GIVEN
const { asg, stack } = newFixtures();

// WHEN
const userData = stack.resolve(renderAmazonLinuxUserData('my-cluster-name', asg, {
dnsClusterIp: '192.0.2.53',
}));

// THEN
test.deepEqual(userData[1], '/etc/eks/bootstrap.sh my-cluster-name --kubelet-extra-args "--node-labels lifecycle=OnDemand" --use-max-pods true --dns-cluster-ip 192.0.2.53');
test.done();
},

'--docker-config-json'(test: Test) {
// GIVEN
const { asg } = newFixtures();
Expand Down

0 comments on commit 2b1c1e5

Please sign in to comment.