Skip to content

Commit 2960219

Browse files
committed
feat(#782): added support for multiple sakura instances
Now it is possible to deploy multiple sakura instances within the kubernetes. Signed-off-by: Tobias Anker <tobias.anker@kitsunemimi.moe>
1 parent 6fcfe8e commit 2960219

10 files changed

Lines changed: 61 additions & 105 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@
66

77
- Vagrantfile with ansible playbook to deploy multiple virtual machines with a kubernestes with fully deployed ainari-setup and sdk-api-test
88
- image pull-policy can now be changed by the helm-values
9+
- support other namespaces thand "default"
10+
- support for multiple sakura instances
911

1012
### Changed
1113

1214
- changed the image-build process for the new vagrant-test-setup
15+
- sakura and onsen are now statefulsets within the kubernetes setup
16+
17+
### Fixed
18+
19+
- fixed broken version-output of the pre-build docker images
20+
1321

1422
## v0.10.0
1523

deploy/k8s/ainari/templates/sakura/sakura-config.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
{{- $root := . }}
16+
{{- $replicas := int .Values.sakura.replica_count }}
17+
{{- range $i := until $replicas }}
1518
apiVersion: v1
19+
kind: ConfigMap
1620
metadata:
17-
name: sakura-config
21+
name: sakura-config-{{ $i }}
1822
data:
1923
sakura.toml: |+
2024
debug = true
2125
log_path = ""
2226
skip_tls_verification = true
23-
address = "https://sakura-tls-service.{{ .Release.Namespace }}.svc.cluster.local:8443"
27+
address = "https://sakura-{{ $i }}.sakura-tls-service.{{ $root.Release.Namespace }}.svc.cluster.local:8443"
2428
2529
[processing]
26-
max_number_of_threads = {{ .Values.sakura.processing.max_number_of_threads }}
30+
max_number_of_threads = {{ $root.Values.sakura.processing.max_number_of_threads }}
2731
2832
[storage]
2933
tempfile_location = "/tmp/sakura"
@@ -38,6 +42,6 @@ data:
3842
file_path = "/etc/ainari/sakura/sakura_db"
3943
4044
[miko]
41-
address = "https://miko-tls-service.{{ .Release.Namespace }}.svc.cluster.local:8443"
42-
43-
kind: ConfigMap
45+
address = "https://miko-tls-service.{{ $root.Release.Namespace }}.svc.cluster.local:8443"
46+
--- {{/* This separator is mandatory inside the loop. otherwise only one instance is created */}}
47+
{{- end }}

deploy/k8s/ainari/templates/sakura/sakura-ingress.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

deploy/k8s/ainari/templates/sakura/sakura-pv.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

deploy/k8s/ainari/templates/sakura/sakura-pvc.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

deploy/k8s/ainari/templates/sakura/sakura-statefulset.yaml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ metadata:
1919
labels:
2020
app: sakura
2121
spec:
22+
serviceName: sakura-tls-service
2223
replicas: {{ .Values.sakura.replica_count }}
2324
selector:
2425
matchLabels:
@@ -46,6 +47,24 @@ spec:
4647
values:
4748
- sakura
4849
topologyKey: kubernetes.io/hostname
50+
51+
initContainers:
52+
- name: copy-config
53+
image: busybox
54+
command:
55+
- sh
56+
- -c
57+
- |
58+
ORDINAL=${HOSTNAME##*-}
59+
mkdir -p /etc/ainari
60+
ls /configs
61+
cp /configs/sakura-config-${ORDINAL}/sakura.toml /etc/ainari/sakura.toml
62+
volumeMounts:
63+
- name: sakura-configs
64+
mountPath: /configs
65+
- name: sakura-config
66+
mountPath: /etc/ainari
67+
4968
containers:
5069
- name: sakura
5170
image: {{ .Values.sakura.docker.repository }}:{{ .Values.sakura.docker.tag }}
@@ -63,13 +82,12 @@ spec:
6382
secretKeyRef:
6483
name: sakura-registration-key
6584
key: sakura_retistration_key
85+
6686
volumeMounts:
6787
- name: data-volume
6888
mountPath: /etc/ainari/sakura/
6989
- name: sakura-config
70-
mountPath: /etc/ainari/sakura.toml
71-
subPath: sakura.toml
72-
readOnly: true
90+
mountPath: /etc/ainari
7391
- name: wg-secret
7492
mountPath: /etc/wireguard
7593
readOnly: true
@@ -81,6 +99,8 @@ spec:
8199

82100
- name: tls-termination
83101
image: nginx:latest
102+
ports:
103+
- containerPort: 8443
84104
volumeMounts:
85105
- name: tls-certs
86106
mountPath: /etc/nginx/certs
@@ -93,9 +113,18 @@ spec:
93113
cpu: "500m"
94114

95115
volumes:
116+
- name: sakura-configs
117+
projected:
118+
sources:
119+
{{- range $i := until (.Values.sakura.replica_count | int) }}
120+
- configMap:
121+
name: sakura-config-{{ $i }}
122+
items:
123+
- key: sakura.toml
124+
path: sakura-config-{{ $i }}/sakura.toml
125+
{{- end }}
96126
- name: sakura-config
97-
configMap:
98-
name: sakura-config
127+
emptyDir: {}
99128
- name: tls-certs
100129
secret:
101130
secretName: sakura-selfsigned-secret

deploy/k8s/ainari/templates/sakura/sakura-tls-service.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ kind: Service
1717
metadata:
1818
name: sakura-tls-service
1919
labels:
20-
run: sakura
20+
app: sakura
2121
spec:
22+
clusterIP: None
2223
selector:
2324
app: sakura
2425
ports:
2526
- name: input
2627
protocol: TCP
2728
port: 8443
2829
targetPort: 8443
29-
type: ClusterIP

deploy/k8s/test_values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ miko:
99
token:
1010
data: "this-is-a-test"
1111

12+
13+
# sakura:
14+
# replica_count: 3
15+

testing/vagrant/playbook.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202

203203
- name: Create ainari namespace
204204
ansible.builtin.shell: |
205-
kubectl create namespace ainari || yes
205+
kubectl create namespace ainari || true
206206
207207
- name: Ensure cert-manager namespace exists
208208
ansible.builtin.shell: |
@@ -264,7 +264,7 @@
264264

265265
- name: Check if Helm release of ainari exists
266266
ansible.builtin.command:
267-
cmd: helm status ainari
267+
cmd: helm status -n ainari ainari
268268
register: helm_status
269269
failed_when: false
270270
changed_when: false

testing/vagrant/test_values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ hanami:
2727

2828

2929
sakura:
30-
replica_count: 1
30+
replica_count: 2
3131
docker:
3232
tag: "local_test"
3333
repository: "kitsudaiki/sakura"

0 commit comments

Comments
 (0)