Skip to content

Commit 6a096d5

Browse files
committed
massive revamp
1 parent 4c2b773 commit 6a096d5

File tree

14 files changed

+311
-507
lines changed

14 files changed

+311
-507
lines changed

.werft/installer-tests.ts

Lines changed: 39 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ interface InfraConfig {
2222
interface TestConfig {
2323
DESCRIPTION: string;
2424
PHASES: string[];
25-
CLOUD: string;
25+
CLUSTER: string;
2626
}
2727

2828
// Each of the TEST_CONFIGURATIONS define an integration test end-to-end
2929
// It should be a combination of multiple INFRA_PHASES, order of PHASES slice is important
3030
const TEST_CONFIGURATIONS: { [name: string]: TestConfig } = {
3131
STANDARD_GKE_TEST: {
32-
CLOUD: "gcp",
32+
CLUSTER: "gcp",
3333
DESCRIPTION: "Deploy Gitpod on GKE, with managed DNS, and run integration tests",
3434
PHASES: [
35-
"STANDARD_GKE_CLUSTER",
35+
"CREATE_CLUSTER",
3636
"CERT_MANAGER",
37-
"GCP_MANAGED_DNS",
37+
"EXTERNALDNS",
38+
"CLUSTER_ISSUER",
3839
"GENERATE_KOTS_CONFIG",
3940
"INSTALL_GITPOD",
4041
"CHECK_INSTALLATION",
@@ -44,12 +45,13 @@ const TEST_CONFIGURATIONS: { [name: string]: TestConfig } = {
4445
],
4546
},
4647
STANDARD_GKE_UPGRADE_TEST: {
47-
CLOUD: "gcp",
48+
CLUSTER: "gcp",
4849
DESCRIPTION: `Deploy Gitpod on GKE, and test upgrade from ${version} to latest version`,
4950
PHASES: [
50-
"STANDARD_GKE_CLUSTER",
51+
"CREATE_CLUSTER",
5152
"CERT_MANAGER",
52-
"GCP_MANAGED_DNS",
53+
"EXTERNALDNS",
54+
"CLUSTER_ISSUER",
5355
"GENERATE_KOTS_CONFIG",
5456
"INSTALL_GITPOD",
5557
"CHECK_INSTALLATION",
@@ -59,13 +61,14 @@ const TEST_CONFIGURATIONS: { [name: string]: TestConfig } = {
5961
],
6062
},
6163
STANDARD_K3S_TEST: {
62-
CLOUD: "gcp", // the cloud provider is still GCP
64+
CLUSTER: "gcp", // the cloud provider is still GCP
6365
DESCRIPTION:
6466
"Deploy Gitpod on a K3s cluster, created on a GCP instance," +
6567
" with managed DNS and run integrations tests",
6668
PHASES: [
6769
"STANDARD_K3S_CLUSTER_ON_GCP",
6870
"CERT_MANAGER",
71+
"CLUSTER_ISSUER",
6972
"GENERATE_KOTS_CONFIG",
7073
"INSTALL_GITPOD",
7174
"CHECK_INSTALLATION",
@@ -75,24 +78,26 @@ const TEST_CONFIGURATIONS: { [name: string]: TestConfig } = {
7578
],
7679
},
7780
STANDARD_K3S_PREVIEW: {
78-
CLOUD: "gcp",
81+
CLUSTER: "k3s",
7982
DESCRIPTION: "Create a SH Gitpod preview environment on a K3s cluster, created on a GCP instance",
8083
PHASES: [
81-
"STANDARD_K3S_CLUSTER_ON_GCP",
84+
"CREATE_CLUSTER",
8285
"CERT_MANAGER",
86+
"CLUSTER_ISSUER",
87+
"EXTERNALDNS",
8388
"GENERATE_KOTS_CONFIG",
8489
"INSTALL_GITPOD",
8590
"CHECK_INSTALLATION",
8691
"RESULTS",
8792
],
8893
},
8994
STANDARD_AKS_TEST: {
90-
CLOUD: "azure",
95+
CLUSTER: "aks",
9196
DESCRIPTION: "Deploy Gitpod on AKS, with managed DNS, and run integration tests",
9297
PHASES: [
93-
"STANDARD_AKS_CLUSTER",
98+
"CREATE_CLUSTER",
9499
"CERT_MANAGER",
95-
"AZURE_ISSUER",
100+
"CLUSTER_ISSUER",
96101
"EXTERNALDNS",
97102
"ADD_NS_RECORD",
98103
"GENERATE_KOTS_CONFIG",
@@ -104,17 +109,14 @@ const TEST_CONFIGURATIONS: { [name: string]: TestConfig } = {
104109
],
105110
},
106111
STANDARD_EKS_TEST: {
107-
CLOUD: "aws",
108-
DESCRIPTION: "Create an EKS cluster",
112+
CLUSTER: "eks",
113+
DESCRIPTION: "Creates an EKS cluster, install gitpod and run integration tests",
109114
PHASES: [
110-
"STANDARD_GKE_CLUSTER",
115+
"CREATE_CLUSTER",
111116
"CERT_MANAGER",
112117
"EXTERNALDNS",
113-
// TODO phases are:
114-
// external dns with aws
115-
// 1) register domains in AWS, associate with route53
116-
// 2) add the associated ns record to gcp(since we use gitpod-self-hsoted.com domain)
117-
// 3) create cluster issuer with route53 as solver
118+
"CLUSTER_ISSUER",
119+
"ADD_NS_RECORD",
118120
"GENERATE_KOTS_CONFIG",
119121
"INSTALL_GITPOD",
120122
// "CHECK_INSTALLATION",
@@ -126,65 +128,45 @@ const TEST_CONFIGURATIONS: { [name: string]: TestConfig } = {
126128
};
127129

128130
const config: TestConfig = TEST_CONFIGURATIONS[testConfig];
129-
const cloud: string = config.CLOUD;
131+
const cluster: string = config.CLUSTER;
130132

131133
// `INFRA_PHASES` describe the phases that can be mixed
132134
// and matched to form a test configuration
133135
// Each phase should contain a `makeTarget` which
134136
// corresponds to a target in the Makefile in ./nightly-tests/Makefile
135137
const INFRA_PHASES: { [name: string]: InfraConfig } = {
136-
STANDARD_GKE_CLUSTER: {
137-
phase: "create-std-gke-cluster",
138-
makeTarget: "gke-standard-cluster",
139-
description: "Creating a GKE cluster with 1 nodepool each for workspace and server",
140-
},
141-
STANDARD_K3S_CLUSTER_ON_GCP: {
142-
phase: "create-std-k3s-cluster",
143-
makeTarget: "k3s-standard-cluster",
144-
description: "Creating a k3s cluster on GCP with 1 node",
145-
},
146-
STANDARD_AKS_CLUSTER: {
147-
phase: "create-std-aks-cluster",
148-
makeTarget: "aks-standard-cluster",
149-
description: "Creating an aks cluster(azure)",
150-
},
151-
STANDARD_EKS_CLUSTER: {
152-
phase: "create-std-eks-cluster",
153-
makeTarget: "eks-standard-cluster",
154-
description: "Creating a EKS cluster with 1 nodepool each for workspace and server",
138+
CREATE_CLUSTER: {
139+
phase: "create-cluster",
140+
makeTarget: "create-cluster",
141+
description: `Creating a ${cluster} cluster`,
155142
},
156143
CERT_MANAGER: {
157144
phase: "setup-cert-manager",
158145
makeTarget: "cert-manager",
159146
description: "Sets up cert-manager and optional cloud dns secret",
160147
},
161-
GCP_MANAGED_DNS: {
162-
phase: "setup-external-dns-with-cloud-dns",
163-
makeTarget: "managed-dns",
164-
description: "Sets up external-dns & cloudDNS config",
165-
},
166148
GENERATE_KOTS_CONFIG: {
167149
phase: "generate-kots-config",
168-
makeTarget: `generate-kots-config storage=${randomize("storage", cloud)} registry=${randomize(
150+
makeTarget: `generate-kots-config storage=${randomize("storage", cluster)} registry=${randomize(
169151
"registry",
170-
cloud,
171-
)} db=${randomize("db", cloud)}`,
152+
cluster,
153+
)} db=${randomize("db", cluster)}`,
172154
description: `Generate KOTS Config file`,
173155
},
174-
AZURE_ISSUER: {
175-
phase: "setup-azure-cluster-issuer",
176-
makeTarget: "azure-issuer",
177-
description: "Deploys ClusterIssuer for azure",
156+
CLUSTER_ISSUER: {
157+
phase: "setup-cluster-issuer",
158+
makeTarget: "cluster-issuer",
159+
description: `Deploys ClusterIssuer for ${cluster}`,
178160
},
179161
EXTERNALDNS: {
180162
phase: "external-dns",
181-
makeTarget: `external-dns provider=${cloud}`,
182-
description: `Deploys external-dns with ${cloud} provider`,
163+
makeTarget: `external-dns`,
164+
description: `Deploys external-dns with ${cluster} provider`,
183165
},
184166
ADD_NS_RECORD: {
185167
phase: "add-ns-record",
186168
makeTarget: "add-ns-record",
187-
description: "Adds NS record for subdomain under gitpod-self-hosted.com",
169+
description: `Adds NS record for subdomain under gitpod-self-hosted.com for ${cluster}`,
188170
},
189171
INSTALL_GITPOD_IGNORE_PREFLIGHTS: {
190172
phase: "install-gitpod-without-preflights",
@@ -214,7 +196,7 @@ const INFRA_PHASES: { [name: string]: InfraConfig } = {
214196
},
215197
DESTROY: {
216198
phase: "destroy",
217-
makeTarget: "cleanup",
199+
makeTarget: `cleanup cluster=${cluster}`,
218200
description: "Destroy the created infrastucture",
219201
},
220202
RESULTS: {

install/infra/terraform/aks/output.tf

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,32 @@ output "external_dns_secrets" {
3636
}
3737

3838
output "external_dns_settings" {
39-
value = {
40-
provider = "azure"
41-
"azure.resourceGroup" = azurerm_resource_group.gitpod.name
42-
"azure.subscriptionId" = data.azurerm_client_config.current.subscription_id
43-
"azure.tenantId" = data.azurerm_client_config.current.tenant_id
44-
"azure.useManagedIdentityExtension" = true
45-
"azure.userAssignedIdentityID" = azurerm_kubernetes_cluster.k8s.kubelet_identity.0.client_id
46-
}
39+
value = [
40+
{
41+
"name": "provider",
42+
"value": "azure"
43+
},
44+
{
45+
"name": "azure.resourceGroup",
46+
"value": azurerm_resource_group.gitpod.name,
47+
},
48+
{
49+
"name": "azure.subscriptionId",
50+
"value": data.azurerm_client_config.current.subscription_id,
51+
},
52+
{
53+
"name": "azure.tenantId",
54+
"value": data.azurerm_client_config.current.tenant_id,
55+
},
56+
{
57+
"name": "azure.useManagedIdentityExtension",
58+
"value": true
59+
},
60+
{
61+
"name": "azure.userAssignedIdentityID",
62+
"value": azurerm_kubernetes_cluster.k8s.kubelet_identity.0.client_id
63+
},
64+
]
4765
}
4866

4967
output "k8s_connection" {

install/infra/terraform/eks/dns.tf

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
variable "domain_name" {}
2+
variable "cluster_name" {}
3+
4+
terraform {
5+
required_providers {
6+
aws = {
7+
version = " ~> 3.0"
8+
source = "registry.terraform.io/hashicorp/aws"
9+
}
10+
}
11+
}
12+
13+
provider "aws" {
14+
region = "eu-west-1"
15+
}
16+
17+
resource "aws_route53_zone" "gitpod" {
18+
name = var.domain_name
19+
20+
tags = {
21+
Environment = "test"
22+
}
23+
}
24+
25+
resource "aws_iam_policy" "gitpod" {
26+
name = "role-${var.cluster_name}"
27+
28+
# Terraform's "jsonencode" function converts a
29+
# Terraform expression result to valid JSON syntax.
30+
policy = jsonencode({
31+
Version = "2012-10-17",
32+
Statement = [
33+
{
34+
Effect = "Allow",
35+
Action = [
36+
"route53:ChangeResourceRecordSets"
37+
],
38+
Resource = [
39+
"arn:aws:route53:::hostedzone/*"
40+
]
41+
},
42+
{
43+
Effect = "Allow",
44+
Action = [
45+
"route53:ListHostedZones",
46+
"route53:ListResourceRecordSets"
47+
],
48+
Resource = [ "*" ]
49+
}
50+
],
51+
})
52+
}
53+
54+
resource "aws_iam_role" "gitpod" {
55+
name = "iam-route53-${var.cluster_name}"
56+
57+
assume_role_policy = <<POLICY
58+
{
59+
"Version": "2012-10-17",
60+
"Statement": [
61+
{
62+
"Effect": "Allow",
63+
"Principal": {
64+
"Service": "ec2.amazonaws.com"
65+
},
66+
"Action": "sts:AssumeRole"
67+
}
68+
]
69+
}
70+
POLICY
71+
}
72+
73+
resource "aws_iam_role_policy_attachment" "route53" {
74+
policy_arn = resource.aws_iam_policy.gitpod.arn
75+
role = aws_iam_role.gitpod.name
76+
}

0 commit comments

Comments
 (0)