forked from code-dot-org/code-dot-org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskaffold.yaml
More file actions
257 lines (248 loc) · 8.79 KB
/
Copy pathskaffold.yaml
File metadata and controls
257 lines (248 loc) · 8.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# Using skaffold (https://skaffold.dev/) allows us to start a kubernetes cluster
# for code.org development with one command: `skaffold dev`
#
# This is currently an experimental feature, see: k8s/experimental.yaml
#
# IF YOU MODIFY THIS FILE, also fix its sibling k8s/kustomize/skaffold.yaml in the same
# way until we decide between Helm and Kustomize.
apiVersion: skaffold/v4beta13
kind: Config
build:
artifacts:
- image: code-dot-org
sync:
infer:
# rerun watching
# /app/src/lib, /app/src/shared/middleware, /app/src/dashboard/legacy, /app/src/pegasus for **/*.{rb,ru,yml} (ignoring **/migrations/*.rb,test/**/*.rb)\
- '**/*.rb'
- '**/*.ru'
- '**/*.yml'
- '**/*.js'
- '**/*.jsx'
- '**/*.json'
custom:
buildCommand: |
k8s/bin/docker-buildx -f k8s/docker/code-dot-org.dockerfile \
--build-arg CODE_DOT_ORG_CORE="$CODE_DOT_ORG_CORE" \
--build-arg CODE_DOT_ORG_DB_SEED="$CODE_DOT_ORG_DB_SEED" \
--build-arg CODE_DOT_ORG_PEGASUS="$CODE_DOT_ORG_PEGASUS" \
--build-arg CODE_DOT_ORG_STATIC="$CODE_DOT_ORG_STATIC"
dependencies:
dockerfile:
path: k8s/docker/code-dot-org.dockerfile
requires:
- image: code-dot-org-core
alias: CODE_DOT_ORG_CORE
- image: code-dot-org-db-seed
alias: CODE_DOT_ORG_DB_SEED
- image: code-dot-org-pegasus
alias: CODE_DOT_ORG_PEGASUS
- image: code-dot-org-static
alias: CODE_DOT_ORG_STATIC
- image: code-dot-org-core
custom:
# skaffold sync only works when the user is root 😤:
# https://github.com/GoogleContainerTools/skaffold/issues/2479
# If we find a solution, we can drop this override:
buildCommand: |
k8s/bin/docker-buildx -f k8s/docker/code-dot-org-core.dockerfile \
--build-arg USERNAME=root \
--build-arg UID=0 \
--build-arg GID=0
dependencies:
dockerfile:
path: k8s/docker/code-dot-org-core.dockerfile
- image: code-dot-org-pegasus
custom:
buildCommand: k8s/bin/docker-buildx -f k8s/docker/code-dot-org-pegasus.dockerfile
dependencies:
dockerfile:
path: k8s/docker/code-dot-org-pegasus.dockerfile
- image: code-dot-org-static
custom:
buildCommand: k8s/bin/docker-buildx -f k8s/docker/code-dot-org-static.dockerfile
dependencies:
dockerfile:
path: k8s/docker/code-dot-org-static.dockerfile
- image: code-dot-org-db-seed
custom:
buildCommand: k8s/bin/docker-buildx -f k8s/docker/code-dot-org-db-seed.dockerfile
dependencies:
dockerfile:
path: k8s/docker/code-dot-org-db-seed.dockerfile
deploy:
helm:
releases:
- name: cdo
chartPath: ./k8s/helm
setValueTemplates:
image: "{{.IMAGE_FULLY_QUALIFIED_code_dot_org}}"
# skaffold sync only works when the user is root 😤:
# https://github.com/GoogleContainerTools/skaffold/issues/2479
# If we find a solution, we can drop this override:
user.username: root
user.uid: "0"
user.gid: "0"
user.home: /home/root
valuesFiles:
# This list will be extended by skaffold profiles e.g.: k8s/helm/development.values.yaml
- k8s/helm/values.yaml
profiles:
- name: development
activation:
- command: dev
- command: debug
- kubeContext: docker-desktop
patches:
- op: add
path: /deploy/helm/releases/0/valuesFiles/-
value: k8s/helm/development.values.yaml
# In development mode we auto-generate passwords for the cluster-local MySQL/Redis/MinIO
#
# Please note that to change these passwords you BOTH have to delete/edit cdo-local-secrets.env
# AND you have to delete the persistent volume associated with that service, because
# changing the password in helm after first create typically does not modify the
# password in the service's root volume.
- op: add
path: /deploy/helm/releases/0/setValueTemplates/services.mysql.password
value: '{{ cmd "./k8s/bin/cdo-local-secrets" "MYSQL_ROOT_PASSWORD" }}'
- op: add
path: /deploy/helm/releases/0/setValueTemplates/services.redis.password
value: '{{ cmd "./k8s/bin/cdo-local-secrets" "REDIS_PASSWORD" }}'
- op: add
path: /deploy/helm/releases/0/setValueTemplates/services.minio.password
value: '{{ cmd "./k8s/bin/cdo-local-secrets" "MINIO_ROOT_PASSWORD" }}'
# These have to be patches vs in values.yml because they inject local env vars:
- op: add
path: /deploy/helm/releases/0/setValueTemplates/localDev.mounts.hostPaths.home
value: '{{ cmd "sh" "-c" "echo $HOME" }}'
- op: add
path: /deploy/helm/releases/0/setValueTemplates/localDev.mounts.hostPaths.skaffoldStorage
value: '{{ cmd "sh" "-c" "echo $PWD/skaffoldStorage" }}'
- op: add
path: /deploy/helm/releases/0/setValueTemplates/localDev.mounts.AWS_PROFILE
value: '{{ cmd "sh" "-c" "echo $AWS_PROFILE" }}'
# Mount local machine credential directories into the dashboard container so it can
# use your local AWS and gcloud credentials. To use: `skaffold dev -p local-dev`
- name: local-dev
patches:
- op: add
path: /deploy/helm/releases/0/setValues
value:
localDev:
mounts:
mountDotAWS: true
mountDotConfigGcloud: true
# Populates Dashboard DB (rake dashboard:setup_db)
# Run: skaffold dev --trigger=manual -p setup-db -p setup-s3
- name: setup-db
patches:
- op: add
path: /deploy/helm/releases/0/setValueTemplates/dashboardJob
value:
enabled: true
name: setup-db
args: ["cd dashboard && rake dashboard:setup_db && echo 'setup-db COMPLETE'"]
# Create standard cdo-v3-* S3 buckets in minio.
# Run: skaffold dev --trigger=manual -p setup-db -p setup-s3
- name: setup-s3
patches:
- op: add
path: /deploy/helm/releases/0/setValueTemplates/services.minio.runSetupS3Job
value: true
# Mimic allows us to run a light-weight stubbed version of our huge repo. Its great for
# fast iterative development of our k8s docker files and helm charts.
#
# To use:
# 1. First-time: skaffold dev -p mimic --cache-artifacts=false
# 2. Run: skaffold dev -p mimic
#
# For details, see: ./k8s/mimic/README.md
- name: mimic
patches:
# Create the k8s/mimic/cdo-no-symlinks dir to serve as the build context for the
# mimic docker build. This is just a copy of k8s/mimic/code-dot-org, but symlinks
# have been replaced by copies of the real files, because docker doesn't follow
# symlinks outside its root build context.
- op: add
path: /build/hooks
value:
before:
- command: ["k8s/mimic/bin/update-cdo-no-symlinks.sh"]
# Artifact 0 (code-dot-org)
- op: add
path: /build/artifacts/0/context
value: k8s/mimic/cdo-no-symlinks
- op: replace
path: /build/artifacts/0/image
value: mimic
# Artifact 1 (code-dot-org-core)
- op: add
path: /build/artifacts/1/context
value: k8s/mimic/cdo-no-symlinks
- op: replace
path: /build/artifacts/1/image
value: mimic-core
# Artifact 2 (code-dot-org-pegasus)
- op: add
path: /build/artifacts/2/context
value: k8s/mimic/cdo-no-symlinks
- op: replace
path: /build/artifacts/2/image
value: mimic-pegasus
# Artifact 3 (code-dot-org-static)
- op: add
path: /build/artifacts/3/context
value: k8s/mimic/cdo-no-symlinks
- op: replace
path: /build/artifacts/3/image
value: mimic-static
# Artifact 4 (code-dot-org-db-seed)
- op: add
path: /build/artifacts/4/context
value: k8s/mimic/cdo-no-symlinks
- op: replace
path: /build/artifacts/4/image
value: mimic-db-seed
# Update required images in artifact 0
- op: replace
path: /build/artifacts/0/requires/0/image
value: mimic-core
- op: replace
path: /build/artifacts/0/requires/1/image
value: mimic-db-seed
- op: replace
path: /build/artifacts/0/requires/2/image
value: mimic-pegasus
- op: replace
path: /build/artifacts/0/requires/3/image
value: mimic-static
# Update the docker image passed to helm
- op: replace
path: /deploy/helm/releases/0/setValueTemplates/image
value: "{{.IMAGE_FULLY_QUALIFIED_mimic}}"
portForward:
- resourceType: Service
resourceName: cdo-dashboard
port: http
localPort: 13000
- resourceType: Service
resourceName: cdo-dashboard
port: http-hmr
localPort: 19000
- resourceType: Service
resourceName: cdo-mysql
port: mysql
localPort: 13306
- resourceType: Service
resourceName: cdo-redis
port: redis
localPort: 16379
- resourceType: Service
resourceName: cdo-minio
port: api
localPort: 29000
- resourceType: Service
resourceName: cdo-minio
port: console
localPort: 29001