Skip to content

Commit

Permalink
Merge pull request #85 from lbrlabs/karpenter_taints
Browse files Browse the repository at this point in the history
add taints to karpenter nodes
  • Loading branch information
jaxxstorm authored Feb 18, 2024
2 parents aa7ad5b + 447e576 commit 2608e22
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 7 deletions.
8 changes: 2 additions & 6 deletions provider/pkg/provider/autoscaledNodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

type Requirement struct {
Key pulumi.StringInput `pulumi:"key"`
Operator pulumi.StringInput `pulumi:"operator"`
Values pulumi.StringArrayInput `pulumi:"values"`
}

type AutoscaledNodeGroupArgs struct {
Annotations *pulumi.StringMapInput `pulumi:"annotations"`
AMIFamily *pulumi.StringInput `pulumi:"amiFamily"`
Taints pulumi.ArrayInput `pulumi:"taints"`
NodeRole pulumi.StringInput `pulumi:"nodeRole"`
SubnetIds pulumi.StringArrayInput `pulumi:"subnetIds"`
SecurityGroupIds pulumi.StringArrayInput `pulumi:"securityGroupIds"`
Expand Down Expand Up @@ -119,6 +114,7 @@ func NewAutoscaledNodeGroup(ctx *pulumi.Context,
"nodeClassRef": map[string]interface{}{
"name": nodeClass.Metadata.Name(),
},
"taints": args.Taints,
},
},
},
Expand Down
20 changes: 20 additions & 0 deletions schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ types:
items:
type: string
description: "The list of values for the requirement."
lbrlabs-eks:index:Taint:
description: Represents a taint for a karpenter node.
type: object
properties:
key:
type: string
description: "The key of the taint."
value:
type: string
description: "The value of the taint."
effect:
type: array
items:
type: string
description: "The effect of the taint."
resources:
lbrlabs-eks:index:Cluster:
isComponent: true
Expand Down Expand Up @@ -321,6 +336,11 @@ resources:
items:
"$ref": "#/types/lbrlabs-eks:index:Requirement"
description: "List of requirements for the node group."
taints:
type: array
items:
"$ref": "/kubernetes/v4.7.1/schema.json#/types/kubernetes:core%2Fv1:Taint"
description: "Optional node taints."
requiredInputs:
- nodeRole
- subnetIds
Expand Down
12 changes: 12 additions & 0 deletions sdk/dotnet/Eks/AutoscaledNodeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ public InputList<string> SubnetIds
set => _subnetIds = value;
}

[Input("taints")]
private InputList<Pulumi.Kubernetes.Types.Inputs.Core.V1.TaintArgs>? _taints;

/// <summary>
/// Optional node taints.
/// </summary>
public InputList<Pulumi.Kubernetes.Types.Inputs.Core.V1.TaintArgs> Taints
{
get => _taints ?? (_taints = new InputList<Pulumi.Kubernetes.Types.Inputs.Core.V1.TaintArgs>());
set => _taints = value;
}

public AutoscaledNodeGroupArgs()
{
}
Expand Down
5 changes: 5 additions & 0 deletions sdk/go/eks/autoscaledNodeGroup.go

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

10 changes: 10 additions & 0 deletions sdk/go/eks/pulumiTypes.go

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

5 changes: 5 additions & 0 deletions sdk/go/eks/x/autoscaledNodeGroup.go

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

10 changes: 10 additions & 0 deletions sdk/go/eks/x/pulumiTypes.go

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

7 changes: 7 additions & 0 deletions sdk/nodejs/autoscaledNodeGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import * as inputs from "./types/input";
import * as outputs from "./types/output";
import * as utilities from "./utilities";

import * as pulumiKubernetes from "@pulumi/kubernetes";

export class AutoscaledNodeGroup extends pulumi.ComponentResource {
/** @internal */
public static readonly __pulumiType = 'lbrlabs-eks:index:AutoscaledNodeGroup';
Expand Down Expand Up @@ -51,6 +53,7 @@ export class AutoscaledNodeGroup extends pulumi.ComponentResource {
resourceInputs["requirements"] = args ? args.requirements : undefined;
resourceInputs["securityGroupIds"] = args ? args.securityGroupIds : undefined;
resourceInputs["subnetIds"] = args ? args.subnetIds : undefined;
resourceInputs["taints"] = args ? args.taints : undefined;
} else {
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
Expand Down Expand Up @@ -86,4 +89,8 @@ export interface AutoscaledNodeGroupArgs {
* List of subnet selector terms for the node group.
*/
subnetIds: pulumi.Input<pulumi.Input<string>[]>;
/**
* Optional node taints.
*/
taints?: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.core.v1.Taint>[]>;
}
1 change: 1 addition & 0 deletions sdk/nodejs/types/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ export interface RequirementArgs {
*/
values?: pulumi.Input<pulumi.Input<string>[]>;
}

23 changes: 22 additions & 1 deletion sdk/python/lbrlabs_pulumi_eks/autoscaled_node_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Any, Mapping, Optional, Sequence, Union, overload
from . import _utilities
from ._inputs import *
import pulumi_kubernetes

__all__ = ['AutoscaledNodeGroupArgs', 'AutoscaledNodeGroup']

Expand All @@ -20,7 +21,8 @@ def __init__(__self__, *,
security_group_ids: pulumi.Input[Sequence[pulumi.Input[str]]],
subnet_ids: pulumi.Input[Sequence[pulumi.Input[str]]],
ami_family: Optional[pulumi.Input[str]] = None,
annotations: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None):
annotations: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
taints: Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_kubernetes.core.v1.TaintArgs']]]] = None):
"""
The set of arguments for constructing a AutoscaledNodeGroup resource.
:param pulumi.Input[str] node_role: Node role for the node group.
Expand All @@ -29,6 +31,7 @@ def __init__(__self__, *,
:param pulumi.Input[Sequence[pulumi.Input[str]]] subnet_ids: List of subnet selector terms for the node group.
:param pulumi.Input[str] ami_family: AMI family for the node group.
:param pulumi.Input[Mapping[str, pulumi.Input[str]]] annotations: Annotations to apply to the node group.
:param pulumi.Input[Sequence[pulumi.Input['pulumi_kubernetes.core.v1.TaintArgs']]] taints: Optional node taints.
"""
pulumi.set(__self__, "node_role", node_role)
pulumi.set(__self__, "requirements", requirements)
Expand All @@ -38,6 +41,8 @@ def __init__(__self__, *,
pulumi.set(__self__, "ami_family", ami_family)
if annotations is not None:
pulumi.set(__self__, "annotations", annotations)
if taints is not None:
pulumi.set(__self__, "taints", taints)

@property
@pulumi.getter(name="nodeRole")
Expand Down Expand Up @@ -111,6 +116,18 @@ def annotations(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]
def annotations(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]):
pulumi.set(self, "annotations", value)

@property
@pulumi.getter
def taints(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_kubernetes.core.v1.TaintArgs']]]]:
"""
Optional node taints.
"""
return pulumi.get(self, "taints")

@taints.setter
def taints(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_kubernetes.core.v1.TaintArgs']]]]):
pulumi.set(self, "taints", value)


class AutoscaledNodeGroup(pulumi.ComponentResource):
@overload
Expand All @@ -123,6 +140,7 @@ def __init__(__self__,
requirements: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RequirementArgs']]]]] = None,
security_group_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
subnet_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
taints: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_kubernetes.core.v1.TaintArgs']]]]] = None,
__props__=None):
"""
Create a AutoscaledNodeGroup resource with the given unique name, props, and options.
Expand All @@ -134,6 +152,7 @@ def __init__(__self__,
:param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RequirementArgs']]]] requirements: List of requirements for the node group.
:param pulumi.Input[Sequence[pulumi.Input[str]]] security_group_ids: List of security group selector terms for the node group.
:param pulumi.Input[Sequence[pulumi.Input[str]]] subnet_ids: List of subnet selector terms for the node group.
:param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_kubernetes.core.v1.TaintArgs']]]] taints: Optional node taints.
"""
...
@overload
Expand Down Expand Up @@ -164,6 +183,7 @@ def _internal_init(__self__,
requirements: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RequirementArgs']]]]] = None,
security_group_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
subnet_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
taints: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_kubernetes.core.v1.TaintArgs']]]]] = None,
__props__=None):
opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
if not isinstance(opts, pulumi.ResourceOptions):
Expand All @@ -189,6 +209,7 @@ def _internal_init(__self__,
if subnet_ids is None and not opts.urn:
raise TypeError("Missing required property 'subnet_ids'")
__props__.__dict__["subnet_ids"] = subnet_ids
__props__.__dict__["taints"] = taints
super(AutoscaledNodeGroup, __self__).__init__(
'lbrlabs-eks:index:AutoscaledNodeGroup',
resource_name,
Expand Down

0 comments on commit 2608e22

Please sign in to comment.