Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55890df

Browse files
authored
feat: add helm README, install guide, linters (coder#3268)
1 parent 3610402 commit 55890df

File tree

6 files changed

+234
-13
lines changed

6 files changed

+234
-13
lines changed

.github/workflows/coder.yaml

+40-7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
5353
sh: ${{ steps.filter.outputs.sh }}
5454
ts: ${{ steps.filter.outputs.ts }}
55+
k8s: ${{ steps.filter.outputs.k8s }}
5556
steps:
5657
- uses: actions/checkout@v3
5758
# For pull requests it's not necessary to checkout the code
@@ -69,6 +70,10 @@ jobs:
6970
- "**.sh"
7071
ts:
7172
- 'site/**'
73+
k8s:
74+
- 'helm/**'
75+
- Dockerfile
76+
- scripts/helm.sh
7277
- id: debug
7378
run: |
7479
echo "${{ toJSON(steps.filter )}}"
@@ -136,6 +141,26 @@ jobs:
136141
run: yarn lint
137142
working-directory: site
138143

144+
style-lint-k8s:
145+
name: "style/lint/k8s"
146+
timeout-minutes: 5
147+
needs: changes
148+
if: needs.changes.outputs.k8s == 'true'
149+
runs-on: ubuntu-latest
150+
steps:
151+
- name: Checkout
152+
uses: actions/checkout@v3
153+
154+
- name: Install helm
155+
uses: azure/setup-helm@v3
156+
with:
157+
version: v3.9.2
158+
159+
- name: cd helm && make lint
160+
run: |
161+
cd helm
162+
make lint
163+
139164
gen:
140165
name: "style/gen"
141166
timeout-minutes: 8
@@ -185,14 +210,21 @@ jobs:
185210
path: ${{ steps.go-cache-paths.outputs.go-mod }}
186211
key: ${{ github.job }}-go-mod-${{ hashFiles('**/go.sum') }}
187212

188-
- run: |
213+
- name: Install sqlc
214+
run: |
189215
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.13.0/sqlc_1.13.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
216+
- name: Install protoc-gen-go
217+
run: go install google.golang.org/protobuf/cmd/[email protected]
218+
- name: Install protoc-gen-go-drpc
219+
run: go install storj.io/drpc/cmd/[email protected]
220+
- name: Install goimports
221+
run: go install golang.org/x/tools/cmd/goimports@latest
222+
223+
- name: make gen
224+
run: "make --output-sync -j -B gen"
190225

191-
- run: go install google.golang.org/protobuf/cmd/[email protected]
192-
- run: go install storj.io/drpc/cmd/[email protected]
193-
- run: go install golang.org/x/tools/cmd/goimports@latest
194-
- run: "make --output-sync -j -B gen"
195-
- run: ./scripts/check_unstaged.sh
226+
- name: Check for unstaged files
227+
run: ./scripts/check_unstaged.sh
196228

197229
style-fmt:
198230
name: "style/fmt"
@@ -222,7 +254,8 @@ jobs:
222254
- name: Install shfmt
223255
run: go install mvdan.cc/sh/v3/cmd/[email protected]
224256

225-
- run: |
257+
- name: make fmt
258+
run: |
226259
export PATH=${PATH}:$(go env GOPATH)/bin
227260
make --output-sync -j -B fmt
228261

docs/install.md

+125
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,131 @@ grep /etc/group -e "docker"
103103
sudo systemctl restart coder.service
104104
```
105105
106+
## Kubernetes via Helm
107+
108+
Before proceeding, please ensure that you have both Helm 3.5+ and the
109+
[latest version of Coder](https://github.com/coder/coder/releases) installed.
110+
You will also need to have a Kubernetes cluster running K8s 1.19+.
111+
112+
> See our [Helm README](https://github.com/coder/coder/blob/main/helm#readme)
113+
> file for additional information. Check the
114+
> [values.yaml](https://github.com/coder/coder/blob/main/helm/values.yaml) file
115+
> for a list of supported Helm values and their defaults.
116+
117+
> ⚠️ **Warning**: Helm support is new and not yet complete. There may be changes
118+
> to the Helm chart between releases which require manual values updates. Please
119+
> file an issue if you run into any issues.
120+
>
121+
> Additionally, the Helm chart does not currently automatically configure a
122+
> Service Account and workspace template for use in Coder. See
123+
> [#3265](https://github.com/coder/coder/issues/3265).
124+
125+
1. Create a namespace for Coder, such as `coder`:
126+
127+
```console
128+
$ kubectl create namespace coder
129+
```
130+
131+
1. Create a PostgreSQL deployment. Coder does not manage a database server for
132+
you.
133+
134+
- If you're in a public cloud such as
135+
[Google Cloud](https://cloud.google.com/sql/docs/postgres/),
136+
[AWS](https://aws.amazon.com/rds/postgresql/),
137+
[Azure](https://docs.microsoft.com/en-us/azure/postgresql/), or
138+
[DigitalOcean](https://www.digitalocean.com/products/managed-databases-postgresql),
139+
you can use the managed PostgreSQL offerings they provide. Make sure that
140+
the PostgreSQL service is running and accessible from your cluster. It
141+
should be in the same network, same project, etc.
142+
143+
- You can install Postgres manually on your cluster using the
144+
[Bitnami PostgreSQL Helm chart](https://github.com/bitnami/charts/tree/master/bitnami/postgresql#readme). There are some
145+
[helpful guides](https://phoenixnap.com/kb/postgresql-kubernetes) on the
146+
internet that explain sensible configurations for this chart. Example:
147+
148+
```console
149+
$ helm repo add bitnami https://charts.bitnami.com/bitnami
150+
$ helm install postgres bitnami/postgresql \
151+
--namespace coder \
152+
--set auth.username=coder \
153+
--set auth.password=coder \
154+
--set auth.database=coder \
155+
--set persistence.size=10Gi
156+
```
157+
158+
The cluster-internal DB URL for the above database is:
159+
```
160+
postgres://coder:[email protected]:5432/coder?sslmode=disable
161+
```
162+
163+
> Ensure you set up periodic backups so you don't lose data.
164+
165+
- You can use
166+
[Postgres operator](https://github.com/zalando/postgres-operator) to
167+
manage PostgreSQL deployments on your Kubernetes cluster.
168+
169+
1. Download the latest `coder_helm` package from
170+
[GitHub releases](https://github.com/coder/coder/releases).
171+
172+
1. Create a `values.yaml` with the configuration settings you'd like for your
173+
deployment. For example:
174+
175+
```yaml
176+
coder:
177+
# You can specify any environment variables you'd like to pass to Coder
178+
# here. Coder consumes environment variables listed in
179+
# `coder server --help`, and these environment variables are also passed
180+
# to the workspace provisioner (so you can consume them in your Terraform
181+
# templates for auth keys etc.).
182+
#
183+
# Please keep in mind that you should not set `CODER_ADDRESS`,
184+
# `CODER_TLS_ENABLE`, `CODER_TLS_CERT_FILE` or `CODER_TLS_KEY_FILE` as
185+
# they are already set by the Helm chart and will cause conflicts.
186+
env:
187+
- name: CODER_ACCESS_URL
188+
value: "https://coder.example.com"
189+
- name: CODER_PG_CONNECTION_URL
190+
valueFrom:
191+
secretKeyRef:
192+
# You'll need to create a secret called coder-db-url with your
193+
# Postgres connection URL like:
194+
# postgres://coder:password@postgres:5432/coder?sslmode=disable
195+
name: coder-db-url
196+
key: url
197+
198+
tls:
199+
secretName: my-tls-secret-name
200+
```
201+
202+
> You can view our
203+
> [Helm README](https://github.com/coder/coder/blob/main/helm#readme) for
204+
> details on the values that are available, or you can view the
205+
> [values.yaml](https://github.com/coder/coder/blob/main/helm/values.yaml)
206+
> file directly.
207+
208+
1. Run the following commands to install the chart in your cluster.
209+
210+
```console
211+
$ helm install coder ./coder_helm_x.y.z.tgz \
212+
--namespace coder \
213+
--values values.yaml
214+
```
215+
216+
You can watch Coder start up by running `kubectl get pods`. Once Coder has
217+
started, the `coder-*` pods should enter the `Running` state.
218+
219+
You can view Coder's logs by getting the pod name from `kubectl get pods` and
220+
then running `kubectl logs <pod name>`. You can also view these logs in your
221+
Cloud's log management system if you are using managed Kubernetes.
222+
223+
To upgrade Coder in the future, you can run the following command with a new `coder_helm_x.y.z.tgz` file from GitHub releases:
224+
225+
```console
226+
$ helm upgrade coder ./coder_helm_x.y.z.tgz \
227+
--namespace coder \
228+
-f values.yaml
229+
```
230+
106231
## Manual
107232
108233
We publish self-contained .zip and .tar.gz archives in [GitHub releases](https://github.com/coder/coder/releases). The archives bundle `coder` binary.

helm/.helmignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
.idea/
2222
*.tmproj
2323
.vscode/
24+
Makefile

helm/Makefile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Use a single bash shell for each job, and immediately exit on failure
2+
SHELL := bash
3+
.SHELLFLAGS = -ceu
4+
.ONESHELL:
5+
6+
# This doesn't work on directories.
7+
# See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets
8+
.DELETE_ON_ERROR:
9+
10+
all: lint
11+
.PHONY: all
12+
13+
lint: lint/helm
14+
.PHONY: lint
15+
16+
lint/helm:
17+
helm lint --strict .
18+
.PHONY: lint/helm

helm/README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Coder Helm Chart
2+
3+
This directory contains the Helm chart used to deploy Coder onto a Kubernetes
4+
cluster. It contains the minimum required components to run Coder on Kubernetes,
5+
and notably (compared to Coder Classic) does not include a database server.
6+
7+
## Getting Started
8+
9+
> ⚠️ **Warning**: The main branch in this repository does not represent the
10+
> latest release of Coder. Please reference our installation docs for
11+
> instructions on a tagged release.
12+
13+
View
14+
[our docs](https://coder.com/docs/coder-oss/latest/install#kubernetes-via-helm)
15+
for detailed installation instructions.
16+
17+
## Values
18+
19+
Please refer to [values.yaml](values.yaml) for available Helm values and their
20+
defaults.
21+
22+
A good starting point for your values file is:
23+
24+
```yaml
25+
coder:
26+
# You can specify any environment variables you'd like to pass to Coder
27+
# here. Coder consumes environment variables listed in
28+
# `coder server --help`, and these environment variables are also passed
29+
# to the workspace provisioner (so you can consume them in your Terraform
30+
# templates for auth keys etc.).
31+
#
32+
# Please keep in mind that you should not set `CODER_ADDRESS`,
33+
# `CODER_TLS_ENABLE`, `CODER_TLS_CERT_FILE` or `CODER_TLS_KEY_FILE` as
34+
# they are already set by the Helm chart and will cause conflicts.
35+
env:
36+
- name: CODER_ACCESS_URL
37+
value: "https://coder.example.com"
38+
- name: CODER_PG_CONNECTION_URL
39+
valueFrom:
40+
secretKeyRef:
41+
# You'll need to create a secret called coder-db-url with your
42+
# Postgres connection URL like:
43+
# postgres://coder:password@postgres:5432/coder?sslmode=disable
44+
name: coder-db-url
45+
key: url
46+
47+
tls:
48+
secretName: my-tls-secret-name
49+
```

helm/values.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,13 @@ coder:
1919
# coder.env -- The environment variables to set for Coder. These can be used
2020
# to configure all aspects of `coder server`. Please see `coder server --help`
2121
# for information about what environment variables can be set.
22-
#
2322
# Note: The following environment variables are set by default and cannot be
2423
# overridden:
2524
# - CODER_ADDRESS: set to 0.0.0.0:80 and cannot be changed.
2625
# - CODER_TLS_ENABLE: set if tls.secretName is not empty.
2726
# - CODER_TLS_CERT_FILE: set if tls.secretName is not empty.
2827
# - CODER_TLS_KEY_FILE: set if tls.secretName is not empty.
29-
env:
30-
- name: CODER_ACCESS_URL
31-
value: "https://coder.example.com"
32-
#- name: CODER_PG_CONNECTION_URL
33-
# value: "postgres://coder:password@postgres:5432/coder?sslmode=disable"
28+
env: []
3429

3530
# coder.tls -- The TLS configuration for Coder.
3631
tls:

0 commit comments

Comments
 (0)