Skip to content

Commit 37a5c53

Browse files
committed
adding the new cluster creation code
1 parent 7fe2032 commit 37a5c53

File tree

7 files changed

+110
-12
lines changed

7 files changed

+110
-12
lines changed

.werft/installer-tests.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,16 @@ const TEST_CONFIGURATIONS: { [name: string]: TestConfig } = {
107107
CLOUD: "aws",
108108
DESCRIPTION: "Create an EKS cluster",
109109
PHASES: [
110-
"STANDARD_GKE_CLUSTER",
111-
"STANDARD_EKS_CLUSTER", // this only creates aws dependencies for now
110+
"STANDARD_EKS_CLUSTER",
112111
"CERT_MANAGER",
113112
"EXTERNALDNS",
114113
"CLUSTER_ISSUER",
115114
"ADD_NS_RECORD",
116115
"GENERATE_KOTS_CONFIG",
116+
"RESULTS",
117117
"INSTALL_GITPOD",
118-
// "CHECK_INSTALLATION",
118+
"CHECK_INSTALLATION",
119119
// "RUN_INTEGRATION_TESTS",
120-
"RESULTS",
121120
"DESTROY",
122121
],
123122
},
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
resource "aws_iam_role" "EKSClusterRole" {
2+
name = "${var.cluster_name}-eks-role"
3+
assume_role_policy = jsonencode({
4+
Version = "2012-10-17"
5+
Statement = [
6+
{
7+
Action = "sts:AssumeRole"
8+
Effect = "Allow"
9+
Principal = {
10+
Service = "eks.amazonaws.com"
11+
}
12+
},
13+
]
14+
})
15+
}
16+
17+
resource "aws_iam_role" "NodeGroupRole" {
18+
name = "${var.cluster_name}-node-role"
19+
assume_role_policy = jsonencode({
20+
Version = "2012-10-17"
21+
Statement = [
22+
{
23+
Action = "sts:AssumeRole"
24+
Effect = "Allow"
25+
Principal = {
26+
Service = "ec2.amazonaws.com"
27+
}
28+
},
29+
]
30+
})
31+
}
32+
33+
resource "aws_iam_role_policy_attachment" "AmazonEKSClusterPolicy" {
34+
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
35+
role = aws_iam_role.EKSClusterRole.name
36+
}
37+
38+
resource "aws_iam_role_policy_attachment" "AmazonEKSWorkerNodePolicy" {
39+
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
40+
role = aws_iam_role.NodeGroupRole.name
41+
}
42+
43+
resource "aws_iam_role_policy_attachment" "AmazonEC2ContainerRegistryReadOnly" {
44+
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
45+
role = aws_iam_role.NodeGroupRole.name
46+
}
47+
48+
resource "aws_iam_role_policy_attachment" "AmazonEKS_CNI_Policy" {
49+
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
50+
role = aws_iam_role.NodeGroupRole.name
51+
}
52+
53+
resource "aws_eks_cluster" "gitpod-cluster" {
54+
name = "${var.cluster_name}-name"
55+
role_arn = aws_iam_role.EKSClusterRole.arn
56+
version = "1.21"
57+
58+
vpc_config {
59+
subnet_ids = data.aws_subnet_ids.subnet_ids.ids
60+
61+
security_group_ids = [ aws_security_group.alb.id ]
62+
}
63+
64+
depends_on = [
65+
aws_iam_role_policy_attachment.AmazonEKSClusterPolicy
66+
]
67+
}
68+
69+
resource "aws_eks_node_group" "node-ec2" {
70+
cluster_name = aws_eks_cluster.gitpod-cluster.name
71+
node_group_name = "t3_micro-node_group"
72+
node_role_arn = aws_iam_role.NodeGroupRole.arn
73+
subnet_ids = data.aws_subnet_ids.subnet_ids.ids
74+
75+
scaling_config {
76+
desired_size = 2
77+
max_size = 3
78+
min_size = 1
79+
}
80+
81+
ami_type = "AL2_x86_64"
82+
instance_types = ["t3.micro"]
83+
capacity_type = "ON_DEMAND"
84+
disk_size = 20
85+
86+
depends_on = [
87+
aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy,
88+
aws_iam_role_policy_attachment.AmazonEC2ContainerRegistryReadOnly,
89+
aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy
90+
]
91+
}
92+
93+
resource "null_resource" "example1" {
94+
depends_on = [aws_eks_node_group.node-ec2 ]
95+
provisioner "local-exec" {
96+
command = "aws eks update-kubeconfig --name ${aws_eks_cluster.gitpod-cluster.name} --kubeconfig ${var.kubeconfig}"
97+
}
98+
}

install/infra/terraform/eks/output.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ output "database" {
5353
output "registry" {
5454
sensitive = true
5555
value = try({
56-
server = data.aws_ecr_authorization_token.gitpod.proxy_endpoint
56+
server = aws_ecr_repository.gitpod.repository_url
5757
username = data.aws_ecr_authorization_token.gitpod.user_name
5858
password = data.aws_ecr_authorization_token.gitpod.password
5959
}, {})

install/infra/terraform/tools/issuer/azure/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ resource "kubernetes_manifest" "clusterissuer_gitpod" {
2626
"privateKeySecretRef" = {
2727
"name" = "issuer-account-key"
2828
}
29-
# "server" = "https://acme-v02.api.letsencrypt.org/directory"
30-
"server" = "https://acme-staging-v02.api.letsencrypt.org/directory"
29+
"server" = "https://acme-v02.api.letsencrypt.org/directory"
30+
# "server" = "https://acme-staging-v02.api.letsencrypt.org/directory"
3131
"solvers" = [
3232
{
3333
"dns01" = {

install/tests/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ get-config-aws-storage:
156156
yq m -i tmp_config.yml tmp_2_config.yml
157157

158158
get-config-aws-registry:
159-
export SERVER=$$(terraform output -json registry | yq r - 'server') && \
159+
export SERVER=$$(terraform output -json registry | yq r - 'server' | cut -d / -f 1) && \
160160
export PASSWORD=$$(terraform output -json registry | yq r - 'password') && \
161161
export USERNAME=$$(terraform output -json registry | yq r - 'username') && \
162162
envsubst < ./manifests/kots-config-aws-registry.yaml > tmp_2_config.yml
@@ -174,7 +174,7 @@ license_community_stable := "../licenses/Community.yaml"
174174
license_community_unstable := "../licenses/Community (Unstable).yaml"
175175

176176
install-kots-cli:
177-
curl https://kots.io/install | bash
177+
curl https://kots.io/install/1.72.0 | bash
178178

179179
preflights ?= true
180180
channel ?= unstable

install/tests/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ module "k3s" {
4040
}
4141

4242
locals {
43-
eksmod = try(module.eks, null)
44-
aksmod = try(module.aks, null)
43+
eksmod = module.eks
44+
aksmod = null
45+
# aksmod = try(module.aks
4546
storage = coalesce(try(lookup(local.eksmod, "storage"), null), try(lookup(local.aksmod, "storage"), null))
4647
database = coalesce(try(lookup(local.eksmod, "database"), null), try(lookup(local.aksmod, "database"), null))
4748
registry = coalesce(try(lookup(local.eksmod, "registry"), null), try(lookup(local.aksmod, "registry"), null))

install/tests/manifests/kots-config-aws-storage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: ConfigValues
33
spec:
44
values:
55
store_provider:
6-
value: "S3"
6+
value: "s3"
77
data: "store_provider"
88
store_region:
99
value: "${REGION}"

0 commit comments

Comments
 (0)