Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LaunchTemplateTagSpecifications to NodeGroupV2 #810

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased
- [Add support for non-default AWS partitions #788](https://github.com/pulumi/pulumi-eks/pull/788)
- [Add support for launchTemplateTagSpecifications within NodeGroupV2 #810](https://github.com/pulumi/pulumi-eks/pull/810)

## 0.42.2 (Released Oct 12, 2022)
- Fix internal registration of NodeGroupV2 resource.
Expand Down
24 changes: 24 additions & 0 deletions examples/nodegroup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ const spot = new eks.NodeGroup("example-ng-simple-spot", {
providers: { kubernetes: cluster1.provider},
});

const withLaunchTemplateTagSpecifications = new eks.NodeGroupV2("example-ng2-launchtemplate-tags", {
cluster: cluster1,
instanceType: "t2.medium",
desiredCapacity: 1,
minSize: 1,
maxSize: 2,
labels: { "ondemand": "true" },
instanceProfile: instanceProfile0,
launchTemplateTagSpecifications: [
{
resourceType: "instance",
tags: {
"foo": "bar",
},
},
{
resourceType: "volume",
tags: {
"foo2": "bar2",
},
},
],
});

// Export the cluster's kubeconfig.
export const kubeconfig1 = cluster1.kubeconfig;

Expand Down
7 changes: 5 additions & 2 deletions nodejs/eks/nodegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ export interface NodeGroupV2Options extends NodeGroupOptions {
*
* Defaults to 50.
*/
minRefreshPercentage?: number;
minRefreshPercentage?: number;

launchTemplateTagSpecifications?: awsInputs.ec2.LaunchTemplateTagSpecification[];
}

/**
Expand Down Expand Up @@ -416,7 +418,7 @@ export class NodeGroupV2 extends pulumi.ComponentResource implements NodeGroupV2
* @param args The arguments for this cluster.
* @param opts A bag of options that control this component's behavior.
*/
constructor(name: string, args: NodeGroupOptions, opts?: pulumi.ComponentResourceOptions) {
constructor(name: string, args: NodeGroupV2Options, opts?: pulumi.ComponentResourceOptions) {
super("eks:index:NodeGroupV2", name, args, opts);

const group = createNodeGroupV2(name, args, this, opts?.provider);
Expand Down Expand Up @@ -938,6 +940,7 @@ ${customUserData}
securityGroups: [nodeSecurityGroupId, ...extraNodeSecurityGroupIds],
}],
userData: userdata,
tagSpecifications: args.launchTemplateTagSpecifications,
}, { parent, provider});

// Compute the worker node group subnets to use from the various approaches.
Expand Down
8 changes: 8 additions & 0 deletions provider/cmd/pulumi-gen-eks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,14 @@ func nodeGroupProperties(cluster, v2 bool) map[string]schema.PropertySpec {
TypeSpec: schema.TypeSpec{Type: "integer"},
Description: "The minimum amount of instances that should remain available during an instance refresh, expressed as a percentage. Defaults to 50.",
}

props["launchTemplateTagSpecifications"] = schema.PropertySpec{
TypeSpec: schema.TypeSpec{
Type: "array",
Items: &schema.TypeSpec{Ref: awsRef("#/types/aws:ec2%2FLaunchTemplateTagSpecification:LaunchTemplateTagSpecification")},
},
Description: "The tag specifications to apply to the launch template.",
}
}

return props
Expand Down
7 changes: 7 additions & 0 deletions provider/cmd/pulumi-resource-eks/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,13 @@
},
"description": "Custom k8s node labels to be attached to each worker node. Adds the given key/value pairs to the `--node-labels` kubelet argument."
},
"launchTemplateTagSpecifications": {
"type": "array",
"items": {
"$ref": "/aws/v5.4.0/schema.json#/types/aws:ec2%2FLaunchTemplateTagSpecification:LaunchTemplateTagSpecification"
},
"description": "The tag specifications to apply to the launch template."
},
"maxSize": {
"type": "integer",
"description": "The maximum number of worker nodes running in the cluster. Defaults to 2."
Expand Down
12 changes: 12 additions & 0 deletions sdk/dotnet/NodeGroupV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ public InputMap<string> Labels
set => _labels = value;
}

[Input("launchTemplateTagSpecifications")]
private InputList<Pulumi.Aws.Ec2.Inputs.LaunchTemplateTagSpecificationArgs>? _launchTemplateTagSpecifications;

/// <summary>
/// The tag specifications to apply to the launch template.
/// </summary>
public InputList<Pulumi.Aws.Ec2.Inputs.LaunchTemplateTagSpecificationArgs> LaunchTemplateTagSpecifications
{
get => _launchTemplateTagSpecifications ?? (_launchTemplateTagSpecifications = new InputList<Pulumi.Aws.Ec2.Inputs.LaunchTemplateTagSpecificationArgs>());
set => _launchTemplateTagSpecifications = value;
}

/// <summary>
/// The maximum number of worker nodes running in the cluster. Defaults to 2.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions sdk/go/eks/nodeGroupV2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions sdk/java/src/main/java/com/pulumi/eks/NodeGroupV2Args.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.pulumi.aws.ec2.SecurityGroup;
import com.pulumi.aws.ec2.SecurityGroupRule;
import com.pulumi.aws.ec2.inputs.LaunchTemplateTagSpecificationArgs;
import com.pulumi.aws.iam.InstanceProfile;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Import;
Expand Down Expand Up @@ -318,6 +319,21 @@ public Optional<Output<Map<String,String>>> labels() {
return Optional.ofNullable(this.labels);
}

/**
* The tag specifications to apply to the launch template.
*
*/
@Import(name="launchTemplateTagSpecifications")
private @Nullable Output<List<LaunchTemplateTagSpecificationArgs>> launchTemplateTagSpecifications;

/**
* @return The tag specifications to apply to the launch template.
*
*/
public Optional<Output<List<LaunchTemplateTagSpecificationArgs>>> launchTemplateTagSpecifications() {
return Optional.ofNullable(this.launchTemplateTagSpecifications);
}

/**
* The maximum number of worker nodes running in the cluster. Defaults to 2.
*
Expand Down Expand Up @@ -558,6 +574,7 @@ private NodeGroupV2Args(NodeGroupV2Args $) {
this.keyName = $.keyName;
this.kubeletExtraArgs = $.kubeletExtraArgs;
this.labels = $.labels;
this.launchTemplateTagSpecifications = $.launchTemplateTagSpecifications;
this.maxSize = $.maxSize;
this.minRefreshPercentage = $.minRefreshPercentage;
this.minSize = $.minSize;
Expand Down Expand Up @@ -993,6 +1010,37 @@ public Builder labels(Map<String,String> labels) {
return labels(Output.of(labels));
}

/**
* @param launchTemplateTagSpecifications The tag specifications to apply to the launch template.
*
* @return builder
*
*/
public Builder launchTemplateTagSpecifications(@Nullable Output<List<LaunchTemplateTagSpecificationArgs>> launchTemplateTagSpecifications) {
$.launchTemplateTagSpecifications = launchTemplateTagSpecifications;
return this;
}

/**
* @param launchTemplateTagSpecifications The tag specifications to apply to the launch template.
*
* @return builder
*
*/
public Builder launchTemplateTagSpecifications(List<LaunchTemplateTagSpecificationArgs> launchTemplateTagSpecifications) {
return launchTemplateTagSpecifications(Output.of(launchTemplateTagSpecifications));
}

/**
* @param launchTemplateTagSpecifications The tag specifications to apply to the launch template.
*
* @return builder
*
*/
public Builder launchTemplateTagSpecifications(LaunchTemplateTagSpecificationArgs... launchTemplateTagSpecifications) {
return launchTemplateTagSpecifications(List.of(launchTemplateTagSpecifications));
}

/**
* @param maxSize The maximum number of worker nodes running in the cluster. Defaults to 2.
*
Expand Down
20 changes: 20 additions & 0 deletions sdk/python/pulumi_eks/node_group_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(__self__, *,
key_name: Optional[pulumi.Input[str]] = None,
kubelet_extra_args: Optional[pulumi.Input[str]] = None,
labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
launch_template_tag_specifications: Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]] = None,
max_size: Optional[pulumi.Input[int]] = None,
min_refresh_percentage: Optional[pulumi.Input[int]] = None,
min_size: Optional[pulumi.Input[int]] = None,
Expand Down Expand Up @@ -91,6 +92,7 @@ def __init__(__self__, *,
:param pulumi.Input[str] key_name: Name of the key pair to use for SSH access to worker nodes.
:param pulumi.Input[str] kubelet_extra_args: Extra args to pass to the Kubelet. Corresponds to the options passed in the `--kubeletExtraArgs` flag to `/etc/eks/bootstrap.sh`. For example, '--port=10251 --address=0.0.0.0'. Note that the `labels` and `taints` properties will be applied to this list (using `--node-labels` and `--register-with-taints` respectively) after to the explicit `kubeletExtraArgs`.
:param pulumi.Input[Mapping[str, pulumi.Input[str]]] labels: Custom k8s node labels to be attached to each worker node. Adds the given key/value pairs to the `--node-labels` kubelet argument.
:param pulumi.Input[Sequence[pulumi.Input['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]] launch_template_tag_specifications: The tag specifications to apply to the launch template.
:param pulumi.Input[int] max_size: The maximum number of worker nodes running in the cluster. Defaults to 2.
:param pulumi.Input[int] min_refresh_percentage: The minimum amount of instances that should remain available during an instance refresh, expressed as a percentage. Defaults to 50.
:param pulumi.Input[int] min_size: The minimum number of worker nodes running in the cluster. Defaults to 1.
Expand Down Expand Up @@ -149,6 +151,8 @@ def __init__(__self__, *,
pulumi.set(__self__, "kubelet_extra_args", kubelet_extra_args)
if labels is not None:
pulumi.set(__self__, "labels", labels)
if launch_template_tag_specifications is not None:
pulumi.set(__self__, "launch_template_tag_specifications", launch_template_tag_specifications)
if max_size is not None:
pulumi.set(__self__, "max_size", max_size)
if min_refresh_percentage is not None:
Expand Down Expand Up @@ -395,6 +399,18 @@ def labels(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:
def labels(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]):
pulumi.set(self, "labels", value)

@property
@pulumi.getter(name="launchTemplateTagSpecifications")
def launch_template_tag_specifications(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]]:
"""
The tag specifications to apply to the launch template.
"""
return pulumi.get(self, "launch_template_tag_specifications")

@launch_template_tag_specifications.setter
def launch_template_tag_specifications(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]]):
pulumi.set(self, "launch_template_tag_specifications", value)

@property
@pulumi.getter(name="maxSize")
def max_size(self) -> Optional[pulumi.Input[int]]:
Expand Down Expand Up @@ -586,6 +602,7 @@ def __init__(__self__,
key_name: Optional[pulumi.Input[str]] = None,
kubelet_extra_args: Optional[pulumi.Input[str]] = None,
labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
launch_template_tag_specifications: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]]] = None,
max_size: Optional[pulumi.Input[int]] = None,
min_refresh_percentage: Optional[pulumi.Input[int]] = None,
min_size: Optional[pulumi.Input[int]] = None,
Expand Down Expand Up @@ -648,6 +665,7 @@ def __init__(__self__,
:param pulumi.Input[str] key_name: Name of the key pair to use for SSH access to worker nodes.
:param pulumi.Input[str] kubelet_extra_args: Extra args to pass to the Kubelet. Corresponds to the options passed in the `--kubeletExtraArgs` flag to `/etc/eks/bootstrap.sh`. For example, '--port=10251 --address=0.0.0.0'. Note that the `labels` and `taints` properties will be applied to this list (using `--node-labels` and `--register-with-taints` respectively) after to the explicit `kubeletExtraArgs`.
:param pulumi.Input[Mapping[str, pulumi.Input[str]]] labels: Custom k8s node labels to be attached to each worker node. Adds the given key/value pairs to the `--node-labels` kubelet argument.
:param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]] launch_template_tag_specifications: The tag specifications to apply to the launch template.
:param pulumi.Input[int] max_size: The maximum number of worker nodes running in the cluster. Defaults to 2.
:param pulumi.Input[int] min_refresh_percentage: The minimum amount of instances that should remain available during an instance refresh, expressed as a percentage. Defaults to 50.
:param pulumi.Input[int] min_size: The minimum number of worker nodes running in the cluster. Defaults to 1.
Expand Down Expand Up @@ -715,6 +733,7 @@ def _internal_init(__self__,
key_name: Optional[pulumi.Input[str]] = None,
kubelet_extra_args: Optional[pulumi.Input[str]] = None,
labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
launch_template_tag_specifications: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]]] = None,
max_size: Optional[pulumi.Input[int]] = None,
min_refresh_percentage: Optional[pulumi.Input[int]] = None,
min_size: Optional[pulumi.Input[int]] = None,
Expand Down Expand Up @@ -760,6 +779,7 @@ def _internal_init(__self__,
__props__.__dict__["key_name"] = key_name
__props__.__dict__["kubelet_extra_args"] = kubelet_extra_args
__props__.__dict__["labels"] = labels
__props__.__dict__["launch_template_tag_specifications"] = launch_template_tag_specifications
__props__.__dict__["max_size"] = max_size
__props__.__dict__["min_refresh_percentage"] = min_refresh_percentage
__props__.__dict__["min_size"] = min_size
Expand Down