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

chore: onboarding kubecost addon #37

Merged
merged 2 commits into from
Nov 27, 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
12 changes: 12 additions & 0 deletions src/constructs/core-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,16 @@ export class KubeProxyAddon extends CoreAddonAbstract {
serviceAccountName: 'kube-proxy',
});
}
}

export class KubeCostAddon extends CoreAddonAbstract {
/**
*
*/
constructor(scope: Construct, id: string, props: CoreAddonProps) {
super(scope, id, {
...props,
addonName: 'kubecost_kubecost',
});
}
}
16 changes: 15 additions & 1 deletion src/constructs/eks-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as kms from 'aws-cdk-lib/aws-kms';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { Construct } from 'constructs';
import { CommonHelmCharts, StandardHelmProps } from './common-helm-charts';
import { CoreDnsAddon, KubeProxyAddon } from './core-addon';
import { CoreDnsAddon, KubeProxyAddon, KubeCostAddon } from './core-addon';
import {
VpcCniAddonVersion,
VpcEniAddon,
Expand Down Expand Up @@ -105,6 +105,7 @@ export interface EKSClusterProps {
readonly addonProps?: AddonProps;
readonly coreDnsAddonProps?: CoreAddonValuesProps;
readonly kubeProxyAddonProps?: CoreAddonValuesProps;
readonly kubeCostAddonProps?: CoreAddonValuesProps;
readonly region: string;
}

Expand Down Expand Up @@ -411,6 +412,19 @@ export class EKSCluster extends Construct {
});
}

if (props.kubeCostAddonProps) {
const kubeDnsAddonConfig = this.props.kubeCostAddonProps?.addonVersion && this.props.kubeCostAddonProps?.configurationValues
? { addonVersion: this.props.kubeCostAddonProps?.addonVersion, configurationValues: this.props.kubeCostAddonProps?.configurationValues }
: { addonVersion: this.props.kubeCostAddonProps?.addonVersion };

new KubeCostAddon(this, 'KubeCostAddon', {
cluster: this.cluster,
...kubeDnsAddonConfig,
resolveConflicts: true,
});
}


const storageclassDefault = new eks.KubernetesManifest(this, 'gp2', {
overwrite: true,
cluster: this.cluster,
Expand Down
3 changes: 2 additions & 1 deletion src/constructs/eks-managed-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as cdk from 'aws-cdk-lib';
import * as eks from 'aws-cdk-lib/aws-eks';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Construct } from 'constructs';

export interface VpcCniAddonProps extends EksManagedAddonProps {
readonly addonVersion?: VpcCniAddonVersion;
readonly configurationValues?: string;
Expand Down Expand Up @@ -208,4 +209,4 @@ export class VpcEniAddon extends EksManagedAddonAbstract {
awsManagedPolicyName: 'AmazonEKS_CNI_Policy',
});
}
}
}
Loading