Skip to content

Commit

Permalink
fix(getAmi): allow setting master version & explicitly filter Linux AMIs
Browse files Browse the repository at this point in the history
fixes #84
  • Loading branch information
metral committed Mar 28, 2019
1 parent 976c33b commit 79a955a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,11 @@

- feat(workers): add 'nodeAssociatePublicIpAddress' to toggle public IPs
[#81](https://github.com/pulumi/pulumi-eks/pull/81)
- fix(getAmi): allow setting master version & explicitly filter Linux AMIs
[#85](https://github.com/pulumi/pulumi-eks/pull/85)
- Fix a bug where the wrong AMI was being returned due to a loosely defined
regex.
- Add support for setting the master / control plane version of the cluster.

## 0.17.2 (Release March 19, 2019)

Expand Down
7 changes: 7 additions & 0 deletions nodejs/eks/cluster.ts
Expand Up @@ -126,6 +126,7 @@ export function createCore(name: string, args: ClusterOptions, parent: pulumi.Co
const eksCluster = new aws.eks.Cluster(`${name}-eksCluster`, {
roleArn: eksRole.role.apply(r => r.arn),
vpcConfig: { securityGroupIds: [ eksClusterSecurityGroup.id ], subnetIds: subnetIds },
version: args.version,
}, { parent: parent });

// Compute the required kubeconfig. Note that we do not export this value: we want the exported config to
Expand Down Expand Up @@ -393,6 +394,11 @@ export interface ClusterOptions {
* Defaults to `true`.
*/
deployDashboard?: boolean;

/**
* Desired Kubernetes master / control plane version. If you do not specify a value, the latest available version is used.
*/
version?: pulumi.Input<string>;
}

/**
Expand Down Expand Up @@ -512,6 +518,7 @@ export class Cluster extends pulumi.ComponentResource {
maxSize: args.maxSize,
desiredCapacity: args.desiredCapacity,
amiId: args.nodeAmiId,
version: args.version,
}, this, core.provider);
this.nodeSecurityGroup = this.defaultNodeGroup.nodeSecurityGroup;
configDeps.push(this.defaultNodeGroup.cfnStack.id);
Expand Down
51 changes: 43 additions & 8 deletions nodejs/eks/nodegroup.ts
Expand Up @@ -131,6 +131,11 @@ export interface NodeGroupBaseOptions {
* public IPs.
*/
nodeAssociatePublicIpAddress?: boolean;

/**
* Desired Kubernetes master / control plane version. If you do not specify a value, the latest available version is used.
*/
version?: pulumi.Input<string>;
}

/**
Expand Down Expand Up @@ -310,17 +315,47 @@ ${customUserData}
`;
});

let amiId: pulumi.Input<string> = args.amiId!;
let amiId: any = args.amiId!;
const version: pulumi.Input<string> = args.version!;
if (args.amiId === undefined) {
const eksWorkerAmi = aws.getAmi({
filters: [{
name: "name",
values: [ "amazon-eks-node-*" ],
}],
mostRecent: true,
const filters: { name: string; values: string[]}[] = [
{
name: "description",
values: [ "*linux*", "*Linux*" ],
},
{
name: "description",
values: [ "*k8s*/bin/linux/amd64*"],
},
];

if (version !== undefined) {
filters.push(
{
name: "name",
values: [ "amazon-eks-node-" + version + "*" ],
},
);
} else {
filters.push(
{
name: "name",
values: [ "amazon-eks-node-*" ],
},
);
}

const eksWorkerAmiIds = aws.getAmiIds({
filters,
owners: [ "602401143452" ], // Amazon
sortAscending: true,
}, { parent: parent });
amiId = eksWorkerAmi.then(r => r.imageId);

const bestAmiId = eksWorkerAmiIds.then(r => r.ids.pop());
if (!bestAmiId) {
throw new Error("No Linux AMI Id was found.");
}
amiId = bestAmiId;
}

// Enable auto-assignment of public IP addresses on worker nodes for
Expand Down

0 comments on commit 79a955a

Please sign in to comment.