Skip to content

Commit 592e31f

Browse files
authored
Upgrade to 0.13.6 (#6)
1 parent 38a258d commit 592e31f

21 files changed

+128
-737
lines changed

.DS_Store

-6 KB
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.vscode/
2+
*.DS_Store

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Coder OSS on GKE with Terraform in <20 minutes
1+
# Coder OSS with Terraform
22

33
The purpose of this repo is to demonstrate how remote development environments work using Coder's OSS product. This repo should not be used for production use cases, but simply a proof-of-concept for what coding-in-a-browser feels like using Coder.
44

@@ -8,6 +8,6 @@ The purpose of this repo is to demonstrate how remote development environments w
88

99
Each subfolder in this repo is for a different platform.
1010

11-
* Google GKE
11+
* Google GKE
1212
* Azure AKS
1313
* AWS EKS

aks/Readme.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

eks/Readme.md renamed to aws-eks/Readme.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,32 @@
22

33
1. Create an [AWS Account](https://portal.aws.amazon.com/billing/signup#/start/email).
44
2. Create an IAM User with the Administrator policy. Generate access keys and grant it console access. See bottom for notes.
5-
2. Fork this repo and set it up with [spacelift.io](https://spacelift.io/) or equivalent.
6-
3. Set [AWS_ACCESS_KEY_ID](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) and [AWS_SECRET_ACCESS_KEY](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
7-
4. Make sure to set the directory to eks
8-
4. Run and apply the Terraform (takes 15 minutes).
5+
3. Fork this repo and set it up with [spacelift.io](https://spacelift.io/) or equivalent.
6+
4. Set [AWS_ACCESS_KEY_ID](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) and [AWS_SECRET_ACCESS_KEY](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
7+
5. Make sure to set the directory to eks
8+
6. Run and apply the Terraform (takes 20-30 minutes).
9+
10+
Note: EKS is unstable, and I had more problems with EKS than the rest combined. I've seen weird, unreproducible bugs that required deleting and trying again.
911

1012
## Coder setup Instructions
1113

14+
To get Coder set up initially, we need to give it an admin user and create a kubernetes template for our workspace.
15+
1216
1. Navigate to the DNS of the load balancer (AWS / EC2 / Load balancers).
1317
2. Create the initial username and password.
14-
3. Go to Templates / Kubernetes / Create Workspace and give the workspace a name.
15-
4. Within three minutes, the workspace should launch.
16-
5. Click the code-server button, and start coding.
18+
3. Go to Templates, click Develop in Kubernetes, and click use template
19+
4. Click create template (it will refresh and prompt for 3 more template inputs)
20+
5. Set var.use_kubeconfig to false
21+
6. Set var.namespace to coder
22+
6. Click create template
23+
24+
With the admin user created and the template imported, we are ready to launch a workspace based on that template.
25+
26+
1. Click create workspace from the kubernetes template (templates/kubernetes/workspace)
27+
2. Give it a name and click create
28+
3. Within three minutes, the workspace should launch.
29+
30+
From there, you can click the Terminal button to get an interactive session in the k8s container, or you can click code-server to open up a VSCode window and start coding!
1731

1832
## Why grant the Terraform user Console Access?
1933
Most of the kubernetes resources can only be managed if granted permissions via the kubernetes cluster role binding. The (AWS docs)[https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html] can step you through how to do this. It cannot be granted via IAM alone, except for the IAM user that originally created the EKS cluster. For this reason, it's easiest to grant the Terraform user console access so you can view the properties of the cluster. In production, you'd want to do this differently.

eks/main.tf renamed to aws-eks/main.tf

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
terraform {
22
required_providers {
33
aws = {
4-
source = "hashicorp/aws"
4+
source = "hashicorp/aws"
55
version = "~> 4.0"
66
}
77
}
88
}
99

1010
variable "coder_version" {
11-
default = "0.12.7"
11+
default = "0.13.6"
1212
}
1313

1414
# Configure the AWS Provider
@@ -21,12 +21,12 @@ provider "aws" {
2121
###############################################################
2222
module "vpc" {
2323
source = "terraform-aws-modules/vpc/aws"
24-
name = "coder"
24+
name = "coder"
2525

26-
enable_nat_gateway = true
26+
enable_nat_gateway = true
2727
enable_dns_hostnames = true
2828

29-
cidr = "10.0.0.0/16"
29+
cidr = "10.0.0.0/16"
3030
azs = ["us-east-1a", "us-east-1b", "us-east-1c"]
3131
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
3232
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
@@ -50,9 +50,9 @@ module "eks" {
5050
vpc_id = module.vpc.vpc_id
5151
subnet_ids = module.vpc.private_subnets
5252

53-
cluster_name = "coder"
54-
cluster_version = "1.24"
55-
cluster_endpoint_public_access = true
53+
cluster_name = "coder"
54+
cluster_version = "1.24"
55+
cluster_endpoint_public_access = true
5656
cluster_addons = {
5757
coredns = {
5858
most_recent = true
@@ -102,12 +102,12 @@ provider "kubernetes" {
102102
api_version = "client.authentication.k8s.io/v1beta1"
103103
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name]
104104
command = "aws"
105-
}
105+
}
106106
}
107107

108108
resource "kubernetes_namespace" "coder_namespace" {
109109
metadata {
110-
name = "coder"
110+
name = "coder"
111111
}
112112
}
113113

@@ -122,67 +122,61 @@ provider "helm" {
122122
api_version = "client.authentication.k8s.io/v1beta1"
123123
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name]
124124
command = "aws"
125-
}
125+
}
126126
}
127127
}
128128

129129
resource "helm_release" "pg_cluster" {
130-
name = "postgresql"
131-
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
132-
130+
name = "postgresql"
131+
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
132+
133133
repository = "https://charts.bitnami.com/bitnami"
134134
chart = "postgresql"
135135

136136
set {
137137
name = "auth.username"
138138
value = "coder"
139139
}
140-
140+
141141
set {
142142
name = "auth.password"
143143
value = "coder"
144-
}
145-
144+
}
145+
146146
set {
147147
name = "auth.database"
148148
value = "coder"
149-
}
149+
}
150150

151151
set {
152152
name = "persistence.size"
153153
value = "10Gi"
154-
}
154+
}
155155
}
156156

157157
resource "helm_release" "coder" {
158-
name = "coder"
159-
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
160-
161-
# When v0.13.5 is released, we can unfork the repo
162-
# chart = "https://github.com/coder/coder/releases/download/v${var.coder_version}/coder_helm_${var.coder_version}.tgz"
163-
chart = "./helm"
158+
name = "coder"
159+
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
160+
161+
chart = "https://github.com/coder/coder/releases/download/v${var.coder_version}/coder_helm_${var.coder_version}.tgz"
164162

165163
values = [
166164
<<EOT
167165
coder:
168166
env:
169167
- name: CODER_PG_CONNECTION_URL
170168
value: "postgres://coder:coder@postgresql.coder.svc.cluster.local:5432/coder?sslmode=disable"
171-
- name: CODER_AUTO_IMPORT_TEMPLATES
172-
value: "kubernetes"
169+
- name: CODER_EXPERIMENTAL
170+
value: "true"
173171
EOT
174172
]
175173

176174
set {
177175
name = "coder.service.sessionAffinity"
178176
value = "None"
179177
}
180-
set {
181-
name = "coder.image.tag"
182-
value = "v${var.coder_version}"
183-
}
184178

185179
depends_on = [
186180
helm_release.pg_cluster
187-
]
181+
]
188182
}

azure-aks/Readme.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Getting Coder Installed
2+
3+
1. Create an [Azure Account](https://portal.azure.com/) and [a service principal](https://docs.spacelift.io/integrations/cloud-providers/azure#create-a-service-principal).
4+
2. Fork this repo and set it up with [spacelift.io](https://spacelift.io/) or equivalent
5+
3. Set ARM_CLIENT_ID, ARM_CLIENT_SECRET, ARM_SUBSCRIPTION_ID, ARM_TENANT_ID using the values when you created the service principal.
6+
4. Make sure to set the directory to aks
7+
4. Run and apply the Terraform (took me 5 minutes)
8+
9+
## Coder setup Instructions
10+
11+
1. Navigate to the IP address of the load balancer (Kubernetes services / coder-k8s-cluster / Services & Ingresses.
12+
2. Create the initial username and password.
13+
3. Go to Templates, click Develop in Kubernetes, and click use template
14+
4. Click create template (it will refresh and prompt for 3 more template inputs)
15+
5. Set var.use_kubeconfig to false
16+
6. Set var.namespace to coder
17+
6. Click create template
18+
19+
With the admin user created and the template imported, we are ready to launch a workspace based on that template.
20+
21+
1. Click create workspace from the kubernetes template (templates/kubernetes/workspace)
22+
2. Give it a name and click create
23+
3. Within three minutes, the workspace should launch.
24+
25+
From there, you can click the Terminal button to get an interactive session in the k8s container, or you can click code-server to open up a VSCode window and start coding!

aks/main.tf renamed to azure-aks/main.tf

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ terraform {
88
}
99

1010
variable "coder_version" {
11-
default = "0.12.7"
11+
default = "0.13.6"
1212
}
1313

1414
# Configure the Microsoft Azure Provider
@@ -52,7 +52,7 @@ provider "kubernetes" {
5252

5353
resource "kubernetes_namespace" "coder_namespace" {
5454
metadata {
55-
name = "coder"
55+
name = "coder"
5656
}
5757
}
5858

@@ -69,51 +69,51 @@ provider "helm" {
6969
}
7070

7171
resource "helm_release" "pg_cluster" {
72-
name = "postgresql"
73-
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
74-
72+
name = "postgresql"
73+
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
74+
7575
repository = "https://charts.bitnami.com/bitnami"
7676
chart = "postgresql"
7777

7878
set {
7979
name = "auth.username"
8080
value = "coder"
8181
}
82-
82+
8383
set {
8484
name = "auth.password"
8585
value = "coder"
86-
}
87-
86+
}
87+
8888
set {
8989
name = "auth.database"
9090
value = "coder"
91-
}
91+
}
9292

9393
set {
9494
name = "persistence.size"
9595
value = "10Gi"
96-
}
96+
}
9797
}
9898

9999
resource "helm_release" "coder" {
100-
name = "coder"
101-
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
102-
103-
chart = "https://github.com/coder/coder/releases/download/v${var.coder_version}/coder_helm_${var.coder_version}.tgz"
100+
name = "coder"
101+
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
102+
103+
chart = "https://github.com/coder/coder/releases/download/v${var.coder_version}/coder_helm_${var.coder_version}.tgz"
104104

105105
values = [
106106
<<EOT
107107
coder:
108108
env:
109109
- name: CODER_PG_CONNECTION_URL
110110
value: "postgres://coder:coder@postgresql.coder.svc.cluster.local:5432/coder?sslmode=disable"
111-
- name: CODER_AUTO_IMPORT_TEMPLATES
112-
value: "kubernetes"
111+
- name: CODER_EXPERIMENTAL
112+
value: "true"
113113
EOT
114114
]
115115

116116
depends_on = [
117117
helm_release.pg_cluster
118-
]
118+
]
119119
}

eks/coder_helm_0.12.7.tgz

-6.36 KB
Binary file not shown.

eks/helm/.helmignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

eks/helm/Chart.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)