Skip to content

Commit 3edcbb9

Browse files
authored
Digitalocean k8s (#7)
* Attempting first pass at digital ocean * Fixed azure typo * Trying valid do node size * Added Digital Ocean. Easiest yet.
1 parent 592e31f commit 3edcbb9

File tree

5 files changed

+130
-3
lines changed

5 files changed

+130
-3
lines changed

aws-eks/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
2. Create an IAM User with the Administrator policy. Generate access keys and grant it console access. See bottom for notes.
55
3. Fork this repo and set it up with [spacelift.io](https://spacelift.io/) or equivalent.
66
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
7+
5. Make sure to set the directory to aws-eks/
88
6. Run and apply the Terraform (takes 20-30 minutes).
99

1010
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.

azure-aks/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
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).
44
2. Fork this repo and set it up with [spacelift.io](https://spacelift.io/) or equivalent
55
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
6+
4. Make sure to set the directory to azure-aks/
77
4. Run and apply the Terraform (took me 5 minutes)
88

99
## Coder setup Instructions

digitalocean-k8s/Readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Getting Coder Installed
2+
3+
1. Fork this repo and set it up with [spacelift.io](https://spacelift.io/) or equivalent
4+
2. Create a [Digital Ocean API Key](https://cloud.digitalocean.com/account/api) and set it as DIGITALOCEAN_TOKEN
5+
3. Make sure to set the root directory to digitalocean-k8s/
6+
4. Run and apply the Terraform (took me 10 minutes)
7+
8+
## Coder setup Instructions
9+
10+
1. Navigate to the IP address of the load balancer (Networking / Load Balancers.
11+
2. Create the initial username and password.
12+
3. Go to Templates, click Develop in Kubernetes, and click use template
13+
4. Click create template (it will refresh and prompt for 3 more template inputs)
14+
5. Set var.use_kubeconfig to false
15+
6. Set var.namespace to coder
16+
6. Click create template
17+
18+
With the admin user created and the template imported, we are ready to launch a workspace based on that template.
19+
20+
1. Click create workspace from the kubernetes template (templates/kubernetes/workspace)
21+
2. Give it a name and click create
22+
3. Within three minutes, the workspace should launch.
23+
24+
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!

digitalocean-k8s/main.tf

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
terraform {
2+
required_providers {
3+
digitalocean = {
4+
source = "digitalocean/digitalocean"
5+
version = "~> 2.0"
6+
}
7+
}
8+
}
9+
10+
provider "digitalocean" {
11+
}
12+
13+
variable "coder_version" {
14+
default = "0.13.6"
15+
}
16+
17+
resource "digitalocean_kubernetes_cluster" "coder" {
18+
name = "coder"
19+
region = "nyc1"
20+
version = "1.25.4-do.0"
21+
22+
node_pool {
23+
name = "default"
24+
size = "s-2vcpu-4gb"
25+
node_count = 1
26+
}
27+
}
28+
29+
###############################################################
30+
# K8s configuration
31+
###############################################################
32+
provider "kubernetes" {
33+
host = digitalocean_kubernetes_cluster.coder.endpoint
34+
token = digitalocean_kubernetes_cluster.coder.kube_config[0].token
35+
cluster_ca_certificate = base64decode(digitalocean_kubernetes_cluster.coder.kube_config[0].cluster_ca_certificate)
36+
}
37+
38+
resource "kubernetes_namespace" "coder_namespace" {
39+
metadata {
40+
name = "coder"
41+
}
42+
}
43+
44+
###############################################################
45+
# Coder configuration
46+
###############################################################
47+
provider "helm" {
48+
kubernetes {
49+
host = digitalocean_kubernetes_cluster.coder.endpoint
50+
token = digitalocean_kubernetes_cluster.coder.kube_config[0].token
51+
cluster_ca_certificate = base64decode(digitalocean_kubernetes_cluster.coder.kube_config[0].cluster_ca_certificate)
52+
}
53+
}
54+
55+
resource "helm_release" "pg_cluster" {
56+
name = "postgresql"
57+
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
58+
59+
repository = "https://charts.bitnami.com/bitnami"
60+
chart = "postgresql"
61+
62+
set {
63+
name = "auth.username"
64+
value = "coder"
65+
}
66+
67+
set {
68+
name = "auth.password"
69+
value = "coder"
70+
}
71+
72+
set {
73+
name = "auth.database"
74+
value = "coder"
75+
}
76+
77+
set {
78+
name = "persistence.size"
79+
value = "10Gi"
80+
}
81+
}
82+
83+
resource "helm_release" "coder" {
84+
name = "coder"
85+
namespace = kubernetes_namespace.coder_namespace.metadata.0.name
86+
87+
chart = "https://github.com/coder/coder/releases/download/v${var.coder_version}/coder_helm_${var.coder_version}.tgz"
88+
89+
values = [
90+
<<EOT
91+
coder:
92+
env:
93+
- name: CODER_PG_CONNECTION_URL
94+
value: "postgres://coder:coder@postgresql.coder.svc.cluster.local:5432/coder?sslmode=disable"
95+
- name: CODER_EXPERIMENTAL
96+
value: "true"
97+
EOT
98+
]
99+
100+
depends_on = [
101+
helm_release.pg_cluster
102+
]
103+
}

gcloud-gke/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
1. Create a [Google Cloud Account](https://cloud.google.com/), [a project](https://console.cloud.google.com/projectcreate), and [a service account](https://console.cloud.google.com/iam-admin/serviceaccounts/create) in that project with [editor](https://cloud.google.com/iam/docs/understanding-roles#basic) permissions.
44
2. Fork this repo and set it up with [spacelift.io](https://spacelift.io/) or equivalent
55
3. Set [GOOGLE_CREDENTIALS](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#using-terraform-cloud) and TF_VAR_project with the project id from above
6-
4. Make sure to set the directory to gke
6+
4. Make sure to set the directory to gcloud-gke/
77
4. Run and apply the Terraform (takes 10 minutes).
88

99
## Coder setup Instructions

0 commit comments

Comments
 (0)