Skip to content

Commit fba27bc

Browse files
committed
progress
1 parent a0b722c commit fba27bc

File tree

6 files changed

+92
-63
lines changed

6 files changed

+92
-63
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ LABEL \
1414
# The coder binary is injected by scripts/build_docker.sh.
1515
ADD coder /opt/coder
1616

17+
# Create coder group and user.
18+
RUN addgroup -g 1000 coder &&
19+
adduser -D -g "" -h /home/coder -G coder -u 1000 coder
20+
USER coder:coder
21+
1722
ENTRYPOINT [ "/opt/coder", "server" ]

helm/Chart.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: coder
33
description: Remote development environments on your infrastructure.
44
home: https://github.com/coder/coder
55

6-
# version and appVersion are injected at release.
6+
# version and appVersion are injected at release and will always be shown as
7+
# 0.1.0 in the repository.
78
type: application
89
version: "0.1.0"
910
appVersion: "0.1.0"

helm/templates/_helpers.tpl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ Create chart name and version as used by the chart label.
1212
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
1313
{{- end }}
1414

15+
{{/*
16+
Selector labels
17+
*/}}
18+
{{- define "coder.selectorLabels" -}}
19+
app.kubernetes.io/name: {{ include "coder.name" . }}
20+
app.kubernetes.io/instance: {{ .Release.Name }}
21+
{{- end }}
22+
1523
{{/*
1624
Common labels
1725
*/}}
@@ -23,11 +31,3 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
2331
{{- end }}
2432
app.kubernetes.io/managed-by: {{ .Release.Service }}
2533
{{- end }}
26-
27-
{{/*
28-
Selector labels
29-
*/}}
30-
{{- define "coder.selectorLabels" -}}
31-
app.kubernetes.io/name: {{ include "coder.name" . }}
32-
app.kubernetes.io/instance: {{ .Release.Name }}
33-
{{- end }}

helm/templates/deployment.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ metadata:
55
labels:
66
{{- include "coder.labels" . | nindent 4 }}
77
spec:
8-
replicas: {{ .Values.coder.replicaCount }}
8+
# NOTE: this is currently not used as coder v2 does not support high
9+
# availability yet.
10+
# replicas: {{ .Values.coder.replicaCount }}
11+
replicas: 1
912
selector:
1013
matchLabels:
1114
{{- include "coder.selectorLabels" . | nindent 6 }}
@@ -15,36 +18,45 @@ spec:
1518
{{- include "coder.selectorLabels" . | nindent 8 }}
1619
spec:
1720
restartPolicy: Always
18-
terminationGracePeriodSeconds: 300
21+
terminationGracePeriodSeconds: 60
1922
containers:
2023
- name: coder
21-
image: "{{ .Values.coder.image.repo }}:{{ .Values.coder.image.tag | default .Chart.AppVersion }}"
24+
image: "{{ .Values.coder.image.repo }}:{{ .Values.coder.image.tag | default (printf "v%v" .Chart.AppVersion) }}"
2225
imagePullPolicy: {{ .Values.coder.image.pullPolicy }}
2326
resources:
2427
{{- toYaml .Values.resources | nindent 12 }}
2528
env:
26-
- name: CODER_ADDRESS
27-
value: "0.0.0.0:80"
2829
{{- if .Values.coder.tls.secretName }}
30+
- name: CODER_ADDRESS
31+
value: "0.0.0.0:443"
2932
- name: CODER_TLS_ENABLE
3033
value: "true"
3134
- name: CODER_TLS_CERT_FILE
3235
value: /etc/ssl/certs/coder/tls.crt
3336
- name: CODER_TLS_KEY_FILE
3437
value: /etc/ssl/certs/coder/tls.key
38+
{{- else }}
39+
- name: CODER_ADDRESS
40+
value: "0.0.0.0:80"
3541
{{- end }}
3642
{{- with .Values.coder.env -}}
3743
{{ toYaml . | nindent 12 }}
3844
{{- end }}
3945
ports:
46+
{{- if .Values.coder.tls.secretName }}
47+
- name: https
48+
containerPort: 443
49+
protocol: TCP
50+
{{- else }}
4051
- name: http
4152
containerPort: 80
4253
protocol: TCP
54+
{{- end }}
4355
readinessProbe:
4456
httpGet:
45-
path: /
57+
path: /api/v2/buildinfo
4658
port: http
4759
livenessProbe:
4860
httpGet:
49-
path: /
61+
path: /api/v2/buildinfo
5062
port: http

helm/templates/service.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{- if .Values.coder.service.enable }}
2+
---
13
apiVersion: v1
24
kind: Service
35
metadata:
@@ -7,13 +9,17 @@ metadata:
79
spec:
810
type: {{ .Values.coder.service.type }}
911
ports:
10-
- name: http
11-
port: 80
12-
targetPort: http
13-
protocol: TCP
12+
{{- if .Values.coder.tls.secretName }}
1413
- name: https
1514
port: 443
1615
targetPort: https
1716
protocol: TCP
17+
{{- else }}
18+
- name: http
19+
port: 80
20+
targetPort: http
21+
protocol: TCP
22+
{{- end }}
1823
selector:
1924
{{- include "coder.selectorLabels" . | nindent 4 }}
25+
{{- end }}

helm/values.yaml

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,68 @@
11
# coder -- Primary configuration for `coder server`.
22
coder:
3-
# coder.replicaCount -- The number of Kubernetes deployment replicas.
4-
replicaCount: 1
3+
# NOTE: this is currently not used as coder v2 does not support high
4+
# availability yet.
5+
# # coder.replicaCount -- The number of Kubernetes deployment replicas.
6+
# replicaCount: 1
57

68
# coder.image -- The image to use for Coder.
79
image:
810
# coder.image.repo -- The repository of the image.
911
repo: "ghcr.io/coder/coder"
10-
# coder.image.tag -- The tag of the image, defaults to the same version as
11-
# the chart.
12-
tag: "{{.Release.Version}}"
12+
# coder.image.tag -- The tag of the image, defaults to {{.Chart.AppVersion}}
13+
# if not set.
14+
tag: ""
1315
# coder.image.pullPolicy -- The pull policy to use for the image. See:
1416
# https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy
1517
pullPolicy: IfNotPresent
1618

19+
# coder.env -- The environment variables to set for Coder. These can be used
20+
# to configure all aspects of `coder server`. Please see `coder server --help`
21+
# for information about what environment variables can be set.
22+
#
23+
# Note: The following environment variables are set by default and cannot be
24+
# overridden:
25+
# - CODER_ADDRESS: set to 0.0.0.0:80 and cannot be changed.
26+
# - CODER_TLS_ENABLE: set if tls.secretName is not empty.
27+
# - CODER_TLS_CERT_FILE: set if tls.secretName is not empty.
28+
# - 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"
34+
35+
# coder.tls -- The TLS configuration for Coder.
36+
tls:
37+
# coder.tls.secretName -- The name of the secret containing the TLS
38+
# certificate. The secret should exist in the same namespace as the Helm
39+
# deployment and should be of type "kubernetes.io/tls". The secret will be
40+
# automatically mounted into the pod if specified, and the correct
41+
# "CODER_TLS_*" environment variables will be set for you.
42+
secretName: ""
43+
44+
# coder.resources -- The resources to request for Coder. These are optional
45+
# and are not set by default.
46+
resources: {}
47+
# limits:
48+
# cpu: 100m
49+
# memory: 128Mi
50+
# requests:
51+
# cpu: 100m
52+
# memory: 128Mi
53+
1754
# coder.service -- The Service object to expose for Coder.
1855
service:
56+
# coder.service.enable -- Whether to create the Service object.
57+
enable: true
1958
# coder.service.type -- The type of service to expose. See:
2059
# https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
2160
type: LoadBalancer
2261
# coder.service.externalTrafficPolicy -- The external traffic policy to use.
23-
# On AWS EKS you may need to change this to "Cluster". See:
62+
# You may need to change this to "Local" to preserve the source IP address
63+
# in some situations.
2464
# https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
25-
externalTrafficPolicy: Local
65+
externalTrafficPolicy: Cluster
2666
# coder.service.loadBalancerIP -- The IP address of the LoadBalancer. If not
2767
# specified, a new IP will be generated each time the load balancer is
2868
# recreated. It is recommended to manually create a static IP address in
@@ -32,7 +72,7 @@ coder:
3272

3373
# coder.ingress -- The Ingress object to expose for Coder.
3474
ingress:
35-
# coder.ingress.enable -- Whether to enable the Ingress.
75+
# coder.ingress.enable -- Whether to create the Ingress object.
3676
enable: false
3777
# coder.ingress.className -- The name of the Ingress class to use.
3878
className: ""
@@ -44,38 +84,3 @@ coder:
4484
enable: false
4585
# coder.ingress.tls.secretName -- The name of the TLS secret to use.
4686
secretName: ""
47-
48-
# coder.tls -- The TLS configuration for Coder.
49-
tls:
50-
# coder.tls.secretName -- The name of the secret containing the TLS
51-
# certificate. The secret should exist in the same namespace as the Helm
52-
# deployment and should be of type "kubernetes.io/tls". The secret will be
53-
# automatically mounted into the pod if specified, and the correct
54-
# "CODER_TLS_*" environment variables will be set for you.
55-
secretName: ""
56-
57-
# coder.resources -- The resources to request for Coder. These are optional
58-
# and are not set by default.
59-
resources: {}
60-
# limits:
61-
# cpu: 100m
62-
# memory: 128Mi
63-
# requests:
64-
# cpu: 100m
65-
# memory: 128Mi
66-
67-
# coder.env -- The environment variables to set for Coder. These can be used
68-
# to configure all aspects of `coder server`. Please see `coder server --help`
69-
# for information about what environment variables can be set.
70-
#
71-
# Note: The following environment variables are set by default and cannot be
72-
# overridden:
73-
# - CODER_ADDRESS: set to 0.0.0.0:80 and cannot be changed.
74-
# - CODER_TLS_ENABLE: set if tls.secretName is not empty.
75-
# - CODER_TLS_CERT_FILE: set if tls.secretName is not empty.
76-
# - CODER_TLS_KEY_FILE: set if tls.secretName is not empty.
77-
env:
78-
- name: CODER_ACCESS_URL
79-
value: "https://coder.example.com"
80-
- name: CODER_PG_CONNECTION_URL
81-
value: "postgres://coder:password@postgres:5432/coder?sslmode=disable"

0 commit comments

Comments
 (0)