Skip to content

Commit e45f322

Browse files
committed
feat: gcp SA mounts & gke-pod template
1 parent e84519f commit e45f322

File tree

5 files changed

+431
-13
lines changed

5 files changed

+431
-13
lines changed

.github/workflows/gcp-linux.yml .github/workflows/gke-code-server-pod.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Update gcp-linux template
1+
name: Update gke-code-server-pod template
22

33
on:
44
push:
55
branches:
66
- main
77
paths:
8-
- "templates/gcp-linux/main.tf"
9-
- ".github/workflows/gcp-linux.yml"
8+
- "templates/gke-code-server-pod/main.tf"
9+
- ".github/workflows/gke-code-server-pod.yml"
1010
workflow_dispatch:
1111

1212
jobs:
@@ -25,8 +25,8 @@ jobs:
2525
- name: Update Coder Template
2626
uses: matifali/update-coder-template@v3
2727
with:
28-
id: gcp-linux
29-
dir: templates/gcp-linux
28+
id: gke-code-server-pod
29+
dir: templates/gke-code-server-pod
3030
url: https://eric-aks.demo.coder.com
3131
name: ${{ steps.latest_commit.outputs.hash }}
3232
message: ${{ steps.commit_title.outputs.title }}

helm/values.yaml

+24-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ coder:
33
- /bin/sh
44
commandArgs:
55
- -c
6-
# az CLI auth'd via system-assigned identity prior to instantiating Coder server
7-
- az login --identity && /opt/coder server
6+
# az & gcloud CLIs auth'd prior to instantiating Coder server
7+
- az login --identity && gcloud auth activate-service-account --key-file=/var/secrets/gcp/gcp-service-account-key && /opt/coder server
8+
89
image:
910
# custom image with az CLI installed
1011
repo: "docker.io/ericpaulsen/coder-2.7.0"
11-
tag: "az"
12+
tag: "multi-cloud"
1213
pullPolicy: Always
14+
1315
# user-assigned managed identity used for authenticating Terraform to Azure
1416
podLabels:
1517
aadpodidbinding: eric-cluster-pod-identity
@@ -22,14 +24,21 @@ coder:
2224
replicaCount: 1
2325
serviceAccount:
2426
workspacePerms: true
27+
2528
# GCP credentials for Terraform
2629
volumes:
27-
- name: gcp-credential
30+
- name: gke-kubeconfig
31+
secret:
32+
secretName: gke-kubeconfig
33+
- name: gcp-service-account-key
2834
secret:
29-
secretName: gcp-credential
35+
secretName: gcp-service-account-key
3036
volumeMounts:
31-
- name: gcp-credential
32-
mountPath: /var/secrets/google
37+
- name: gke-kubeconfig
38+
mountPath: /var/secrets/gke
39+
readOnly: false
40+
- name: gcp-service-account-key
41+
mountPath: /var/secrets/gcp
3342
readOnly: true
3443

3544
# Coder configuration
@@ -39,13 +48,15 @@ coder:
3948
value: https://eric-aks.demo.coder.com
4049
- name: CODER_WILDCARD_ACCESS_URL
4150
value: '*.eric-aks.demo.coder.com'
51+
4252
# database configuration
4353
- name: CODER_PG_CONNECTION_URL
4454
valueFrom:
4555
secretKeyRef:
4656
key: url
4757
# connection URL for Azure Single Server PostgreSQL
4858
name: azure-db-url
59+
4960
# OIDC/SSO configuration
5061
- name: CODER_OIDC_ISSUER_URL
5162
value: https://login.microsoftonline.com/110f0c0f-cd76-4717-a6f8-4eea3d0f8109/v2.0
@@ -69,6 +80,7 @@ coder:
6980
value: /icon/azure.png
7081
- name: CODER_DISABLE_PASSWORD_AUTH
7182
value: "false"
83+
7284
# self-hosted GitLab integration
7385
- name: CODER_EXTERNAL_AUTH_0_TYPE
7486
value: gitlab
@@ -92,6 +104,7 @@ coder:
92104
value: https://owo.codes/oauth/token
93105
- name: CODER_EXTERNAL_AUTH_0_REGEX
94106
value: owo\.codes
107+
95108
# GitHub SaaS integration
96109
- name: CODER_EXTERNAL_AUTH_1_TYPE
97110
value: github
@@ -107,6 +120,7 @@ coder:
107120
secretKeyRef:
108121
key: client-secret
109122
name: github-secret
123+
110124
# jFrog Artifactory integration
111125
- name: CODER_EXTERNAL_AUTH_2_TYPE
112126
value: jfrog
@@ -130,6 +144,7 @@ coder:
130144
value: /icon/jfrog.svg
131145
- name: CODER_EXTERNAL_AUTH_2_SCOPES
132146
value: applied-permissions/user
147+
133148
- name: CODER_SWAGGER_ENABLE
134149
value: "true" # boolean to enable Swaggger API endpoint, /swagger
135150
- name: CODER_MAX_TOKEN_LIFETIME
@@ -138,6 +153,7 @@ coder:
138153
value: "false" # enables browser-only mode, to block SSH connections
139154
- name: CODER_EXPERIMENTS
140155
value: workspace_actions,template_update_policies,template_autostop_requirement,deployment_health_page
156+
141157
# networking configuration
142158
- name: CODER_DERP_CONFIG_URL
143159
value: https://controlplane.tailscale.com/derpmap/default
@@ -151,6 +167,7 @@ coder:
151167
value: includeSubDomains,preload # two optional fields can be set in the Strict-Transport-Security header
152168
- name: CODER_REDIRECT_TO_ACCESS_URL
153169
value: "false" # specifies whether to redirect requests that do not match the access URL host.
170+
154171
# logging/metrics configuration
155172
- name: CODER_VERBOSE
156173
value: "true"

templates/gcp-linux/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ provider "coder" {
1313
}
1414

1515
provider "google" {
16-
credentials = "/var/secrets/google/gcp-credential"
16+
credentials = "/Users/ericpaulsen/code/cdr/k8s/aks/gcp-credential.json"
1717
zone = data.coder_parameter.zone.value
1818
project = "coder-demo-1"
1919
}
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
name: Develop in a container in a Kubernetes pod
3+
description: The goal is to enable code-server (VS Code in a browser)
4+
tags: [cloud, kubernetes]
5+
---
6+
7+
# code-server (VS Code) template for a workspace in a GKE pod
8+
9+
### Apps included
10+
11+
1. A web-based terminal
12+
1. VS Code IDE in a browwser (Coder's `code-server` project)
13+
14+
### Additional input variables and bash scripting
15+
16+
1. Prompt user and clone/install a dotfiles repository (for personalization settings)
17+
1. Prompt user for compute options (CPU core, memory, and disk)
18+
1. Prompt user for container image to use
19+
1. Prompt user for repo to clone
20+
1. Clone source code repo
21+
1. Download, install and start latest code-server (VS Code-in-a-browser)
22+
1. Download, install and start file-browser to show the contents of the `/home/coder` as a `coder_app` and web icon
23+
1. Add the Access URL and user's Coder session token in the workspace to use the Coder CLI
24+
25+
### Images/languages to choose from
26+
27+
1. NodeJS
28+
1. Golang
29+
1. Java
30+
1. Base (for Rust and Python)
31+
32+
> Note that Rust is installed during the startup script for `~/` configuration
33+
34+
### IDE use
35+
36+
1. While the purpose of this template is to show `code-server` and VS Code in a browser, you can also use the `VS Code Desktop` to download Coder's VS Code extension and the Coder CLI to remotely connect to your Coder workspace from your local installation of VS Code.
37+
38+
### Parameters
39+
40+
Parameters allow users who create workspaces to additional information required in the workspace build. This template will prompt the user for:
41+
42+
1. A Dotfiles repository for workspace personalization `data "coder_parameter" "dotfiles_url"`
43+
2. The size of the persistent volume claim or `/home/coder` directory `data "coder_parameter" "pvc"`
44+
45+
### Coder session token and Access URL injection
46+
47+
Within the agent resource's `startup_script`:
48+
49+
```hcl
50+
coder login ${data.coder_workspace.me.access_url} --token ${data.coder_workspace.me.owner_session_token}
51+
```
52+
53+
### Authentication
54+
55+
This template authenticates to GKE via a mounted `gke-kubeconfig.yaml` on the Coder server.
56+
57+
### Resources
58+
59+
[Coder's Terraform Provider - parameters](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter)
60+
61+
[NodeJS coder-react repo](https://github.com/mark-theshark/coder-react)
62+
63+
[Coder's GoLang v2 repo](https://github.com/coder/coder)
64+
65+
[Coder's code-server TypeScript repo](https://github.com/coder/code-server)
66+
67+
[Golang command line repo](https://github.com/sharkymark/commissions)
68+
69+
[Java Hello World repo](https://github.com/sharkymark/java_helloworld)
70+
71+
[Rust repo](https://github.com/sharkymark/rust-hw)
72+
73+
[Python repo](https://github.com/sharkymark/python_commissions)

0 commit comments

Comments
 (0)