Skip to content

Commit 05c4242

Browse files
committed
refactor k8s resources to use kustomize.
1 parent be66019 commit 05c4242

19 files changed

+182
-98
lines changed

docker/deployment/Makefile

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,11 @@ init-secrets:
4444
create-new-deployment-mail:
4545
kubectl create deployment mail --image=juanluisbaptiste/postfix:1.0.0 --dry-run=client -o yaml > mail-deployment-new.yaml
4646

47-
deploy-staging: deploy-db deploy-mail-staging deploy-app-staging deploy-lfmerge-staging deploy-next-proxy-staging deploy-next-app-staging
48-
deploy-mail-staging:
49-
sed -e s/{{SERVER_HOSTNAME}}/staging.languageforge.org/ mail-deployment.yaml | kubectl apply -f -
50-
deploy-app-staging:
51-
sed -e s/{{WEBSITE}}/staging.languageforge.org/ app-deployment.yaml \
52-
| sed -e s/{{VERSION}}/$(VERSION_APP)/ | kubectl apply -f -
53-
deploy-lfmerge-staging:
54-
sed -e s/{{VERSION_LFMERGE}}/$(VERSION_LFMERGE)/ lfmerge-deployment.yaml | kubectl apply -f -
55-
deploy-next-proxy-staging:
56-
sed -e s/{{WEBSITE}}/staging.languageforge.org/ next-proxy-deployment.yaml \
57-
| sed -e s/{{VERSION}}/$(VERSION_PROXY)/ | kubectl apply -f -
58-
deploy-next-app-staging:
59-
sed -e s/{{VERSION}}/$(VERSION_NEXT_APP)/ next-app-deployment.yaml | kubectl apply -f -
60-
deploy-prod: deploy-db deploy-mail-prod deploy-app-prod deploy-lfmerge-prod deploy-next-proxy-prod deploy-next-app-prod
61-
deploy-mail-prod:
62-
sed -e s/{{SERVER_HOSTNAME}}/languageforge.org/ mail-deployment.yaml | kubectl apply -f -
63-
deploy-app-prod:
64-
sed -e s/{{WEBSITE}}/languageforge.org/ app-deployment.yaml \
65-
| sed -e s/{{VERSION}}/$(VERSION_APP)/ | kubectl apply -f -
66-
deploy-lfmerge-prod:
67-
sed -e s/{{VERSION_LFMERGE}}/$(VERSION_LFMERGE)/ lfmerge-deployment.yaml | kubectl apply -f -
68-
deploy-next-proxy-prod:
69-
sed -e s/{{WEBSITE}}/languageforge.org/ next-proxy-deployment.yaml \
70-
| sed -e s/{{VERSION}}/$(VERSION_PROXY)/ | kubectl apply -f -
71-
deploy-next-app-prod:
72-
sed -e s/{{VERSION}}/$(VERSION_NEXT_APP)/ next-app-deployment.yaml | kubectl apply -f -
73-
deploy-db:
74-
kubectl apply -f db-deployment.yaml
47+
deploy-staging:
48+
kubectl --context dallas-rke apply -k staging/
49+
deploy-prod:
50+
kubectl --context aws-rke apply -k prod/
51+
7552

7653
delete: delete-app delete-lfmerge delete-mail delete-db delete-next-proxy delete-next-app
7754
delete-db: # does NOT delete the volume, i.e., the data in the database

docker/deployment/base/app-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ metadata:
44
name: app-config
55
data:
66
website: "localhost"
7-
7+
hg-domain: "hg-staging.languagforge.org"

docker/deployment/base/app-deployment.yaml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,6 @@ spec:
1818

1919
---
2020

21-
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
22-
apiVersion: v1
23-
kind: PersistentVolumeClaim
24-
metadata:
25-
name: lf-project-assets
26-
spec:
27-
accessModes:
28-
- ReadWriteMany
29-
resources:
30-
requests:
31-
storage: 10Gi
32-
storageClassName: weekly-snapshots-retain-4 # provided by LTOps
33-
34-
---
35-
36-
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
37-
apiVersion: v1
38-
kind: PersistentVolumeClaim
39-
metadata:
40-
name: lfmerge-sendreceive-data
41-
spec:
42-
accessModes:
43-
- ReadWriteMany
44-
resources:
45-
requests:
46-
storage: 50Gi
47-
storageClassName: weekly-snapshots-retain-4 # provided by LTOps
48-
49-
---
5021

5122
# https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#writing-a-deployment-spec
5223
apiVersion: apps/v1
@@ -93,7 +64,7 @@ spec:
9364
name: sendreceive-data
9465
containers:
9566
- name: app
96-
image: sillsdev/web-languageforge:{{VERSION}}
67+
image: sillsdev/web-languageforge:latest
9768
imagePullPolicy: Always
9869
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers
9970
resources:
@@ -113,7 +84,10 @@ spec:
11384
- name: ENVIRONMENT
11485
value: production
11586
- name: WEBSITE
116-
value: {{WEBSITE}}
87+
valueFrom:
88+
configMapKeyRef:
89+
name: app-config
90+
key: website
11791
- name: MAIL_HOST
11892
value: mail
11993
- name: LFMERGE_LOGGING_DEST
@@ -143,6 +117,7 @@ spec:
143117
secretKeyRef:
144118
key: LEX_BOX_HOST
145119
name: ld-api
120+
optional: true
146121
- name: FACEBOOK_CLIENT_ID
147122
valueFrom:
148123
secretKeyRef:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# template, copy into env folder and change the values, then add as a patch to the kustomization.yaml file
2+
3+
- op: replace
4+
path: /spec/rules/0/host
5+
value: localhost
6+
- op: replace
7+
path: /spec/tls/0/hosts
8+
value:
9+
- localhost

docker/deployment/base/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ resources:
66
- app-deployment.yaml
77
- db-deployment.yaml
88
- lfmerge-deployment.yaml
9+
- lfmerge-pvcs.yaml
910
- mail-deployment.yaml
1011
- next-app-deployment.yaml
1112
- next-proxy-deployment.yaml
13+
- app-config.yaml

docker/deployment/base/lfmerge-deployment.yaml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,6 @@ spec:
1818

1919
---
2020

21-
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
22-
apiVersion: v1
23-
kind: PersistentVolumeClaim
24-
metadata:
25-
name: lf-project-assets
26-
spec:
27-
accessModes:
28-
- ReadWriteMany
29-
resources:
30-
requests:
31-
storage: 10Gi
32-
storageClassName: weekly-snapshots-retain-4 # provided by LTOps
33-
34-
---
35-
36-
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
37-
apiVersion: v1
38-
kind: PersistentVolumeClaim
39-
metadata:
40-
name: lfmerge-sendreceive-data
41-
spec:
42-
accessModes:
43-
- ReadWriteMany
44-
resources:
45-
requests:
46-
storage: 50Gi
47-
storageClassName: weekly-snapshots-retain-4 # provided by LTOps
48-
49-
---
50-
5121
# https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#writing-a-deployment-spec
5222
apiVersion: apps/v1
5323
kind: Deployment
@@ -100,7 +70,7 @@ spec:
10070
name: sendreceive-data
10171
containers:
10272
- name: lfmerge
103-
image: ghcr.io/sillsdev/lfmerge:{{VERSION_LFMERGE}}
73+
image: ghcr.io/sillsdev/lfmerge:latest
10474
imagePullPolicy: Always
10575
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers
10676
resources:
@@ -133,6 +103,11 @@ spec:
133103
value: sf_
134104
- name: LFMERGE_VERBOSE_PROGRESS
135105
value: "true"
106+
- name: LFMERGE_LANGUAGE_DEPOT_HG_PUBLIC_HOSTNAME
107+
valueFrom:
108+
configMapKeyRef:
109+
name: app-config
110+
key: hg-domain
136111
- name: LANGUAGE_DEPOT_TRUST_TOKEN
137112
valueFrom:
138113
secretKeyRef:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
3+
apiVersion: v1
4+
kind: PersistentVolumeClaim
5+
metadata:
6+
name: lf-project-assets
7+
spec:
8+
accessModes:
9+
- ReadWriteMany
10+
resources:
11+
requests:
12+
storage: 10Gi
13+
storageClassName: weekly-snapshots-retain-4 # provided by LTOps
14+
15+
---
16+
17+
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
18+
apiVersion: v1
19+
kind: PersistentVolumeClaim
20+
metadata:
21+
name: lfmerge-sendreceive-data
22+
spec:
23+
accessModes:
24+
- ReadWriteMany
25+
resources:
26+
requests:
27+
storage: 50Gi
28+
storageClassName: weekly-snapshots-retain-4 # provided by LTOps

docker/deployment/base/mail-deployment.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ spec:
4141
memory: 100Mi
4242
env:
4343
- name: SERVER_HOSTNAME
44-
value: {{SERVER_HOSTNAME}}
44+
valueFrom:
45+
configMapKeyRef:
46+
name: app-config
47+
key: website
4548
- name: SMTP_SERVER
4649
valueFrom:
4750
secretKeyRef:

docker/deployment/base/next-app-deployment.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ spec:
3737
spec:
3838
containers:
3939
- name: next-app
40-
image: sillsdev/web-languageforge:{{VERSION}}
40+
# this image doesn't actually exist as for some reason tags were used for different image types instead of just version number.
41+
# this is a workaround because kustomize is designed to work with image names
42+
image: sillsdev/web-languageforge-next-app:latest
4143
imagePullPolicy: Always
4244
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers
4345
resources:

docker/deployment/base/next-proxy-deployment.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
nginx.ingress.kubernetes.io/proxy-body-size: 60M
1010
spec:
1111
rules:
12-
- host: {{WEBSITE}}
12+
- host: localhost
1313
http:
1414
paths:
1515
- path: /
@@ -21,7 +21,7 @@ spec:
2121
number: 80
2222
tls:
2323
- hosts:
24-
- {{WEBSITE}}
24+
- localhost
2525
secretName: languageforge-tls
2626

2727
---
@@ -64,7 +64,9 @@ spec:
6464
spec:
6565
containers:
6666
- name: next-proxy
67-
image: sillsdev/web-languageforge:{{VERSION}}
67+
# this image doesn't actually exist as for some reason tags were used for different image types instead of just version number.
68+
# this is a workaround because kustomize is designed to work with image names
69+
image: sillsdev/web-languageforge-next-proxy:latest
6870
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers
6971
imagePullPolicy: Always
7072
resources:

0 commit comments

Comments
 (0)