-
Notifications
You must be signed in to change notification settings - Fork 6
/
devspace.yaml
160 lines (152 loc) · 5.52 KB
/
devspace.yaml
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
version: v2beta1
name: dadjokes
vars:
OPENAI_API_KEY:
source: env
TAG: $(git describe --always)
NAMESPACE: ${DEVSPACE_NAMESPACE}
JOKE_SERVER: vfiftyfive/joke-server:${TAG}
JOKE_WORKER: vfiftyfive/joke-worker:${TAG}
# This is a list of `pipelines` that DevSpace can execute (you can define your own)
pipelines:
# This is the pipeline for the main command: `devspace dev` (or `devspace run-pipeline dev`)
dev:
run: |-
run_dependencies --all
ensure_pull_secrets --all
create_deployments redis-operator
create_deployments nats joke-server joke-worker custom-resources
start_dev --all
# You can run this pipeline via `devspace deploy` (or `devspace run-pipeline deploy`)
deploy:
run: |-
run_dependencies --all # 1. Deploy any projects this project needs (see "dependencies")
ensure_pull_secrets --all # 2. Ensure pull secrets
create_deployments redis-operator
create_deployments nats joke-server joke-worker custom-resources
build: |-
run_dependencies --all
build_images --all -t $(git describe --always)
# This is a list of `images` that DevSpace can build for this project
# We recommend to skip image building during development (devspace dev) as much as possible
images:
joke-server:
image: ${JOKE_SERVER}
buildKit:
args: ["--platform=linux/amd64,linux/arm64"]
dockerfile: ../../cmd/joke-server/Dockerfile
context: ../..
joke-worker:
image: ${JOKE_WORKER}build
buildKit:
args: ["--platform=linux/amd64,linux/arm64"]
dockerfile: ../../cmd/joke-worker/Dockerfile
context: ../..
# This is a list of `deployments` that DevSpace can create for this project
deployments:
redis-operator:
helm:
chart:
name: redis-operator
repo: https://ot-container-kit.github.io/helm-charts/
nats:
helm:
chart:
name: nats
repo: https://nats-io.github.io/k8s/helm/charts/
joke-server:
# This deployment uses `helm` but you can also define `kubectl` deployments or kustomizations
helm:
# We are deploying this project with the Helm chart you provided
chart:
name: component-chart
repo: https://charts.devspace.sh
# Under `values` we can define the values for this Helm chart used during `helm install/upgrade`
# You may also use `valuesFiles` to load values from files, e.g. valuesFiles: ["values.yaml"]
values:
containers:
- image: ${JOKE_SERVER}
env:
- name: NATS_URL
value: nats://nats-headless:4222
service:
ports:
- port: 8080
joke-worker:
# This deployment uses `helm` but you can also define `kubectl` deployments or kustomizations
helm:
# We are deploying this project with the Helm chart you provided
chart:
name: component-chart
repo: https://charts.devspace.sh
# Under `values` we can define the values for this Helm chart used during `helm install/upgrade`
# You may also use `valuesFiles` to load values from files, e.g. valuesFiles: ["values.yaml"]
values:
containers:
- image: ${JOKE_WORKER}
env:
- name: NATS_URL
value: nats://nats-headless:4222
- name: REDIS_URL
value: redis-headless:6379
- name: OPENAI_API_KEY
valueFrom:
secretKeyRef:
name: openai-api-key
key: OPENAI_API_KEY
custom-resources:
kubectl:
manifests:
- custom-resources/
# This is a list of `dev` containers that are based on the containers created by your deployments
dev:
joke-server:
imageSelector: ${JOKE_SERVER}
ports:
- port: "8080"
joke-worker:
imageSelector: ${JOKE_WORKER}
command: ["./joke-worker"]
restartHelper:
inject: true
sync:
- path: ../../cmd/joke-worker:/app/cmd/joke-worker
onUpload:
restartContainer: true
exec:
- command: |-
go build -o joke-worker ./cmd/joke-worker/main.go
- path: ../../go.mod:/app/go.mod
- path: ../../go.sum:/app/go.sum
- path: ../../internal:/app/internal
onUpload:
restartContainer: true
exec:
- command: |-
go build -o joke-worker ./cmd/joke-worker/main.go
hooks:
- name: "Decrypt OPENAI_API_KEY"
command: "sops -d openai-api-key.enc.yaml | sed '/data: |/d' | kubectl apply -n ${NAMESPACE} -f -"
events: ["before:deploy"]
- name: "Patch joke-worker"
command: "kubectl patch deployment -n ${NAMESPACE} joke-worker -p '{\"spec\": {\"template\":{\"metadata\":{\"labels\":{\"credentials-operator.otterize.com/create-aws-role\":\"true\"}}}} }'"
events: ["after:deploy:joke-worker"]
- name: "Delete dynamodb"
command: "kubectl delete -n ${NAMESPACE} table jokestable"
events: ["before: purge"]
- name: "Delete redis resources"
command: "kubectl delete -n ${NAMESPACE} redis --all"
events: ["before:purge"]
- name: "Delete PVCs"
command: "kubectl delete -n ${NAMESPACE} pvc --all"
events: ["after:purge"]
- name: "Delete namespace"
command: "kubectl delete namespace ${NAMESPACE}"
events: ["after:purge"]
commands:
encrypt-openai-secret: |-
kubectl create secret generic openai-api-key \
--from-literal=OPENAI_API_KEY=${OPENAI_API_KEY} \
--dry-run=client -o yaml > openai-secret.yaml && \
sops -e openai-secret.yaml > openai-api-key.enc.yaml && \
rm openai-secret.yaml