Skip to content

Commit de3715a

Browse files
committed
Add support for internal ALB and image pull secret
Signed-off-by: Manuel Alejandro de Brito Fontes <[email protected]>
1 parent 73261e1 commit de3715a

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,13 @@ ROUTE53_ZONEID=XXXXXXXXX
1818
# The name of the S3 bucket where the container images that gitpod creates are stored
1919
# If there is no value we create a new bucket with the name "container-registry-<cluster name>-<account ID>"
2020
CONTAINER_REGISTRY_BUCKET=
21+
22+
# Configure the secret name containing the credentials to pull images from private container registries.
23+
# Please do not forget to create the secret!!!
24+
# https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
25+
IMAGE_PULL_SECRET=
26+
27+
# Allow to define internal or internet-facing ALB for gitpod proxy component.
28+
# https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.2/guide/ingress/annotations/#scheme
29+
# https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/how-elastic-load-balancing-works.html#load-balancer-scheme
30+
USE_INTERNAL_ALB=false

lib/charts/assets/ingress.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ metadata:
1818
alb.ingress.kubernetes.io/target-node-labels: gitpod.io/workload_workspaces=true
1919
alb.ingress.kubernetes.io/healthcheck-protocol: HTTPS
2020
alb.ingress.kubernetes.io/backend-protocol: HTTPS
21-
alb.ingress.kubernetes.io/scheme: internet-facing
2221
alb.ingress.kubernetes.io/listen-ports: >-
2322
[{
2423
"HTTP": 80

lib/gitpod.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ import { Database } from './database';
66
import { Registry } from './registry';
77
import { importCluster } from './charts/cluster-utils';
88

9+
var createNestedObject = function (base: any, names: any, value: any) {
10+
var lastName = arguments.length === 3 ? names.pop() : false;
11+
for (var i = 0; i < names.length; i++) {
12+
base = base[names[i]] = base[names[i]] || {};
13+
}
14+
15+
if (lastName) {
16+
base = base[lastName] = value;
17+
}
18+
};
19+
920
// TODO: switch to official gitpod.io build.
1021
const version = "aledbf-mk3.29";
1122

@@ -42,14 +53,22 @@ export class GitpodStack extends cdk.Stack {
4253

4354
replace(/{{issuerName}}/g, 'ca-issuer');
4455

56+
const values = loadYaml(doc);
57+
if (process.env.IMAGE_PULL_SECRET) {
58+
createNestedObject(values, ["components", "workspace", "templates", "default", "spec", "imagePullSecrets"], []);
59+
createNestedObject(values, ["components", "imageBuilderMk3", "registry"], {});
60+
values.components.workspace.templates.default.spec.imagePullSecrets.push({ "name": `${process.env.IMAGE_PULL_SECRET}` });
61+
values.components.imageBuilderMk3.registry.secretName = `${process.env.IMAGE_PULL_SECRET}`;
62+
}
63+
4564
const helmChart = cluster.addHelmChart('GitpodChart', {
4665
chart: 'gitpod',
4766
release: 'gitpod',
4867
repository: 'https://aledbf.github.io/gitpod-chart-cleanup/',
4968
namespace: 'default',
50-
version: '1.2.14',
69+
version: '1.2.15',
5170
wait: true,
52-
values: loadYaml(doc),
71+
values,
5372
});
5473

5574
doc = readYamlDocument(__dirname + '/charts/assets/ingress.yaml');
@@ -61,11 +80,19 @@ export class GitpodStack extends cdk.Stack {
6180
manifest.metadata.annotations["alb.ingress.kubernetes.io/ssl-policy"] = "ELBSecurityPolicy-FS-1-2-Res-2020-10";
6281
}
6382

83+
manifest.metadata.annotations["alb.ingress.kubernetes.io/load-balancer-name"] = `${process.env.CLUSTER_NAME}-${props.env?.region}`;
84+
6485
// if we have a route53 zone ID, enable external-dns.
6586
if (process.env.ROUTE53_ZONEID) {
6687
manifest.metadata.annotations["external-dns.alpha.kubernetes.io/hostname"] = `${props.domain}, *.${props.domain}, *.ws.${props.domain}`;
6788
}
6889

90+
if (process.env.USE_INTERNAL_ALB && process.env.USE_INTERNAL_ALB.toLowerCase() === 'true') {
91+
manifest.metadata.annotations["alb.ingress.kubernetes.io/scheme"] = 'internal';
92+
} else {
93+
manifest.metadata.annotations["alb.ingress.kubernetes.io/scheme"] = 'internet-facing';
94+
}
95+
6996
const gitpodIngress = new KubernetesManifest(this, "gitpod-ingress", {
7097
cluster,
7198
overwrite: true,

0 commit comments

Comments
 (0)