Skip to content

Commit 2f41e00

Browse files
committed
Configure object storage access
1 parent a0592aa commit 2f41e00

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GITPOD_VERSION="aledbf-eksinstaller.29"
1+
ARG GITPOD_VERSION="aledbf-insts3.1"
22

33
FROM eu.gcr.io/gitpod-core-dev/build/installer:$GITPOD_VERSION as installer
44

lib/registry.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export interface RegistryProps extends cdk.StackProps {
1111
}
1212

1313
export class Registry extends cdk.Stack {
14-
readonly _bucket: string
15-
readonly _iamAccessKey: string
16-
readonly _iamSecretKey: string
17-
1814
constructor(scope: cdk.Construct, id: string, props: RegistryProps) {
1915
super(scope, id, props);
2016

@@ -34,8 +30,6 @@ export class Registry extends cdk.Stack {
3430
});
3531
}
3632

37-
this._bucket = props.bucketName;
38-
3933
const GitpodRegistryAccess = new iam.Policy(this, 'RegistryAccess', {
4034
policyName: 'GitpodS3Access',
4135
statements: [
@@ -82,19 +76,13 @@ export class Registry extends cdk.Stack {
8276
});
8377
accessKey.node.addDependency(user);
8478

85-
this._iamAccessKey = accessKey.ref;
86-
this._iamSecretKey = accessKey.attrSecretAccessKey;
87-
}
88-
89-
get bucketName() {
90-
return this._bucket;
91-
}
92-
93-
get accessKey() {
94-
return this._iamAccessKey;
95-
}
96-
97-
get secretKey() {
98-
return this._iamSecretKey;
79+
new cdk.CfnOutput(this, "AccessKeyId", {
80+
value: accessKey.ref,
81+
exportName: "AccessKeyId",
82+
});
83+
new cdk.CfnOutput(this, "SecretAccessKey", {
84+
value: accessKey.attrSecretAccessKey,
85+
exportName: "SecretAccessKey",
86+
});
9987
}
10088
}

lib/services.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as cdk from '@aws-cdk/core'
33
import * as ec2 from '@aws-cdk/aws-ec2'
44

55
import { Database } from './database';
6-
//import { Registry } from './registry';
6+
import { Registry } from './registry';
77

88
export class ServicesStack extends cdk.Stack {
99
//readonly registry: Registry
@@ -27,13 +27,11 @@ export class ServicesStack extends cdk.Stack {
2727
database.node.addDependency(vpc);
2828

2929
// create permissions to access S3 buckets
30-
/*
31-
this.registry = new Registry(this, 'Registry', {
30+
const registry = new Registry(this, 'Registry', {
3231
env: props.env,
3332
clusterName: `${process.env.CLUSTER_NAME}`,
3433
bucketName: `${process.env.CONTAINER_REGISTRY_BUCKET}`,
3534
createBucket: process.env.CREATE_S3_BUCKET === 'true',
3635
});
37-
*/
3836
}
3937
}

setup.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ function install() {
145145
MYSQL_GITPOD_PASSWORD=$(openssl rand -hex 18)
146146
MYSQL_GITPOD_SECRET="mysql-gitpod-token"
147147
MYSQL_GITPOD_ENCRYPTION_KEY='[{"name":"general","version":1,"primary":true,"material":"4uGh1q8y2DYryJwrVMHs0kWXJlqvHWWt/KJuNi04edI="}]'
148+
SECRET_STORAGE="object-storage-gitpod-token"
148149

149150
# generated password cannot excede 41 characters (RDS limitation)
150151
SSM_KEY="/gitpod/cluster/${CLUSTER_NAME}/region/${AWS_REGION}"
@@ -195,6 +196,13 @@ EOF
195196
--dry-run=client -o yaml | \
196197
kubectl replace --force -f -
197198

199+
echo "Create storage secret..."
200+
kubectl create secret generic "${SECRET_STORAGE}" \
201+
--from-literal=s3AccessKey="$(jq -r '. | to_entries[] | select(.key | startswith("ServicesRegistry")).value.AccessKeyId ' < cdk-outputs.json)" \
202+
--from-literal=s3SecretKey="$(jq -r '. | to_entries[] | select(.key | startswith("ServicesRegistry")).value.SecretAccessKey ' < cdk-outputs.json)" \
203+
--dry-run=client -o yaml | \
204+
kubectl replace --force -f -
205+
198206
local CONFIG_FILE="${DIR}/gitpod-config.yaml"
199207
gitpod-installer init > "${CONFIG_FILE}"
200208

@@ -205,6 +213,9 @@ EOF
205213
yq e -i ".database.external.certificate.kind = \"secret\"" "${CONFIG_FILE}"
206214
yq e -i ".database.external.certificate.name = \"${MYSQL_GITPOD_SECRET}\"" "${CONFIG_FILE}"
207215
yq e -i '.workspace.runtime.containerdRuntimeDir = "/var/lib/containerd/io.containerd.runtime.v2.task/k8s.io"' "${CONFIG_FILE}"
216+
yq e -i ".containerRegistry.s3storage.bucket = \"${CONTAINER_REGISTRY_BUCKET}\"" "${CONFIG_FILE}"
217+
yq e -i ".containerRegistry.s3storage.certificate.kind = \"secret\"" "${CONFIG_FILE}"
218+
yq e -i ".containerRegistry.s3storage.certificate.name = \"${SECRET_STORAGE}\"" "${CONFIG_FILE}"
208219

209220
gitpod-installer \
210221
render \

0 commit comments

Comments
 (0)