Skip to content

Commit

Permalink
resolves #560, fixing jupyter hub failure
Browse files Browse the repository at this point in the history
  • Loading branch information
shapirov103 committed Jan 12, 2023
1 parent 77df253 commit e657911
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 29 deletions.
27 changes: 15 additions & 12 deletions examples/blueprint-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface BlueprintConstructProps {
export default class BlueprintConstruct {
constructor(scope: Construct, props: cdk.StackProps) {

HelmAddOn.validateHelmVersions = true;
HelmAddOn.validateHelmVersions = false;
HelmAddOn.failOnVersionValidation = false;

// TODO: fix IAM user provisioning for admin user
Expand Down Expand Up @@ -134,15 +134,16 @@ export default class BlueprintConstruct {
irsaRoles: ["CloudWatchFullAccess", "AmazonSQSFullAccess"]
}),
new blueprints.addons.AWSPrivateCAIssuerAddon(),
// new blueprints.addons.JupyterHubAddOn({
// efsConfig: {
// pvcName: "efs-persist",
// removalPolicy: cdk.RemovalPolicy.DESTROY,
// capacity: '10Gi',
// },
// enableIngress: false,
// notebookStack: 'jupyter/datascience-notebook',
// }),
new blueprints.addons.JupyterHubAddOn({
efsConfig: {
pvcName: "efs-persist",
removalPolicy: cdk.RemovalPolicy.DESTROY,
capacity: '10Gi',
},
enableIngress: false,
notebookStack: 'jupyter/datascience-notebook',
values: { prePuller: { hook: { enabled: false }}}
}),
new blueprints.EmrEksAddOn()
];

Expand All @@ -163,16 +164,18 @@ export default class BlueprintConstruct {
{
id: "mng1",
amiType: NodegroupAmiType.AL2_X86_64,
instanceTypes: [new ec2.InstanceType('m5.2xlarge')],
instanceTypes: [new ec2.InstanceType('m5.4xlarge')],
diskSize: 25,
desiredSize: 3,
desiredSize: 2,
maxSize: 3,
nodeGroupSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }
},
{
id: "mng2-customami",
instanceTypes: [new ec2.InstanceType('t3.large')],
nodeGroupCapacityType: CapacityType.SPOT,
desiredSize: 0,
minSize: 0,
customAmi: {
machineImage: ec2.MachineImage.genericLinux({
'us-east-1': 'ami-08e520f5673ee0894',
Expand Down
2 changes: 1 addition & 1 deletion lib/addons/ack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const defaultProps: AckAddOnProps = {
/**
* Main class to instantiate the Helm chart
*/
@Reflect.metadata("strictOrder", true)
@Reflect.metadata("ordered", true)
export class AckAddOn extends HelmAddOn {

readonly options: AckAddOnProps;
Expand Down
2 changes: 1 addition & 1 deletion lib/addons/cert-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultProps: HelmAddOnProps & CertManagerAddOnProps = {
name: "blueprints-cert-manager-addon",
namespace: "cert-manager",
chart: "cert-manager",
version: "1.10.1",
version: "1.11.0",
release: "cert-manager",
repository: "https://charts.jetstack.io",
values: {},
Expand Down
2 changes: 1 addition & 1 deletion lib/addons/efs-csi-driver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface EfsCsiDriverProps extends HelmAddOnUserProps {
* Defaults options for the add-on
*/
const defaultProps: EfsCsiDriverProps = {
version: '2.3.5',
version: '2.3.6',
namespace: "kube-system",
repository: "https://kubernetes-sigs.github.io/aws-efs-csi-driver/",
name: EFS_CSI_DRIVER,
Expand Down
2 changes: 1 addition & 1 deletion lib/addons/external-dns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const defaultProps = {
namespace: 'external-dns',
repository: 'https://charts.bitnami.com/bitnami',
release: 'blueprints-addon-external-dns',
version: '6.12.3',
version: '6.13.0',
values: {},
};

Expand Down
2 changes: 1 addition & 1 deletion lib/addons/jupyterhub/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class JupyterHubAddOn extends HelmAddOn {
}

// Create Helm Chart
const jupyterHubChart = this.addHelmChart(clusterInfo, values, false, true);
const jupyterHubChart = this.addHelmChart(clusterInfo, values, false, false);

// Add dependency
jupyterHubChart.node.addDependency(ns);
Expand Down
2 changes: 1 addition & 1 deletion lib/addons/kube-state-metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const defaultProps: HelmAddOnProps & KubeStateMetricsAddOnProps = {
name: "kube-state-metrics",
namespace: "kube-system",
chart: "kube-state-metrics",
version: "4.27.0",
version: "4.28.0",
release: "kube-state-metrics",
repository: "https://prometheus-community.github.io/helm-charts",
values: {},
Expand Down
2 changes: 1 addition & 1 deletion lib/addons/prometheus-node-exporter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const defaultProps: HelmAddOnProps & PrometheusNodeExporterAddOnProps = {
name: "prometheus-node-exporter",
namespace: "prometheus-node-exporter",
chart: "prometheus-node-exporter",
version: "4.9.0",
version: "4.12.0",
release: "prometheus-node-exporter",
repository: "https://prometheus-community.github.io/helm-charts",
values: {},
Expand Down
27 changes: 25 additions & 2 deletions lib/spi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Cluster, KubernetesVersion, Nodegroup } from 'aws-cdk-lib/aws-eks';
import { Construct } from 'constructs';
import { ResourceProvider } from '.';
import { EksBlueprintProps } from '../stacks';
import { logger } from "../utils/log-utils";

/**
* Data type defining helm repositories for GitOps bootstrapping.
Expand Down Expand Up @@ -121,6 +122,7 @@ export class ClusterInfo {

private readonly provisionedAddOns: Map<string, Construct>;
private readonly scheduledAddOns: Map<string, Promise<Construct>>;
private readonly orderedAddOns: string[];
private resourceContext: ResourceContext;

/**
Expand All @@ -132,6 +134,7 @@ export class ClusterInfo {
this.cluster = cluster;
this.provisionedAddOns = new Map<string, Construct>();
this.scheduledAddOns = new Map<string, Promise<Construct>>();
this.orderedAddOns = [];
}

/**
Expand All @@ -156,6 +159,12 @@ export class ClusterInfo {
* @param construct
*/
public addProvisionedAddOn(addOn: string, construct: Construct) {
if(this.isOrderedAddOn(addOn) && this.provisionedAddOns.size > 0){
const prev : Construct = Array.from(this.provisionedAddOns.values()).pop()!;
construct.node.addDependency(prev);
const prevAddOn = Array.from(this.provisionedAddOns.keys()).pop()!;
logger.debug(`Adding dependency from ${addOn} to ${prevAddOn}`);
}
this.provisionedAddOns.set(addOn, construct);
}

Expand All @@ -172,7 +181,7 @@ export class ClusterInfo {
* Returns all provisioned addons
* @returns scheduledAddOns: Map<string, cdk.Construct>
*/
public getAllProvisionedAddons(): Map<string, Construct> {
public getAllProvisionedAddons(): Map<string, Construct> {
return this.provisionedAddOns;
}

Expand All @@ -181,11 +190,25 @@ export class ClusterInfo {
* of the addon being provisioned
* @param addOn
* @param promise
* @param ordered if addon depends on previous addons for completion (runs serially)
*/
public addScheduledAddOn(addOn: string, promise: Promise<Construct>) {
public addScheduledAddOn(addOn: string, promise: Promise<Construct>, ordered: boolean) {
this.scheduledAddOns.set(addOn, promise);
if(ordered) {
this.orderedAddOns.push(addOn);
}
}

/**
* Indicates if strict ordering is applied to the addon
* @param addOn addOn key
* @returns
*/
public isOrderedAddOn(addOn: string) {
return this.orderedAddOns.includes(addOn);
}


/**
* Returns the promise for the Addon construct
* @param addOn
Expand Down
10 changes: 5 additions & 5 deletions lib/stacks/eks-blueprint-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MngClusterProvider } from '../cluster-providers/mng-cluster-provider';
import { VpcProvider } from '../resource-providers/vpc';
import * as spi from '../spi';
import * as constraints from '../utils/constraints-utils';
import { getAddOnNameOrId, setupClusterLogging, withUsageTracking } from '../utils';
import * as utils from '../utils';
import { cloneDeep } from '../utils';
import { IKey } from "aws-cdk-lib/aws-kms";
import {KmsKeyProvider} from "../resource-providers/kms-key";
Expand Down Expand Up @@ -208,7 +208,7 @@ export class EksBlueprint extends cdk.Stack {
}

constructor(scope: Construct, blueprintProps: EksBlueprintProps, props?: cdk.StackProps) {
super(scope, blueprintProps.id, withUsageTracking(EksBlueprint.USAGE_ID, props));
super(scope, blueprintProps.id, utils.withUsageTracking(EksBlueprint.USAGE_ID, props));
this.validateInput(blueprintProps);

const resourceContext = this.provideNamedResources(blueprintProps);
Expand Down Expand Up @@ -236,16 +236,16 @@ export class EksBlueprint extends cdk.Stack {

let enableLogTypes: string[] | undefined = blueprintProps.enableControlPlaneLogTypes;
if (enableLogTypes) {
setupClusterLogging(this.clusterInfo.cluster.stack, this.clusterInfo.cluster, enableLogTypes);
utils.setupClusterLogging(this.clusterInfo.cluster.stack, this.clusterInfo.cluster, enableLogTypes);
}

const postDeploymentSteps = Array<spi.ClusterPostDeploy>();

for (let addOn of (blueprintProps.addOns ?? [])) { // must iterate in the strict order
const result = addOn.deploy(this.clusterInfo);
if (result) {
const addOnKey = getAddOnNameOrId(addOn);
this.clusterInfo.addScheduledAddOn(addOnKey, result);
const addOnKey = utils.getAddOnNameOrId(addOn);
this.clusterInfo.addScheduledAddOn(addOnKey, result, utils.isOrderedAddOn(addOn));
}
const postDeploy: any = addOn;
if ((postDeploy as spi.ClusterPostDeploy).postDeploy !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/addon-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function getAddOnNameOrId(addOn: ClusterAddOn): string {
return addOn.id ?? addOn.constructor.name;
}

export function isStrictOrder(addOn: ClusterAddOn) : boolean {
return Reflect.getMetadata("strictOrder", addOn) ?? false;
export function isOrderedAddOn(addOn: ClusterAddOn) : boolean {
return Reflect.getMetadata("ordered", addOn.constructor) ?? false;
}
/**
* Decorator function that accepts a list of AddOns and
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/log-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export const logger = new Logger({
colorizePrettyLogs: true,
displayLogLevel: true,
name: "main",
overwriteConsole: true
overwriteConsole: true,
minLevel: "info"
});

0 comments on commit e657911

Please sign in to comment.