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

feat(ClusterArgs/NewCluster): add ingress controller configuration #108

Merged
merged 1 commit into from
Apr 2, 2024
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
40 changes: 40 additions & 0 deletions provider/pkg/provider/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

// ingress configuration args
type IngressConfig struct {
EnableMetrics pulumi.BoolInput `pulumi:"enableMetrics"`
EnableServiceMonitor pulumi.BoolInput `pulumi:"enableServiceMonitor"`
ServiceMonitorNamespace pulumi.StringInput `pulumi:"serviceMonitorNamespace"`
ControllerReplicas pulumi.IntInput `pulumi:"controllerReplicas"`
AdditionalConfig pulumi.MapInput `pulumi:"additionalConfig"`
}

// The set of arguments for creating a Cluster component resource.
type ClusterArgs struct {
ClusterSubnetIds pulumi.StringArrayInput `pulumi:"clusterSubnetIds"`
Expand All @@ -41,6 +50,7 @@ type ClusterArgs struct {
EnableCertManager bool `pulumi:"enableCertManager"`
EnableKarpenter bool `pulumi:"enableKarpenter"`
LetsEncryptEmail string `pulumi:"letsEncryptEmail"`
IngressConfig *IngressConfig `pulumi:"ingressConfig"`
EnableInternalIngress bool `pulumi:"enableInternalIngress"`
EnableExternalIngress bool `pulumi:"enableExternalIngress"`
LbType pulumi.StringInput `pulumi:"lbType"`
Expand Down Expand Up @@ -582,6 +592,18 @@ func NewCluster(ctx *pulumi.Context,
}
}

var realisedIngressConfig IngressConfig

if args.IngressConfig == nil {
realisedIngressConfig = IngressConfig{
EnableMetrics: pulumi.Bool(false),
EnableServiceMonitor: pulumi.Bool(false),
ControllerReplicas: pulumi.Int(1),
}
} else {
realisedIngressConfig = *args.IngressConfig
}

if args.EnableExternalIngress {
nginxIngressExternal, err := helm.NewChart(ctx, fmt.Sprintf("%s-nginx-ext", name), helm.ChartArgs{
Chart: pulumi.String("ingress-nginx"),
Expand All @@ -592,6 +614,15 @@ func NewCluster(ctx *pulumi.Context,
},
Values: pulumi.Map{
"controller": pulumi.Map{
"metrics": pulumi.Map{
"enabled": realisedIngressConfig.EnableMetrics,
"serviceMonitor": pulumi.Map{
"enabled": realisedIngressConfig.EnableServiceMonitor,
"namespace": realisedIngressConfig.ServiceMonitorNamespace,
},
},
"config": realisedIngressConfig.AdditionalConfig,
"replicaCount": realisedIngressConfig.ControllerReplicas,
"admissionWebhooks": pulumi.Map{
"patch": pulumi.Map{
"tolerations": pulumi.MapArray{
Expand Down Expand Up @@ -671,6 +702,15 @@ func NewCluster(ctx *pulumi.Context,
},
Values: pulumi.Map{
"controller": pulumi.Map{
"replicaCount": realisedIngressConfig.ControllerReplicas,
"metrics": pulumi.Map{
"enabled": realisedIngressConfig.EnableMetrics,
"serviceMonitor": pulumi.Map{
"enabled": realisedIngressConfig.EnableServiceMonitor,
"namespace": realisedIngressConfig.ServiceMonitorNamespace,
},
},
"config": realisedIngressConfig.AdditionalConfig,
"admissionWebhooks": pulumi.Map{
"patch": pulumi.Map{
"tolerations": pulumi.MapArray{
Expand Down
31 changes: 29 additions & 2 deletions schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ keywords:
- category/cloud
repository: "https://github.com/lbrlabs/pulumi-lbrlabs-eks"
types:
lbrlabs-eks:index:IngressConfig:
description: Configuration for the ingress controller.
type: object
properties:
enableMetrics:
type: boolean
default: false
description: Enable metrics for the ingress controller.
enableServiceMonitor:
type: boolean
default: false
description: Enable the service monitor for kube-prometheus-stackl.
serviceMonitorNamespace:
type: string
description: The namespace to deploy the service monitor to.
controllerReplicas:
type: number
default: 1
description: The number of replicas of the ingress controller.
additionalConfig:
type: object
additionalProperties:
type: string
description: Additional configuration for the ingress controller.
lbrlabs-eks:index:Requirement:
description: Represents a single requirement with key, operator, and values.
type: object
Expand Down Expand Up @@ -49,6 +73,9 @@ resources:
lbrlabs-eks:index:Cluster:
isComponent: true
inputProperties:
ingressConfig:
"$ref": "#/types/lbrlabs-eks:index:IngressConfig"
description: Configuration for the ingress controller.
clusterVersion:
type: string
description: The version of the EKS cluster to create.
Expand Down Expand Up @@ -248,7 +275,7 @@ resources:
serviceAccountName:
type: string
description: The name of the service account to bind to the role
tags:
tags:
type: object
additionalProperties:
type: string
Expand Down Expand Up @@ -311,7 +338,7 @@ resources:
role:
"$ref": "/aws/v6.14.0/schema.json#/resources/aws:iam%2Frole:Role"
profile:
"$ref": "/aws/v6.14.0/schema.json#/resources/aws:eks%2FfargateProfile:FargateProfile"
"$ref": "/aws/v6.14.0/schema.json#/resources/aws:eks%2FfargateProfile:FargateProfile"
required:
- role
- profile
Expand Down
6 changes: 6 additions & 0 deletions sdk/dotnet/Eks/Cluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ public InputList<string> EnabledClusterLogTypes
[Input("externalDNSVersion")]
public Input<string>? ExternalDNSVersion { get; set; }

/// <summary>
/// Configuration for the ingress controller.
/// </summary>
[Input("ingressConfig")]
public Input<Inputs.IngressConfigArgs>? IngressConfig { get; set; }

/// <summary>
/// The type of loadbalancer to provision.
/// </summary>
Expand Down
63 changes: 63 additions & 0 deletions sdk/dotnet/Eks/Inputs/IngressConfigArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
using Pulumi;

namespace Lbrlabs.PulumiPackage.Eks.Inputs
{

/// <summary>
/// Configuration for the ingress controller.
/// </summary>
public sealed class IngressConfigArgs : global::Pulumi.ResourceArgs
{
[Input("additionalConfig")]
private InputMap<string>? _additionalConfig;

/// <summary>
/// Additional configuration for the ingress controller.
/// </summary>
public InputMap<string> AdditionalConfig
{
get => _additionalConfig ?? (_additionalConfig = new InputMap<string>());
set => _additionalConfig = value;
}

/// <summary>
/// The number of replicas of the ingress controller.
/// </summary>
[Input("controllerReplicas")]
public Input<double>? ControllerReplicas { get; set; }

/// <summary>
/// Enable metrics for the ingress controller.
/// </summary>
[Input("enableMetrics")]
public Input<bool>? EnableMetrics { get; set; }

/// <summary>
/// Enable the service monitor for kube-prometheus-stackl.
/// </summary>
[Input("enableServiceMonitor")]
public Input<bool>? EnableServiceMonitor { get; set; }

/// <summary>
/// The namespace to deploy the service monitor to.
/// </summary>
[Input("serviceMonitorNamespace")]
public Input<string>? ServiceMonitorNamespace { get; set; }

public IngressConfigArgs()
{
ControllerReplicas = 1;
EnableMetrics = false;
EnableServiceMonitor = false;
}
public static new IngressConfigArgs Empty => new IngressConfigArgs();
}
}
7 changes: 7 additions & 0 deletions sdk/go/eks/cluster.go

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

Loading
Loading