Skip to content

Commit

Permalink
chore: onboarding kubecost addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sm-utkarsh committed Nov 27, 2024
1 parent d15e387 commit d0d8e08
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/constructs/eks-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CoreDnsAddon, KubeProxyAddon } from './core-addon';
import {
VpcCniAddonVersion,
VpcEniAddon,
KubeCostAddon,
} from '../constructs/eks-managed-addon';

import {
Expand Down Expand Up @@ -105,6 +106,7 @@ export interface EKSClusterProps {
readonly addonProps?: AddonProps;
readonly coreDnsAddonProps?: CoreAddonValuesProps;
readonly kubeProxyAddonProps?: CoreAddonValuesProps;
readonly kubeCostAddonProps?: KubeCostAddonProps;
readonly region: string;
}

Expand All @@ -113,6 +115,11 @@ export interface AddonProps {
readonly configurationValues?: string;
}

export interface KubeCostAddonProps {
readonly addonVersion?: VpcCniAddonVersion;
readonly configurationValues?: string;
}

export interface CoreAddonValuesProps {
readonly addonVersion?: string;
readonly configurationValues?: string;
Expand Down Expand Up @@ -411,6 +418,17 @@ export class EKSCluster extends Construct {
});
}

if (props.kubeCostAddonProps) {
const kubeCostAddonConfig = 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,
...kubeCostAddonConfig,
resolveConflicts: true,
});
}

const storageclassDefault = new eks.KubernetesManifest(this, 'gp2', {
overwrite: true,
cluster: this.cluster,
Expand Down
13 changes: 13 additions & 0 deletions src/constructs/eks-managed-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,16 @@ export class VpcEniAddon extends EksManagedAddonAbstract {
});
}
}

export class KubeCostAddon extends EksManagedAddonAbstract {
/**
*
*/
constructor(scope: Construct, id: string, props: VpcCniAddonProps) {
super(scope, id, {
...props,
addonName: 'kubecost_kubecost',
serviceAccountName: 'aws-node',
});
}
}

0 comments on commit d0d8e08

Please sign in to comment.