From 37a90240eed76772e4ed2d438cd0d66a5c693970 Mon Sep 17 00:00:00 2001 From: iandyh Date: Tue, 18 Apr 2023 04:00:02 +0900 Subject: [PATCH 01/47] prepare the controller for the split --- shibuya/api/main.go | 4 +++- shibuya/controller/garbage.go | 6 +++--- shibuya/controller/main.go | 21 ++++++++++----------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/shibuya/api/main.go b/shibuya/api/main.go index df4d7730..45ed9665 100644 --- a/shibuya/api/main.go +++ b/shibuya/api/main.go @@ -27,9 +27,11 @@ type ShibuyaAPI struct { } func NewAPIServer() *ShibuyaAPI { - return &ShibuyaAPI{ + c := &ShibuyaAPI{ ctr: controller.NewController(), } + c.ctr.StartRunning() + return c } type JSONMessage struct { diff --git a/shibuya/controller/garbage.go b/shibuya/controller/garbage.go index ad37b23c..eea81931 100644 --- a/shibuya/controller/garbage.go +++ b/shibuya/controller/garbage.go @@ -10,7 +10,7 @@ import ( log "github.com/sirupsen/logrus" ) -func (c *Controller) checkRunningThenTerminate() { +func (c *Controller) CheckRunningThenTerminate() { jobs := make(chan *RunningPlan) for w := 1; w <= 3; w++ { go func(jobs <-chan *RunningPlan) { @@ -107,7 +107,7 @@ func isCollectionStale(rh *model.RunHistory, launchTime time.Time) (bool, error) return true, nil } -func (c *Controller) autoPurgeDeployments() { +func (c *Controller) AutoPurgeDeployments() { for { deployedCollections, err := c.Scheduler.GetDeployedCollections() if err != nil { @@ -151,7 +151,7 @@ func (c *Controller) autoPurgeDeployments() { // Last time used is defined as: // 1. If none of the collections has a run, it will be the last launch time of the engines of a collection // 2. If any of the collection has a run, it will be the end time of that run -func (c *Controller) autoPurgeProjectIngressController() { +func (c *Controller) AutoPurgeProjectIngressController() { projectLastUsedTime := make(map[int64]time.Time) ingressLifespan, err := time.ParseDuration(config.SC.IngressConfig.Lifespan) if err != nil { diff --git a/shibuya/controller/main.go b/shibuya/controller/main.go index 015bbb66..4d68d496 100644 --- a/shibuya/controller/main.go +++ b/shibuya/controller/main.go @@ -44,17 +44,6 @@ func NewController() *Controller { } c.schedulerKind = config.SC.ExecutorConfig.Cluster.Kind c.Scheduler = scheduler.NewEngineScheduler(config.SC.ExecutorConfig.Cluster) - - // First we do is to resume the running plans - // This method should not be moved as later goroutines rely on it. - c.resumeRunningPlans() - go c.streamToApi() - go c.readConnectedEngines() - go c.checkRunningThenTerminate() - go c.fetchEngineMetrics() - go c.cleanLocalStore() - go c.autoPurgeDeployments() - go c.autoPurgeProjectIngressController() return c } @@ -70,6 +59,16 @@ type ApiMetricStreamEvent struct { PlanID string `json:"plan_id"` } +func (c *Controller) StartRunning() { + // First we do is to resume the running plans + // This method should not be moved as later goroutines rely on it. + c.resumeRunningPlans() + go c.streamToApi() + go c.readConnectedEngines() + go c.fetchEngineMetrics() + go c.cleanLocalStore() +} + func (c *Controller) streamToApi() { for { select { From 4e722c4d06e3f518259e021a7cfc5b610622dce3 Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 7 Jul 2023 16:59:29 +0900 Subject: [PATCH 02/47] controller into cmd --- shibuya/controller/cmd/Dockerfile | 21 ++++++++++ shibuya/controller/cmd/Makefile | 11 +++++ shibuya/controller/cmd/config_tmp.json | 56 ++++++++++++++++++++++++++ shibuya/controller/cmd/deployment.yaml | 19 +++++++++ shibuya/controller/cmd/main.go | 13 ++++++ 5 files changed, 120 insertions(+) create mode 100644 shibuya/controller/cmd/Dockerfile create mode 100644 shibuya/controller/cmd/Makefile create mode 100644 shibuya/controller/cmd/config_tmp.json create mode 100644 shibuya/controller/cmd/deployment.yaml create mode 100644 shibuya/controller/cmd/main.go diff --git a/shibuya/controller/cmd/Dockerfile b/shibuya/controller/cmd/Dockerfile new file mode 100644 index 00000000..3072e5a9 --- /dev/null +++ b/shibuya/controller/cmd/Dockerfile @@ -0,0 +1,21 @@ +FROM gcr.io/shibuya-214807/golang:1.20.2-buster AS builder + +WORKDIR /go/src/shibuya-controller + +ENV GO111MODULE on +ADD go.mod . +ADD go.sum . +RUN go mod download + +COPY . /go/src/shibuya-controller + + + +RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/sc + +FROM gcr.io/shibuya-214807/ubuntu:18.04 + +COPY --from=builder /go/bin/sc /usr/local/bin/sc +COPY config_tmp.json /config.json + +CMD ["sc"] diff --git a/shibuya/controller/cmd/Makefile b/shibuya/controller/cmd/Makefile new file mode 100644 index 00000000..5b1af17a --- /dev/null +++ b/shibuya/controller/cmd/Makefile @@ -0,0 +1,11 @@ +build: + mkdir -p bin + go build -o bin/ingress-controller + +docker: + docker build -t ${IMG} . + docker push ${IMG} + +docker-local: + docker build -t ${IMG} . + kind load docker-image ${IMG} --name shibuya \ No newline at end of file diff --git a/shibuya/controller/cmd/config_tmp.json b/shibuya/controller/cmd/config_tmp.json new file mode 100644 index 00000000..fe5ed4b0 --- /dev/null +++ b/shibuya/controller/cmd/config_tmp.json @@ -0,0 +1,56 @@ +{ + "bg_color": "#fff", + "project_home": "", + "upload_file_help": "", + "auth_config": { + "admin_users": [], + "ldap_server": "", + "ldap_port": "", + "system_user": "", + "system_password": "", + "base_dn": "", + "no_auth": true + }, + "http_config": { + "proxy": "" + }, + "db": { + "host": "db", + "user": "root", + "password": "root", + "database": "shibuya" + }, + "executors": { + "cluster": { + "on_demand": false + }, + "in_cluster": true, + "namespace": "shibuya-executors", + "jmeter": { + "image": "shibuya:jmeter", + "cpu": "0.1", + "mem": "512Mi" + }, + "pull_secret": "", + "pull_policy": "IfNotPresent", + "max_engines_in_collection": 10 + }, + "ingress": { + "image": "shibuya:ingress-controller", + "cpu": "0.1" + }, + "dashboard": { + "url": "http://localhost:3000", + "run_dashboard": "/d/RXY8nM1mk2/shibuya", + "engine_dashboard": "/d/9EH6xqTZz/shibuya-engine-health" + }, + "object_storage": { + "provider": "local", + "url": "http://storage:8080", + "user": "", + "password": "" + }, + "log_format": { + "json": false + } +} \ No newline at end of file diff --git a/shibuya/controller/cmd/deployment.yaml b/shibuya/controller/cmd/deployment.yaml new file mode 100644 index 00000000..7c792e0e --- /dev/null +++ b/shibuya/controller/cmd/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: shibuya-controller + labels: + app: shibuya-controller +spec: + replicas: 1 + selector: + matchLabels: + app: shibuya-controller + template: + metadata: + labels: + app: shibuya-controller + spec: + containers: + - name: shibuya-controller + image: sc:v0.1 diff --git a/shibuya/controller/cmd/main.go b/shibuya/controller/cmd/main.go new file mode 100644 index 00000000..55cf8e8d --- /dev/null +++ b/shibuya/controller/cmd/main.go @@ -0,0 +1,13 @@ +package main + +import "github.com/rakutentech/shibuya/shibuya/controller" + +// This func keep tracks of all the running engines. They should just rely on the data in the db +// and make necessary queries to the scheduler. +func main() { + controller := controller.NewController() + + controller.CheckRunningThenTerminate() + go controller.AutoPurgeDeployments() + go controller.AutoPurgeProjectIngressController() +} From 46442b3714bc2dcd0f21117403fefe5a0a99b46c Mon Sep 17 00:00:00 2001 From: iandyh Date: Mon, 24 Jul 2023 22:31:00 +0900 Subject: [PATCH 03/47] better build --- shibuya/build.sh | 2 + shibuya/controller/cmd/Dockerfile | 21 ---------- shibuya/controller/cmd/Makefile | 11 ----- shibuya/controller/cmd/config_tmp.json | 56 -------------------------- 4 files changed, 2 insertions(+), 88 deletions(-) delete mode 100644 shibuya/controller/cmd/Dockerfile delete mode 100644 shibuya/controller/cmd/Makefile delete mode 100644 shibuya/controller/cmd/config_tmp.json diff --git a/shibuya/build.sh b/shibuya/build.sh index 9b2f9418..5ca94e5f 100644 --- a/shibuya/build.sh +++ b/shibuya/build.sh @@ -8,6 +8,8 @@ go mod download case "$target" in "jmeter") GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o build/shibuya-agent $(pwd)/engines/jmeter ;; + "controller") GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o build/shibuya-controller $(pwd)/controller/cmd + ;; *) GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o build/shibuya esac \ No newline at end of file diff --git a/shibuya/controller/cmd/Dockerfile b/shibuya/controller/cmd/Dockerfile deleted file mode 100644 index 3072e5a9..00000000 --- a/shibuya/controller/cmd/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM gcr.io/shibuya-214807/golang:1.20.2-buster AS builder - -WORKDIR /go/src/shibuya-controller - -ENV GO111MODULE on -ADD go.mod . -ADD go.sum . -RUN go mod download - -COPY . /go/src/shibuya-controller - - - -RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/sc - -FROM gcr.io/shibuya-214807/ubuntu:18.04 - -COPY --from=builder /go/bin/sc /usr/local/bin/sc -COPY config_tmp.json /config.json - -CMD ["sc"] diff --git a/shibuya/controller/cmd/Makefile b/shibuya/controller/cmd/Makefile deleted file mode 100644 index 5b1af17a..00000000 --- a/shibuya/controller/cmd/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -build: - mkdir -p bin - go build -o bin/ingress-controller - -docker: - docker build -t ${IMG} . - docker push ${IMG} - -docker-local: - docker build -t ${IMG} . - kind load docker-image ${IMG} --name shibuya \ No newline at end of file diff --git a/shibuya/controller/cmd/config_tmp.json b/shibuya/controller/cmd/config_tmp.json deleted file mode 100644 index fe5ed4b0..00000000 --- a/shibuya/controller/cmd/config_tmp.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "bg_color": "#fff", - "project_home": "", - "upload_file_help": "", - "auth_config": { - "admin_users": [], - "ldap_server": "", - "ldap_port": "", - "system_user": "", - "system_password": "", - "base_dn": "", - "no_auth": true - }, - "http_config": { - "proxy": "" - }, - "db": { - "host": "db", - "user": "root", - "password": "root", - "database": "shibuya" - }, - "executors": { - "cluster": { - "on_demand": false - }, - "in_cluster": true, - "namespace": "shibuya-executors", - "jmeter": { - "image": "shibuya:jmeter", - "cpu": "0.1", - "mem": "512Mi" - }, - "pull_secret": "", - "pull_policy": "IfNotPresent", - "max_engines_in_collection": 10 - }, - "ingress": { - "image": "shibuya:ingress-controller", - "cpu": "0.1" - }, - "dashboard": { - "url": "http://localhost:3000", - "run_dashboard": "/d/RXY8nM1mk2/shibuya", - "engine_dashboard": "/d/9EH6xqTZz/shibuya-engine-health" - }, - "object_storage": { - "provider": "local", - "url": "http://storage:8080", - "user": "", - "password": "" - }, - "log_format": { - "json": false - } -} \ No newline at end of file From 8c54c373d63431d92b34aad29e84735aa7dd630d Mon Sep 17 00:00:00 2001 From: iandyh Date: Mon, 24 Jul 2023 22:31:26 +0900 Subject: [PATCH 04/47] provide an entrypoint for building the controller --- makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 308f24c9..bd1a20c1 100644 --- a/makefile +++ b/makefile @@ -84,4 +84,9 @@ ingress-controller: # if you need to debug the controller, please use the makefile in the ingress controller folder # And update the image in the config.json docker build -t shibuya:ingress-controller -f ingress-controller/Dockerfile ingress-controller - kind load docker-image shibuya:ingress-controller --name shibuya \ No newline at end of file + kind load docker-image shibuya:ingress-controller --name shibuya + +.PHONY: controller +controller: + cp shibuya/config_tmpl.json shibuya/config.json + cd shibuya && sh build.sh controller \ No newline at end of file From 1ac484a84c61d242773ce24ea15f885fdf8ad2c2 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 27 Jul 2023 04:49:59 +0900 Subject: [PATCH 05/47] support build the controller locally --- makefile | 4 +++- shibuya/docker-local/Dockerfile | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index bd1a20c1..762b1780 100644 --- a/makefile +++ b/makefile @@ -89,4 +89,6 @@ ingress-controller: .PHONY: controller controller: cp shibuya/config_tmpl.json shibuya/config.json - cd shibuya && sh build.sh controller \ No newline at end of file + cd shibuya && sh build.sh controller + docker build -f shibuya/docker-local/Dockerfile --build-arg env=local --build-arg="binary_name=shibuya-controller" -t controller:local shibuya + kind load docker-image controller:local --name shibuya diff --git a/shibuya/docker-local/Dockerfile b/shibuya/docker-local/Dockerfile index 0a3d6491..55b9c6bd 100644 --- a/shibuya/docker-local/Dockerfile +++ b/shibuya/docker-local/Dockerfile @@ -7,10 +7,12 @@ RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s # Use only binaries from above image for running the app FROM gcr.io/shibuya-214807/ubuntu:18.04 + COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -ADD ./build/shibuya /usr/local/bin/shibuya +ARG binary_name=shibuya +ADD ./build/${binary_name} /usr/local/bin/${binary_name} RUN mkdir /auth ADD ./shibuya-gcp.json /auth/shibuya-gcp.json @@ -27,4 +29,5 @@ ENV https_proxy ${proxy} COPY config/kube_configs /root/.kube COPY config.json /config.json COPY ./ui/ / -CMD ["shibuya"] \ No newline at end of file +ENV binary=${binary_name} +CMD ${binary} From 4dd10ea1583eaa754d74c23669425734101113bc Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 10 Aug 2023 11:04:50 +0900 Subject: [PATCH 06/47] use simplified Dockerfile --- kubernetes/shibuya.yaml | 36 --------------------------------- makefile | 11 +++++----- shibuya/Dockerfile | 35 ++++++-------------------------- shibuya/docker-local/Dockerfile | 33 ------------------------------ 4 files changed, 12 insertions(+), 103 deletions(-) delete mode 100644 kubernetes/shibuya.yaml delete mode 100644 shibuya/docker-local/Dockerfile diff --git a/kubernetes/shibuya.yaml b/kubernetes/shibuya.yaml deleted file mode 100644 index 1f2eb8f4..00000000 --- a/kubernetes/shibuya.yaml +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: shibuya - name: shibuya -spec: - replicas: 1 - selector: - matchLabels: - app: shibuya - template: - metadata: - labels: - app: shibuya - spec: - serviceAccount: shibuya - containers: - - image: shibuya:local - name: shibuya - ports: - - containerPort: 8080 ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app: shibuya - name: shibuya -spec: - ports: - - port: 8080 - protocol: TCP - targetPort: 8080 - selector: - app: shibuya \ No newline at end of file diff --git a/makefile b/makefile index 762b1780..7f7178e4 100644 --- a/makefile +++ b/makefile @@ -35,11 +35,11 @@ grafana: grafana/ .PHONY: shibuya shibuya: shibuya/ kubernetes/ - cp shibuya/config_tmpl.json shibuya/config.json cd shibuya && sh build.sh - docker build -f shibuya/docker-local/Dockerfile --build-arg env=local -t shibuya:local shibuya + docker build -f shibuya/Dockerfile --build-arg env=local -t shibuya:local shibuya kind load docker-image shibuya:local --name shibuya - kubectl -n $(shibuya-controller-ns) replace -f kubernetes/shibuya.yaml --force + helm uninstall shibuya || true + helm upgrade --install shibuya install/shibuya .PHONY: jmeter jmeter: shibuya/engines/jmeter @@ -88,7 +88,8 @@ ingress-controller: .PHONY: controller controller: - cp shibuya/config_tmpl.json shibuya/config.json cd shibuya && sh build.sh controller - docker build -f shibuya/docker-local/Dockerfile --build-arg env=local --build-arg="binary_name=shibuya-controller" -t controller:local shibuya + docker build -f shibuya/Dockerfile --build-arg env=local --build-arg="binary_name=shibuya-controller" -t controller:local shibuya kind load docker-image controller:local --name shibuya + helm uninstall shibuya || true + helm upgrade --install shibuya install/shibuya diff --git a/shibuya/Dockerfile b/shibuya/Dockerfile index bb960443..bccb7a5e 100644 --- a/shibuya/Dockerfile +++ b/shibuya/Dockerfile @@ -1,41 +1,18 @@ -FROM gcr.io/shibuya-214807/golang:1.17-stretch AS builder +FROM gcr.io/shibuya-214807/ubuntu:18.04 +RUN apt-get update && apt-get install -y curl RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ && chmod +x ./kubectl \ && mv ./kubectl /usr/local/bin/kubectl -WORKDIR /go/src/shibuya - -ENV GO111MODULE on -ADD go.mod . -ADD go.sum . -RUN go mod download - -COPY . /go/src/shibuya - -RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/shibuya - -# Use only binaries from above image for running the app -FROM gcr.io/shibuya-214807/ubuntu:18.04 - -COPY --from=builder /go/bin/shibuya /usr/local/bin/shibuya -COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - -RUN mkdir /auth -ADD ./shibuya-gcp.json /auth/shibuya-gcp.json +ARG binary_name=shibuya +ADD ./build/${binary_name} /usr/local/bin/${binary_name} ENV GOOGLE_APPLICATION_CREDENTIALS /auth/shibuya-gcp.json ARG env=local ENV env ${env} -ARG lab_image="" -ENV lab_image ${lab_image} -ARG proxy="" -ENV http_proxy ${proxy} -ENV https_proxy ${proxy} -COPY config/kube_configs /root/.kube -COPY config.json /config.json COPY ./ui/ / -CMD ["shibuya"] \ No newline at end of file +ENV binary=${binary_name} +CMD ${binary} diff --git a/shibuya/docker-local/Dockerfile b/shibuya/docker-local/Dockerfile deleted file mode 100644 index 55b9c6bd..00000000 --- a/shibuya/docker-local/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM gcr.io/shibuya-214807/golang:1.13.6-stretch AS builder - -RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ - && chmod +x ./kubectl \ - && mv ./kubectl /usr/local/bin/kubectl - -# Use only binaries from above image for running the app -FROM gcr.io/shibuya-214807/ubuntu:18.04 - - -COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - -ARG binary_name=shibuya -ADD ./build/${binary_name} /usr/local/bin/${binary_name} - -RUN mkdir /auth -ADD ./shibuya-gcp.json /auth/shibuya-gcp.json -ENV GOOGLE_APPLICATION_CREDENTIALS /auth/shibuya-gcp.json - -ARG env=local -ENV env ${env} -ARG lab_image="" -ENV lab_image ${lab_image} -ARG proxy="" -ENV http_proxy ${proxy} -ENV https_proxy ${proxy} - -COPY config/kube_configs /root/.kube -COPY config.json /config.json -COPY ./ui/ / -ENV binary=${binary_name} -CMD ${binary} From 007124b051e6a569a59880f5433aae166d599258 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 10 Aug 2023 11:06:30 +0900 Subject: [PATCH 07/47] install shibuya runtime with helm --- install/shibuya/.helmignore | 23 +++++++ install/shibuya/Chart.yaml | 24 +++++++ install/shibuya/templates/api.deploy.yaml | 30 +++++++++ install/shibuya/templates/api.service.yaml | 13 ++++ install/shibuya/templates/configmap.yaml | 63 +++++++++++++++++++ install/shibuya/templates/controller.job.yaml | 29 +++++++++ install/shibuya/values.yaml | 62 ++++++++++++++++++ 7 files changed, 244 insertions(+) create mode 100644 install/shibuya/.helmignore create mode 100644 install/shibuya/Chart.yaml create mode 100644 install/shibuya/templates/api.deploy.yaml create mode 100644 install/shibuya/templates/api.service.yaml create mode 100644 install/shibuya/templates/configmap.yaml create mode 100644 install/shibuya/templates/controller.job.yaml create mode 100644 install/shibuya/values.yaml diff --git a/install/shibuya/.helmignore b/install/shibuya/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/install/shibuya/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/install/shibuya/Chart.yaml b/install/shibuya/Chart.yaml new file mode 100644 index 00000000..86aba700 --- /dev/null +++ b/install/shibuya/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: shibuya +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml new file mode 100644 index 00000000..1ad3955f --- /dev/null +++ b/install/shibuya/templates/api.deploy.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: shibuya + name: shibuya +spec: + replicas: 1 + selector: + matchLabels: + app: shibuya + template: + metadata: + labels: + app: shibuya + spec: + serviceAccount: shibuya + containers: + - image: {{ .Values.apiserver.image.name }}:{{ .Values.apiserver.image.tag}} + name: shibuya + ports: + - containerPort: 8080 + volumeMounts: + - name: shibuya-config + mountPath: /config.json + subPath: config.json + volumes: + - name: shibuya-config + configMap: + name: shibuya-config-{{ .Values.context }} diff --git a/install/shibuya/templates/api.service.yaml b/install/shibuya/templates/api.service.yaml new file mode 100644 index 00000000..30e982e3 --- /dev/null +++ b/install/shibuya/templates/api.service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: shibuya + name: shibuya +spec: + ports: + - port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: shibuya diff --git a/install/shibuya/templates/configmap.yaml b/install/shibuya/templates/configmap.yaml new file mode 100644 index 00000000..8ebaf8c9 --- /dev/null +++ b/install/shibuya/templates/configmap.yaml @@ -0,0 +1,63 @@ +apiVersion: v1 +data: + config.json: | + { + "bg_color": "#f5f5f5", + "project_home": "https://confluence.rakuten-it.com/confluence/display/SPRJ/Shibuya+Project+Home", + "upload_file_help": "https://confluence.rakuten-it.com/confluence/display/SPRJ/Uploading+your+files+to+Shibuya", + "enable_sid": true, + "auth_config": { + "admin_users": {{ .Values.runtime.auth_config.admin_users }}, + "ldap_server": {{ .Values.runtime.auth_config.ldap_server | quote }}, + "ldap_port": {{ .Values.runtime.auth_config.ldap_port | quote }}, + "system_user": {{ .Values.runtime.auth_config.system_user | quote }}, + "system_password": {{ .Values.runtime.auth_config.system_password | quote }}, + "base_dn": {{ .Values.runtime.auth_config.base_dn | quote }}, + "session_key": {{ .Values.runtime.auth_config.session_key | quote }}, + "no_auth": {{ .Values.runtime.auth_config.no_auth }} + }, + "http_config": { + "proxy": "" + }, + "db": { + "host": {{ .Values.runtime.db.host | quote }}, + "user": {{ .Values.runtime.db.user | quote }}, + "password": {{ .Values.runtime.db.password | quote }}, + "database": {{ .Values.runtime.db.database | quote }}, + "keypairs": {{ .Values.runtime.db.keypairs | quote }} + }, + "executors": { + "cluster": { + "on_demand": {{ .Values.runtime.executors.cluster.on_demand }} + }, + "in_cluster": {{ .Values.runtime.executors.in_cluster }}, + "namespace": {{ .Values.runtime.executors.namespace | quote }}, + "jmeter": { + "image": {{ .Values.runtime.executors.jmeter.image | quote }}, + "cpu": {{ .Values.runtime.executors.jmeter.cpu | quote }}, + "mem": {{ .Values.runtime.executors.jmeter.mem | quote }} + }, + "pull_secret": {{ .Values.runtime.executors.pull_secret | quote }}, + "pull_policy": {{ .Values.runtime.executors.pull_policy | quote }} + }, + "ingress": { + "image": {{ .Values.runtime.ingress.image | quote }}, + "cpu": {{ .Values.runtime.ingress.cpu | quote }} + }, + "dashboard": { + "url": {{ .Values.runtime.dashboard.url | quote }}, + "run_dashboard": {{ .Values.runtime.dashboard.run_dashboard | quote }}, + "engine_dashboard": {{ .Values.runtime.dashboard.engine_dashboard | quote }} + }, + "object_storage": { + "provider": {{ .Values.runtime.object_storage.provider | quote }}, + "url": {{ .Values.runtime.object_storage.url | quote }} + }, + "log_format": { + "json": false + } + } +kind: ConfigMap +metadata: + name: shibuya-config-{{ .Values.context }} + namespace: {{ .Values.namespace }} diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml new file mode 100644 index 00000000..d96a3b69 --- /dev/null +++ b/install/shibuya/templates/controller.job.yaml @@ -0,0 +1,29 @@ +apiVersion: batch/v1 +kind: Job +metadata: + labels: + app: shibuya-controller + name: shibuya-controller + namespace: shibuya-executors +spec: + template: + metadata: + labels: + app: shibuya-controller + spec: + containers: + - image: {{ .Values.controller.image.name }}:{{ .Values.controller.image.tag}} + imagePullPolicy: IfNotPresent + name: shibuya-sc + volumeMounts: + - name: shibuya-config + mountPath: /config.json + subPath: config.json + dnsPolicy: ClusterFirst + restartPolicy: OnFailure + serviceAccount: shibuya + serviceAccountName: shibuya + volumes: + - name: shibuya-config + configMap: + name: shibuya-config-{{ .Values.context }} diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml new file mode 100644 index 00000000..4eea87f6 --- /dev/null +++ b/install/shibuya/values.yaml @@ -0,0 +1,62 @@ +namespace: shibuya-executors +context: local + +controller: + image: + name: controller + tag: local + +apiserver: + image: + name: shibuya + tag: local + +runtime: + bg_color: "#fff" + project_home: "" + upload_file_help: "" + auth_config: + admin_users: [] + ldap_server: "" + ldap_port: "" + system_user: "" + system_password: "" + base_dn: "" + no_auth: true + session_key: "" + http_config: + proxy: "" + db: + host: "db" + user: "root" + password: "root" + database: "shibuya" + keypairs: "" + executors: + cluster: + on_demand: false + project: "" + zone: "" + cluster_id: "" + gc_duration: "" + service_type: "" + in_cluster: true + namespace: "shibuya-executors" + jmeter: + image: shibuya:jmeter + cpu: 0.1 + mem: 512Mi + pull_secret: "" + pull_policy: "IfNotPresent" + ingress: + image: "shibuya:ingress-controller" + cpu: 0.1 + dashboard: + url: "http://localhost:3000" + run_dashboard: "/d/RXY8nM1mk2/shibuya" + engine_dashboard: "/d/9EH6xqTZz/shibuya-engine-health" + object_storage: + provider: local + url: "http://storage:8080" + user: "" + password: "" From f099f7da104ad14eeeaa5b1e7a97f2b81f853302 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 10 Aug 2023 12:08:35 +0900 Subject: [PATCH 08/47] use dockerhub base image for multi platform build --- shibuya/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shibuya/Dockerfile b/shibuya/Dockerfile index bccb7a5e..b9477a9f 100644 --- a/shibuya/Dockerfile +++ b/shibuya/Dockerfile @@ -1,4 +1,4 @@ -FROM gcr.io/shibuya-214807/ubuntu:18.04 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y curl RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ From 8ed44d15a002fcee5cbd90aeea48e283291395a3 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 10 Aug 2023 12:09:40 +0900 Subject: [PATCH 09/47] remove unused file --- shibuya/controller/cmd/deployment.yaml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 shibuya/controller/cmd/deployment.yaml diff --git a/shibuya/controller/cmd/deployment.yaml b/shibuya/controller/cmd/deployment.yaml deleted file mode 100644 index 7c792e0e..00000000 --- a/shibuya/controller/cmd/deployment.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shibuya-controller - labels: - app: shibuya-controller -spec: - replicas: 1 - selector: - matchLabels: - app: shibuya-controller - template: - metadata: - labels: - app: shibuya-controller - spec: - containers: - - name: shibuya-controller - image: sc:v0.1 From 0a3a22b874b7ca75c75dac7fd916c43f70652ada Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 10 Aug 2023 14:57:52 +0900 Subject: [PATCH 10/47] support distributed mode and non-distributed mode --- install/shibuya/templates/configmap.yaml | 1 + install/shibuya/templates/controller.job.yaml | 2 ++ install/shibuya/values.yaml | 1 + shibuya/config/init.go | 1 + shibuya/controller/cmd/main.go | 11 ++++++----- shibuya/controller/main.go | 12 ++++++++++++ 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/install/shibuya/templates/configmap.yaml b/install/shibuya/templates/configmap.yaml index 8ebaf8c9..67f4e50c 100644 --- a/install/shibuya/templates/configmap.yaml +++ b/install/shibuya/templates/configmap.yaml @@ -6,6 +6,7 @@ data: "project_home": "https://confluence.rakuten-it.com/confluence/display/SPRJ/Shibuya+Project+Home", "upload_file_help": "https://confluence.rakuten-it.com/confluence/display/SPRJ/Uploading+your+files+to+Shibuya", "enable_sid": true, + "distributed_mode": {{ .Values.runtime.distributed_mode }}, "auth_config": { "admin_users": {{ .Values.runtime.auth_config.admin_users }}, "ldap_server": {{ .Values.runtime.auth_config.ldap_server | quote }}, diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index d96a3b69..ec176979 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -1,3 +1,4 @@ +{{ if eq .Values.runtime.distributed_mode true }} apiVersion: batch/v1 kind: Job metadata: @@ -27,3 +28,4 @@ spec: - name: shibuya-config configMap: name: shibuya-config-{{ .Values.context }} +{{ end }} diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index 4eea87f6..dc5f126d 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -15,6 +15,7 @@ runtime: bg_color: "#fff" project_home: "" upload_file_help: "" + distributed_mode: false auth_config: admin_users: [] ldap_server: "" diff --git a/shibuya/config/init.go b/shibuya/config/init.go index b2f20f3e..802e8741 100644 --- a/shibuya/config/init.go +++ b/shibuya/config/init.go @@ -120,6 +120,7 @@ var defaultIngressConfig = IngressConfig{ type ShibuyaConfig struct { ProjectHome string `json:"project_home"` UploadFileHelp string `json:"upload_file_help"` + DistributedMode bool `json:"distributed_mode"` DBConf *MySQLConfig `json:"db"` ExecutorConfig *ExecutorConfig `json:"executors"` DashboardConfig *DashboardConfig `json:"dashboard"` diff --git a/shibuya/controller/cmd/main.go b/shibuya/controller/cmd/main.go index 55cf8e8d..44e89596 100644 --- a/shibuya/controller/cmd/main.go +++ b/shibuya/controller/cmd/main.go @@ -1,13 +1,14 @@ package main -import "github.com/rakutentech/shibuya/shibuya/controller" +import ( + "github.com/rakutentech/shibuya/shibuya/controller" + log "github.com/sirupsen/logrus" +) // This func keep tracks of all the running engines. They should just rely on the data in the db // and make necessary queries to the scheduler. func main() { + log.Info("Controller is running in distributed mode") controller := controller.NewController() - - controller.CheckRunningThenTerminate() - go controller.AutoPurgeDeployments() - go controller.AutoPurgeProjectIngressController() + controller.IsolateBackgroundTasks() } diff --git a/shibuya/controller/main.go b/shibuya/controller/main.go index 4d68d496..3ca74c4c 100644 --- a/shibuya/controller/main.go +++ b/shibuya/controller/main.go @@ -67,6 +67,18 @@ func (c *Controller) StartRunning() { go c.readConnectedEngines() go c.fetchEngineMetrics() go c.cleanLocalStore() + if !config.SC.DistributedMode { + log.Info("Controller is running in non-distributed mode!") + go c.IsolateBackgroundTasks() + } +} + +// In distributed mode, the func will be running as a standalone process +// In non-distributed mode, the func will be run as a goroutine. +func (c *Controller) IsolateBackgroundTasks() { + c.CheckRunningThenTerminate() + go c.AutoPurgeDeployments() + go c.AutoPurgeProjectIngressController() } func (c *Controller) streamToApi() { From 7e96fcce0993dee4e209ed867a7605641d200a59 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 10 Aug 2023 17:31:25 +0900 Subject: [PATCH 11/47] support kubeconfig cm in the manifests --- install/shibuya/templates/api.deploy.yaml | 12 ++++++++++++ install/shibuya/templates/controller.job.yaml | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml index 1ad3955f..16cce2ce 100644 --- a/install/shibuya/templates/api.deploy.yaml +++ b/install/shibuya/templates/api.deploy.yaml @@ -24,7 +24,19 @@ spec: - name: shibuya-config mountPath: /config.json subPath: config.json + {{ if eq .Values.runtime.executors.in_cluster false }} + - name: kubeconfig-volume + mountPath: /root/.kube/config + subPath: config + {{ end }} volumes: - name: shibuya-config configMap: name: shibuya-config-{{ .Values.context }} + {{ if eq .Values.runtime.executors.in_cluster false }} + - name: kubeconfig-volume + configMap: + defaultMode: 420 + name: shibuya-token-{{ .Values.context }} + {{ end }} + diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index ec176979..fdfd77dd 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -20,6 +20,11 @@ spec: - name: shibuya-config mountPath: /config.json subPath: config.json + {{ if eq .Values.runtime.executors.in_cluster false }} + - name: kubeconfig-volume + mountPath: /root/.kube/config + subPath: config + {{ end }} dnsPolicy: ClusterFirst restartPolicy: OnFailure serviceAccount: shibuya @@ -28,4 +33,10 @@ spec: - name: shibuya-config configMap: name: shibuya-config-{{ .Values.context }} + {{ if eq .Values.runtime.executors.in_cluster false }} + - name: kubeconfig-volume + configMap: + defaultMode: 420 + name: shibuya-token-{{ .Values.context }} + {{ end }} {{ end }} From b5952423665bb4849c9d0b33f117f9a807b0a180 Mon Sep 17 00:00:00 2001 From: iandyh Date: Sun, 13 Aug 2023 18:11:28 +0900 Subject: [PATCH 12/47] add helm to the docs --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b669b697..a78d45a3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ Collection is the unit where the actual tests are managed. Therefore, multiple t Pre-requisites: 1. Kind (https://kind.sigs.k8s.io) 2. kubectl (https://kubernetes.io/docs/tasks/tools/install-kubectl) -3. Docker (https://docs.docker.com/install) *On OSX please increase your docker machine's spec or you may face performance issues* +3. Helm (https://helm.sh/docs/intro/install/) +4. Docker (https://docs.docker.com/install) *On OSX please increase your docker machine's spec or you may face performance issues* Run `make` to start local cluster @@ -66,4 +67,4 @@ Please read the makefile to understand what components are needed and how to set - Adding more executor type support. For example, Gatling. Technically speaking, Shibuya can support any executor as long as the executor can provide real time metrics data in some way. - Manage muliple contexts in one controller. -- Better Authentication \ No newline at end of file +- Better Authentication From 64a804dd1d73f19b01fba88b91fd6b1b8589101a Mon Sep 17 00:00:00 2001 From: iandyh Date: Sun, 13 Aug 2023 19:57:29 +0900 Subject: [PATCH 13/47] add some docs about distributed mode --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index a78d45a3..49024e96 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,17 @@ Then you can go to http://localhost:8080 to check. note: Local Shibuya does not have authentication. So you need to put `shibuya` as the ownership of the project. This is the same if you turn off authentication in the config file. +## Distributed mode(WIP) + +In order to improve the scalibility of Shibuya, we are going to split the single Shibuya process into three components: + +- apiserver +- controller. +- Engine metric streamer(Not existing yet) + +By default, at locall, it will be run as non-distributed mode. You can enable to by set the `runtime.distributed_mode` to `true`. + + ### Production setup Please read the makefile to understand what components are needed and how to set them up in detail. From 602383de7cbff5f0e493a26ec71655403d007614 Mon Sep 17 00:00:00 2001 From: iandyh Date: Tue, 22 Aug 2023 22:14:28 +0900 Subject: [PATCH 14/47] support labels and envvars in the templates --- install/shibuya/templates/api.deploy.yaml | 14 +++++++++++--- install/shibuya/values.yaml | 7 +++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml index 16cce2ce..0a1d37a1 100644 --- a/install/shibuya/templates/api.deploy.yaml +++ b/install/shibuya/templates/api.deploy.yaml @@ -2,8 +2,9 @@ apiVersion: apps/v1 kind: Deployment metadata: labels: - app: shibuya - name: shibuya + {{- range .Values.apiserver.labels }} + {{.key }}: {{.value }} + {{- end }} spec: replicas: 1 selector: @@ -12,12 +13,19 @@ spec: template: metadata: labels: - app: shibuya + {{- range .Values.apiserver.labels }} + {{.key }}: {{.value }} + {{- end }} spec: serviceAccount: shibuya containers: - image: {{ .Values.apiserver.image.name }}:{{ .Values.apiserver.image.tag}} name: shibuya + env: + {{- range .Values.apiserver.envvars }} + - name: {{ .key | quote }} + value: {{ .value | quote }} + {{- end }} ports: - containerPort: 8080 volumeMounts: diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index dc5f126d..99f37efc 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -7,6 +7,13 @@ controller: tag: local apiserver: + labels: + - key: app + value: shibuya + envvars: + - key: env + value: local + image: name: shibuya tag: local From 5f168e48c2a1856201e3753004a314d4fb9755f0 Mon Sep 17 00:00:00 2001 From: iandyh Date: Wed, 23 Aug 2023 17:04:27 +0900 Subject: [PATCH 15/47] support resources and context name --- install/shibuya/templates/api.deploy.yaml | 8 ++++++++ install/shibuya/templates/controller.job.yaml | 9 ++++++++- install/shibuya/values.yaml | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml index 0a1d37a1..2291c8be 100644 --- a/install/shibuya/templates/api.deploy.yaml +++ b/install/shibuya/templates/api.deploy.yaml @@ -1,6 +1,7 @@ apiVersion: apps/v1 kind: Deployment metadata: + name: shibuya-apiserver-{{ .Values.context }} labels: {{- range .Values.apiserver.labels }} {{.key }}: {{.value }} @@ -21,6 +22,13 @@ spec: containers: - image: {{ .Values.apiserver.image.name }}:{{ .Values.apiserver.image.tag}} name: shibuya + resource: + requests: + cpu: {{ .Values.apiserver.resources.requests.cpu | quote }} + memory: {{ .Values.apiserver.resources.requests.memory | quote }} + limits: + cpu: {{ .Values.apiserver.resources.limits.cpu | quote }} + memory: {{ .Values.apiserver.resources.limits.memory | quote }} env: {{- range .Values.apiserver.envvars }} - name: {{ .key | quote }} diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index fdfd77dd..60eae0ba 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -4,7 +4,7 @@ kind: Job metadata: labels: app: shibuya-controller - name: shibuya-controller + name: shibuya-controller-{{ .Values.context }} namespace: shibuya-executors spec: template: @@ -16,6 +16,13 @@ spec: - image: {{ .Values.controller.image.name }}:{{ .Values.controller.image.tag}} imagePullPolicy: IfNotPresent name: shibuya-sc + resource: + requests: + cpu: {{ .Values.controller.resources.requests.cpu | quote }} + memory: {{ .Values.controller.resources.requests.memory | quote }} + limits: + cpu: {{ .Values.controller.resources.limits.cpu | quote }} + memory: {{ .Values.controller.resources.limits.memory | quote }} volumeMounts: - name: shibuya-config mountPath: /config.json diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index 99f37efc..548f4f2c 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -5,8 +5,22 @@ controller: image: name: controller tag: local + resources: + requests: + cpu: 0.1 + memory: 128Mi + limits: + cpu: 0.1 + memory: 128Mi apiserver: + resources: + requests: + cpu: 0.1 + memory: 128Mi + limits: + cpu: 0.1 + memory: 128Mi labels: - key: app value: shibuya From 47f365b00204d9aaa376359d037a4a80cdf39efd Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 24 Aug 2023 16:28:35 +0900 Subject: [PATCH 16/47] support annotations --- install/shibuya/templates/api.deploy.yaml | 6 ++++++ install/shibuya/templates/controller.job.yaml | 6 ++++++ install/shibuya/values.yaml | 2 ++ 3 files changed, 14 insertions(+) diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml index 2291c8be..a2d3506e 100644 --- a/install/shibuya/templates/api.deploy.yaml +++ b/install/shibuya/templates/api.deploy.yaml @@ -17,6 +17,12 @@ spec: {{- range .Values.apiserver.labels }} {{.key }}: {{.value }} {{- end }} + {{- if .Values.apiserver.annotations }} + annotations: + {{- range .Values.apiserver.annotations }} + {{.key }}: {{.value }} + {{- end }} + {{- end }} spec: serviceAccount: shibuya containers: diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index 60eae0ba..a572738c 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -11,6 +11,12 @@ spec: metadata: labels: app: shibuya-controller + {{- if .Values.controller.annotations }} + annotations: + {{- range .Values.controller.annotations }} + {{.key }}: {{.value }} + {{- end }} + {{- end }} spec: containers: - image: {{ .Values.controller.image.name }}:{{ .Values.controller.image.tag}} diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index 548f4f2c..085cafcf 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -5,6 +5,7 @@ controller: image: name: controller tag: local + annotations: [] resources: requests: cpu: 0.1 @@ -24,6 +25,7 @@ apiserver: labels: - key: app value: shibuya + annotations: [] envvars: - key: env value: local From 0fff565c9a2b163c8ca7ced5c2930d0a50953592 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 24 Aug 2023 16:32:02 +0900 Subject: [PATCH 17/47] support labels in controllers --- install/shibuya/templates/controller.job.yaml | 4 +++- install/shibuya/values.yaml | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index a572738c..a5a02b30 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -10,7 +10,9 @@ spec: template: metadata: labels: - app: shibuya-controller + {{- range .Values.controller.labels }} + {{.key }}: {{.value }} + {{- end }} {{- if .Values.controller.annotations }} annotations: {{- range .Values.controller.annotations }} diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index 085cafcf..70a4b4f9 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -5,6 +5,9 @@ controller: image: name: controller tag: local + labels: + - key: app + value: shibuya-controller annotations: [] resources: requests: @@ -24,7 +27,7 @@ apiserver: memory: 128Mi labels: - key: app - value: shibuya + value: shibuya-apiserver annotations: [] envvars: - key: env @@ -38,7 +41,7 @@ runtime: bg_color: "#fff" project_home: "" upload_file_help: "" - distributed_mode: false + distributed_mode: true auth_config: admin_users: [] ldap_server: "" From 9dcc536e336bedcba67185ec76339e7bd1067e30 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 24 Aug 2023 16:34:44 +0900 Subject: [PATCH 18/47] better operator usage --- install/shibuya/templates/api.deploy.yaml | 4 ++-- install/shibuya/templates/controller.job.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml index a2d3506e..d883703e 100644 --- a/install/shibuya/templates/api.deploy.yaml +++ b/install/shibuya/templates/api.deploy.yaml @@ -46,7 +46,7 @@ spec: - name: shibuya-config mountPath: /config.json subPath: config.json - {{ if eq .Values.runtime.executors.in_cluster false }} + {{ if not .Values.runtime.executors.in_cluster }} - name: kubeconfig-volume mountPath: /root/.kube/config subPath: config @@ -55,7 +55,7 @@ spec: - name: shibuya-config configMap: name: shibuya-config-{{ .Values.context }} - {{ if eq .Values.runtime.executors.in_cluster false }} + {{ if not .Values.runtime.executors.in_cluster }} - name: kubeconfig-volume configMap: defaultMode: 420 diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index a5a02b30..a0705c29 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -1,4 +1,4 @@ -{{ if eq .Values.runtime.distributed_mode true }} +{{ if .Values.runtime.distributed_mode }} apiVersion: batch/v1 kind: Job metadata: @@ -35,7 +35,7 @@ spec: - name: shibuya-config mountPath: /config.json subPath: config.json - {{ if eq .Values.runtime.executors.in_cluster false }} + {{ if not .Values.runtime.executors.in_cluster }} - name: kubeconfig-volume mountPath: /root/.kube/config subPath: config @@ -48,7 +48,7 @@ spec: - name: shibuya-config configMap: name: shibuya-config-{{ .Values.context }} - {{ if eq .Values.runtime.executors.in_cluster false }} + {{ if not .Values.runtime.executors.in_cluster }} - name: kubeconfig-volume configMap: defaultMode: 420 From f25520b29095890aacc256a87bd55fcc5ad21320 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 24 Aug 2023 16:40:25 +0900 Subject: [PATCH 19/47] support envvars in controller as well --- install/shibuya/templates/controller.job.yaml | 5 +++++ install/shibuya/values.yaml | 3 +++ 2 files changed, 8 insertions(+) diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index a0705c29..e5b89aee 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -31,6 +31,11 @@ spec: limits: cpu: {{ .Values.controller.resources.limits.cpu | quote }} memory: {{ .Values.controller.resources.limits.memory | quote }} + env: + {{- range .Values.controller.envvars }} + - name: {{ .key | quote }} + value: {{ .value | quote }} + {{- end }} volumeMounts: - name: shibuya-config mountPath: /config.json diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index 70a4b4f9..81611696 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -16,6 +16,9 @@ controller: limits: cpu: 0.1 memory: 128Mi + envvars: + - key: env + value: local apiserver: resources: From 2dbe18c57dc0b0506b919b9fb1393e3a4f7c884c Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 24 Aug 2023 16:41:18 +0900 Subject: [PATCH 20/47] fix white spaces in templates --- install/shibuya/templates/api.deploy.yaml | 8 ++++---- install/shibuya/templates/controller.job.yaml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml index d883703e..711814a8 100644 --- a/install/shibuya/templates/api.deploy.yaml +++ b/install/shibuya/templates/api.deploy.yaml @@ -46,19 +46,19 @@ spec: - name: shibuya-config mountPath: /config.json subPath: config.json - {{ if not .Values.runtime.executors.in_cluster }} + {{- if not .Values.runtime.executors.in_cluster }} - name: kubeconfig-volume mountPath: /root/.kube/config subPath: config - {{ end }} + {{- end }} volumes: - name: shibuya-config configMap: name: shibuya-config-{{ .Values.context }} - {{ if not .Values.runtime.executors.in_cluster }} + {{- if not .Values.runtime.executors.in_cluster }} - name: kubeconfig-volume configMap: defaultMode: 420 name: shibuya-token-{{ .Values.context }} - {{ end }} + {{- end }} diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index e5b89aee..c89fcc5e 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -40,11 +40,11 @@ spec: - name: shibuya-config mountPath: /config.json subPath: config.json - {{ if not .Values.runtime.executors.in_cluster }} + {{- if not .Values.runtime.executors.in_cluster }} - name: kubeconfig-volume mountPath: /root/.kube/config subPath: config - {{ end }} + {{- end }} dnsPolicy: ClusterFirst restartPolicy: OnFailure serviceAccount: shibuya @@ -53,10 +53,10 @@ spec: - name: shibuya-config configMap: name: shibuya-config-{{ .Values.context }} - {{ if not .Values.runtime.executors.in_cluster }} + {{- if not .Values.runtime.executors.in_cluster }} - name: kubeconfig-volume configMap: defaultMode: 420 name: shibuya-token-{{ .Values.context }} - {{ end }} + {{- end }} {{ end }} From e7d4922aaac03792277f1f51f841e02bbfb90c09 Mon Sep 17 00:00:00 2001 From: iandyh Date: Wed, 20 Sep 2023 10:27:27 +0900 Subject: [PATCH 21/47] fix template --- install/shibuya/templates/configmap.yaml | 6 +++++- install/shibuya/values.yaml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/install/shibuya/templates/configmap.yaml b/install/shibuya/templates/configmap.yaml index 67f4e50c..6e02aa9e 100644 --- a/install/shibuya/templates/configmap.yaml +++ b/install/shibuya/templates/configmap.yaml @@ -44,6 +44,7 @@ data: "ingress": { "image": {{ .Values.runtime.ingress.image | quote }}, "cpu": {{ .Values.runtime.ingress.cpu | quote }} + "replicas": {{ .Values.runtime.ingress.replicas | quote }} }, "dashboard": { "url": {{ .Values.runtime.dashboard.url | quote }}, @@ -52,7 +53,10 @@ data: }, "object_storage": { "provider": {{ .Values.runtime.object_storage.provider | quote }}, - "url": {{ .Values.runtime.object_storage.url | quote }} + {{- with .Values.runtime.object_storage.url }} + "url": {{ .url | quote }} + {{- end }} + "bucket": {{ .Values.runtime.object_storage.bucket | quote }} }, "log_format": { "json": false diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index 81611696..3c101fc2 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -52,7 +52,7 @@ runtime: system_user: "" system_password: "" base_dn: "" - no_auth: true + no_auth: false session_key: "" http_config: proxy: "" From 01ace68406ba564e0c22f9282a426a563ba0fdbd Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 21 Sep 2023 17:31:03 +0900 Subject: [PATCH 22/47] build the image using GitHub actions --- .github/workflows/build-publish.yml | 63 +++++++++++++++++++++++++++++ shibuya/Makefile | 22 ++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/workflows/build-publish.yml create mode 100644 shibuya/Makefile diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml new file mode 100644 index 00000000..19437808 --- /dev/null +++ b/.github/workflows/build-publish.yml @@ -0,0 +1,63 @@ +# This workflow will build a docker container, publish it to Google Container Registry, and deploy it to GKE when there is a push to the "master" branch. +# +# To configure this workflow: +# +# 1. Ensure that your repository contains the necessary configuration for your Google Kubernetes Engine cluster, including deployment.yml, kustomization.yml, service.yml, etc. +# +# 2. Create and configure a Workload Identity Provider for GitHub (https://github.com/google-github-actions/auth#setting-up-workload-identity-federation) +# +# 3. Change the values for the GAR_LOCATION, GKE_ZONE, GKE_CLUSTER, IMAGE, REPOSITORY and DEPLOYMENT_NAME environment variables (below). +# +# For more support on how to run the workflow, please visit https://github.com/google-github-actions/setup-gcloud/tree/master/example-workflows/gke-kustomize + +name: Build and Deploy to GCP registry + +on: + push: + branches: [ "split" ] + +env: + GAR_LOCATION: asia-northeast1 # TODO: update region of the Artifact Registry + IMAGE: shibuya + +jobs: + setup-build-publish-deploy: + name: Setup, Build, Publish + runs-on: ubuntu-20.04 + environment: production + + permissions: + contents: 'read' + id-token: 'write' + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.17' + + - id: 'auth' + uses: 'google-github-actions/auth@v1' + with: + credentials_json: '${{ secrets.GCP_CREDENTIALS }}' + token_format: 'access_token' + + - name: Docker configuration + run: |- + echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev + + # Build the Docker image + - name: Build api + run: |- + cd shibuya && make api_image component=api + + - name: Build controller + run: |- + cd shibuya && make controller_image component=controller + # Push the Docker image to Google Artifact Registry + # - name: Publish + # run: |- + # docker push "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA" diff --git a/shibuya/Makefile b/shibuya/Makefile new file mode 100644 index 00000000..b3b6a4a8 --- /dev/null +++ b/shibuya/Makefile @@ -0,0 +1,22 @@ +registry=$(GAR_LOCATION)-docker.pkg.dev/$(GCP_PROJECT) +repository = shibuya +tag=$(GITHUB_SHA) +img=$(registry)/$(repository)/$(component):$(tag) + +.PHONY: api_build +api_build: + sh build.sh + +.PHONY: api_image +api_image: api_build + docker build -t $(img) -f Dockerfile . + docker push $(img) + +.PHONY: controller_build +controller_build: + sh build.sh controller + +.PHONY: controller_image +controller_image: controller_build + docker build -t $(img) -f Dockerfile --build-arg="binary_name=shibuya-controller" . + docker push $(img) From 0f13923ce7262dc98c757ede61a73b25359713fe Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 22 Sep 2023 14:26:41 +0900 Subject: [PATCH 23/47] fix install --- install/shibuya/templates/api.deploy.yaml | 6 ++++-- install/shibuya/templates/api.service.yaml | 4 +++- install/shibuya/templates/configmap.yaml | 6 +++--- install/shibuya/templates/controller.job.yaml | 2 +- install/shibuya/values.yaml | 6 ++++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml index 711814a8..ce5ecc64 100644 --- a/install/shibuya/templates/api.deploy.yaml +++ b/install/shibuya/templates/api.deploy.yaml @@ -10,7 +10,9 @@ spec: replicas: 1 selector: matchLabels: - app: shibuya + {{- range .Values.apiserver.labels }} + {{.key }}: {{.value }} + {{- end }} template: metadata: labels: @@ -28,7 +30,7 @@ spec: containers: - image: {{ .Values.apiserver.image.name }}:{{ .Values.apiserver.image.tag}} name: shibuya - resource: + resources: requests: cpu: {{ .Values.apiserver.resources.requests.cpu | quote }} memory: {{ .Values.apiserver.resources.requests.memory | quote }} diff --git a/install/shibuya/templates/api.service.yaml b/install/shibuya/templates/api.service.yaml index 30e982e3..27b65a4a 100644 --- a/install/shibuya/templates/api.service.yaml +++ b/install/shibuya/templates/api.service.yaml @@ -10,4 +10,6 @@ spec: protocol: TCP targetPort: 8080 selector: - app: shibuya + {{- range .Values.apiserver.labels }} + {{.key }}: {{.value }} + {{- end }} diff --git a/install/shibuya/templates/configmap.yaml b/install/shibuya/templates/configmap.yaml index 6e02aa9e..1d3abaf1 100644 --- a/install/shibuya/templates/configmap.yaml +++ b/install/shibuya/templates/configmap.yaml @@ -43,8 +43,8 @@ data: }, "ingress": { "image": {{ .Values.runtime.ingress.image | quote }}, - "cpu": {{ .Values.runtime.ingress.cpu | quote }} - "replicas": {{ .Values.runtime.ingress.replicas | quote }} + "cpu": {{ .Values.runtime.ingress.cpu | quote }}, + "replicas": {{ .Values.runtime.ingress.replicas }} }, "dashboard": { "url": {{ .Values.runtime.dashboard.url | quote }}, @@ -54,7 +54,7 @@ data: "object_storage": { "provider": {{ .Values.runtime.object_storage.provider | quote }}, {{- with .Values.runtime.object_storage.url }} - "url": {{ .url | quote }} + "url": {{ . | quote }}, {{- end }} "bucket": {{ .Values.runtime.object_storage.bucket | quote }} }, diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index c89fcc5e..43f2ce14 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -24,7 +24,7 @@ spec: - image: {{ .Values.controller.image.name }}:{{ .Values.controller.image.tag}} imagePullPolicy: IfNotPresent name: shibuya-sc - resource: + resources: requests: cpu: {{ .Values.controller.resources.requests.cpu | quote }} memory: {{ .Values.controller.resources.requests.memory | quote }} diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index 3c101fc2..a04fef9b 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -37,7 +37,7 @@ apiserver: value: local image: - name: shibuya + name: api tag: local runtime: @@ -52,7 +52,7 @@ runtime: system_user: "" system_password: "" base_dn: "" - no_auth: false + no_auth: true session_key: "" http_config: proxy: "" @@ -81,6 +81,7 @@ runtime: ingress: image: "shibuya:ingress-controller" cpu: 0.1 + replicas: 1 dashboard: url: "http://localhost:3000" run_dashboard: "/d/RXY8nM1mk2/shibuya" @@ -90,3 +91,4 @@ runtime: url: "http://storage:8080" user: "" password: "" + bucket: "" From 969565ee62d715ef0057b2c39d875230bd3bd0bf Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 22 Sep 2023 14:45:02 +0900 Subject: [PATCH 24/47] support the new way of building the images --- install/shibuya/templates/api.deploy.yaml | 2 +- install/shibuya/templates/controller.job.yaml | 2 +- install/shibuya/values.yaml | 3 ++- makefile | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/install/shibuya/templates/api.deploy.yaml b/install/shibuya/templates/api.deploy.yaml index ce5ecc64..d5c82cab 100644 --- a/install/shibuya/templates/api.deploy.yaml +++ b/install/shibuya/templates/api.deploy.yaml @@ -28,7 +28,7 @@ spec: spec: serviceAccount: shibuya containers: - - image: {{ .Values.apiserver.image.name }}:{{ .Values.apiserver.image.tag}} + - image: {{ .Values.repository }}{{ .Values.apiserver.image.name }}:{{ .Values.tag }} name: shibuya resources: requests: diff --git a/install/shibuya/templates/controller.job.yaml b/install/shibuya/templates/controller.job.yaml index 43f2ce14..0a07a5da 100644 --- a/install/shibuya/templates/controller.job.yaml +++ b/install/shibuya/templates/controller.job.yaml @@ -21,7 +21,7 @@ spec: {{- end }} spec: containers: - - image: {{ .Values.controller.image.name }}:{{ .Values.controller.image.tag}} + - image: {{ .Values.repository }}{{ .Values.controller.image.name }}:{{ .Values.tag }} imagePullPolicy: IfNotPresent name: shibuya-sc resources: diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index a04fef9b..a964ced1 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -1,10 +1,11 @@ namespace: shibuya-executors context: local +tag: local +repository: "" controller: image: name: controller - tag: local labels: - key: app value: shibuya-controller diff --git a/makefile b/makefile index 7f7178e4..0c45849c 100644 --- a/makefile +++ b/makefile @@ -36,8 +36,8 @@ grafana: grafana/ .PHONY: shibuya shibuya: shibuya/ kubernetes/ cd shibuya && sh build.sh - docker build -f shibuya/Dockerfile --build-arg env=local -t shibuya:local shibuya - kind load docker-image shibuya:local --name shibuya + docker build -f shibuya/Dockerfile --build-arg env=local -t api:local shibuya + kind load docker-image api:local --name shibuya helm uninstall shibuya || true helm upgrade --install shibuya install/shibuya From 2abbeed014aa3fa38a0714da5ec1b44f93b92b27 Mon Sep 17 00:00:00 2001 From: iandyh Date: Mon, 25 Sep 2023 11:25:23 +0900 Subject: [PATCH 25/47] supporting node affinities and tolerations --- install/shibuya/templates/configmap.yaml | 21 +++++++++++++++++++++ install/shibuya/values.yaml | 2 ++ 2 files changed, 23 insertions(+) diff --git a/install/shibuya/templates/configmap.yaml b/install/shibuya/templates/configmap.yaml index 1d3abaf1..dbce2d8c 100644 --- a/install/shibuya/templates/configmap.yaml +++ b/install/shibuya/templates/configmap.yaml @@ -40,6 +40,27 @@ data: }, "pull_secret": {{ .Values.runtime.executors.pull_secret | quote }}, "pull_policy": {{ .Values.runtime.executors.pull_policy | quote }} + {{- if len .Values.runtime.executors.node_affinity }} + ",node_affinity": [ + {{- range .Values.runtime.executors.node_affinity }} + { + "key": {{ .key }}, + "value": {{ .value }} + } + {{- end }} + ] + {{- end }} + {{- if len .Values.runtime.executors.tolerations -}} + ,tolerations: [ + {{- range .Values.runtime.executors.tolerations }} + { + "key": {{ .key }}, + "value": {{ .value }}, + "effect": {{ .effect }} + } + {{- end }} + ] + {{- end }} }, "ingress": { "image": {{ .Values.runtime.ingress.image | quote }}, diff --git a/install/shibuya/values.yaml b/install/shibuya/values.yaml index a964ced1..c66c0971 100644 --- a/install/shibuya/values.yaml +++ b/install/shibuya/values.yaml @@ -79,6 +79,8 @@ runtime: mem: 512Mi pull_secret: "" pull_policy: "IfNotPresent" + node_affinity: [] + tolerations: [] ingress: image: "shibuya:ingress-controller" cpu: 0.1 From b8623218c9023c82581f975970ac62e8dae9fe9d Mon Sep 17 00:00:00 2001 From: iandyh Date: Mon, 25 Sep 2023 11:47:14 +0900 Subject: [PATCH 26/47] support building helm charts --- shibuya/.gitignore | 2 ++ shibuya/Makefile | 5 +++++ {install => shibuya/install}/shibuya/.helmignore | 0 {install => shibuya/install}/shibuya/Chart.yaml | 0 .../install}/shibuya/templates/api.deploy.yaml | 0 .../install}/shibuya/templates/api.service.yaml | 0 .../install}/shibuya/templates/configmap.yaml | 0 .../install}/shibuya/templates/controller.job.yaml | 0 {install => shibuya/install}/shibuya/values.yaml | 0 9 files changed, 7 insertions(+) create mode 100644 shibuya/.gitignore rename {install => shibuya/install}/shibuya/.helmignore (100%) rename {install => shibuya/install}/shibuya/Chart.yaml (100%) rename {install => shibuya/install}/shibuya/templates/api.deploy.yaml (100%) rename {install => shibuya/install}/shibuya/templates/api.service.yaml (100%) rename {install => shibuya/install}/shibuya/templates/configmap.yaml (100%) rename {install => shibuya/install}/shibuya/templates/controller.job.yaml (100%) rename {install => shibuya/install}/shibuya/values.yaml (100%) diff --git a/shibuya/.gitignore b/shibuya/.gitignore new file mode 100644 index 00000000..a14f5913 --- /dev/null +++ b/shibuya/.gitignore @@ -0,0 +1,2 @@ +*.tgz +shibuya-install/* diff --git a/shibuya/Makefile b/shibuya/Makefile index b3b6a4a8..a52a9630 100644 --- a/shibuya/Makefile +++ b/shibuya/Makefile @@ -20,3 +20,8 @@ controller_build: controller_image: controller_build docker build -t $(img) -f Dockerfile --build-arg="binary_name=shibuya-controller" . docker push $(img) + +.PHONY: helm_charts +helm_charts: + helm create shibuya-install + helm package shibuya-install/ diff --git a/install/shibuya/.helmignore b/shibuya/install/shibuya/.helmignore similarity index 100% rename from install/shibuya/.helmignore rename to shibuya/install/shibuya/.helmignore diff --git a/install/shibuya/Chart.yaml b/shibuya/install/shibuya/Chart.yaml similarity index 100% rename from install/shibuya/Chart.yaml rename to shibuya/install/shibuya/Chart.yaml diff --git a/install/shibuya/templates/api.deploy.yaml b/shibuya/install/shibuya/templates/api.deploy.yaml similarity index 100% rename from install/shibuya/templates/api.deploy.yaml rename to shibuya/install/shibuya/templates/api.deploy.yaml diff --git a/install/shibuya/templates/api.service.yaml b/shibuya/install/shibuya/templates/api.service.yaml similarity index 100% rename from install/shibuya/templates/api.service.yaml rename to shibuya/install/shibuya/templates/api.service.yaml diff --git a/install/shibuya/templates/configmap.yaml b/shibuya/install/shibuya/templates/configmap.yaml similarity index 100% rename from install/shibuya/templates/configmap.yaml rename to shibuya/install/shibuya/templates/configmap.yaml diff --git a/install/shibuya/templates/controller.job.yaml b/shibuya/install/shibuya/templates/controller.job.yaml similarity index 100% rename from install/shibuya/templates/controller.job.yaml rename to shibuya/install/shibuya/templates/controller.job.yaml diff --git a/install/shibuya/values.yaml b/shibuya/install/shibuya/values.yaml similarity index 100% rename from install/shibuya/values.yaml rename to shibuya/install/shibuya/values.yaml From 709a3de2f5e565939ed6ed90cf633f459318a43d Mon Sep 17 00:00:00 2001 From: iandyh Date: Mon, 25 Sep 2023 11:47:42 +0900 Subject: [PATCH 27/47] configure auth for helm --- .github/workflows/build-publish.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 19437808..f2fb81a0 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -49,6 +49,10 @@ jobs: run: |- echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev + - name: Helm configuration + run: |- + echo '${{ steps.auth.outputs.access_token }}' | helm registry login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev + # Build the Docker image - name: Build api run: |- @@ -57,6 +61,10 @@ jobs: - name: Build controller run: |- cd shibuya && make controller_image component=controller + + - name: Build helm charts + run: |- + cd install && make helm_charts # Push the Docker image to Google Artifact Registry # - name: Publish # run: |- From 9b0567bde821bf132d18b93bc54dbd9acc6f932e Mon Sep 17 00:00:00 2001 From: iandyh Date: Mon, 25 Sep 2023 15:10:48 +0900 Subject: [PATCH 28/47] use helm chart releaser --- .github/workflows/build-publish.yml | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index f2fb81a0..447c1b9a 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -26,13 +26,11 @@ jobs: runs-on: ubuntu-20.04 environment: production - permissions: - contents: 'read' - id-token: 'write' - steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v4 @@ -49,10 +47,6 @@ jobs: run: |- echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev - - name: Helm configuration - run: |- - echo '${{ steps.auth.outputs.access_token }}' | helm registry login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev - # Build the Docker image - name: Build api run: |- @@ -62,10 +56,17 @@ jobs: run: |- cd shibuya && make controller_image component=controller - - name: Build helm charts - run: |- - cd install && make helm_charts - # Push the Docker image to Google Artifact Registry - # - name: Publish - # run: |- - # docker push "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA" + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v3 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.5.0 + with: + charts_dir: shibuya/install + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" From c4b19b6e979ceeed85cef48c31d0ac0aebb09992 Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 29 Sep 2023 14:59:28 +0900 Subject: [PATCH 29/47] support image pull secrets --- shibuya/install/shibuya/templates/api.deploy.yaml | 8 +++++++- shibuya/install/shibuya/templates/controller.job.yaml | 8 +++++++- shibuya/install/shibuya/values.yaml | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/shibuya/install/shibuya/templates/api.deploy.yaml b/shibuya/install/shibuya/templates/api.deploy.yaml index d5c82cab..dad7054f 100644 --- a/shibuya/install/shibuya/templates/api.deploy.yaml +++ b/shibuya/install/shibuya/templates/api.deploy.yaml @@ -37,6 +37,12 @@ spec: limits: cpu: {{ .Values.apiserver.resources.limits.cpu | quote }} memory: {{ .Values.apiserver.resources.limits.memory | quote }} + {{- if .Values.image_pull_secrets }} + imagePullSecrets: + {{- range .Values.image_pull_secrets }} + - name: {{ .name }} + {{- end }} + {{- end }} env: {{- range .Values.apiserver.envvars }} - name: {{ .key | quote }} @@ -61,6 +67,6 @@ spec: - name: kubeconfig-volume configMap: defaultMode: 420 - name: shibuya-token-{{ .Values.context }} + name: shibuya-token-{{ .Values.cluster_name }} {{- end }} diff --git a/shibuya/install/shibuya/templates/controller.job.yaml b/shibuya/install/shibuya/templates/controller.job.yaml index 0a07a5da..d6ec154f 100644 --- a/shibuya/install/shibuya/templates/controller.job.yaml +++ b/shibuya/install/shibuya/templates/controller.job.yaml @@ -31,6 +31,12 @@ spec: limits: cpu: {{ .Values.controller.resources.limits.cpu | quote }} memory: {{ .Values.controller.resources.limits.memory | quote }} + {{- if .Values.image_pull_secrets }} + imagePullSecrets: + {{- range .Values.image_pull_secrets }} + - name: {{ .name }} + {{- end }} + {{- end }} env: {{- range .Values.controller.envvars }} - name: {{ .key | quote }} @@ -57,6 +63,6 @@ spec: - name: kubeconfig-volume configMap: defaultMode: 420 - name: shibuya-token-{{ .Values.context }} + name: shibuya-token-{{ .Values.cluster_name }} {{- end }} {{ end }} diff --git a/shibuya/install/shibuya/values.yaml b/shibuya/install/shibuya/values.yaml index c66c0971..e20e664b 100644 --- a/shibuya/install/shibuya/values.yaml +++ b/shibuya/install/shibuya/values.yaml @@ -1,7 +1,9 @@ namespace: shibuya-executors context: local +cluster_name: local tag: local repository: "" +image_pull_secrets: [] controller: image: From 3e76c7301191d746e9615197617eccb111af10b0 Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 29 Sep 2023 15:48:07 +0900 Subject: [PATCH 30/47] fix service name and labels --- shibuya/install/shibuya/templates/api.service.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shibuya/install/shibuya/templates/api.service.yaml b/shibuya/install/shibuya/templates/api.service.yaml index 27b65a4a..b313f7a8 100644 --- a/shibuya/install/shibuya/templates/api.service.yaml +++ b/shibuya/install/shibuya/templates/api.service.yaml @@ -1,9 +1,11 @@ apiVersion: v1 kind: Service metadata: + name: shibuya-api-{{ .Values.context }} labels: - app: shibuya - name: shibuya + {{- range .Values.apiserver.labels }} + {{.key }}: {{.value }} + {{- end }} spec: ports: - port: 8080 From 66316dbd5314e49d192e0f9f4ea031cbe79c3892 Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 29 Sep 2023 16:07:21 +0900 Subject: [PATCH 31/47] fix imagepull secrets --- shibuya/install/shibuya/templates/api.deploy.yaml | 13 +++++++------ .../install/shibuya/templates/controller.job.yaml | 12 ++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/shibuya/install/shibuya/templates/api.deploy.yaml b/shibuya/install/shibuya/templates/api.deploy.yaml index dad7054f..5aad655f 100644 --- a/shibuya/install/shibuya/templates/api.deploy.yaml +++ b/shibuya/install/shibuya/templates/api.deploy.yaml @@ -27,6 +27,12 @@ spec: {{- end }} spec: serviceAccount: shibuya + {{- if .Values.image_pull_secrets }} + imagePullSecrets: + {{- range .Values.image_pull_secrets }} + - name: {{ .name }} + {{- end }} + {{- end }} containers: - image: {{ .Values.repository }}{{ .Values.apiserver.image.name }}:{{ .Values.tag }} name: shibuya @@ -37,12 +43,7 @@ spec: limits: cpu: {{ .Values.apiserver.resources.limits.cpu | quote }} memory: {{ .Values.apiserver.resources.limits.memory | quote }} - {{- if .Values.image_pull_secrets }} - imagePullSecrets: - {{- range .Values.image_pull_secrets }} - - name: {{ .name }} - {{- end }} - {{- end }} + env: {{- range .Values.apiserver.envvars }} - name: {{ .key | quote }} diff --git a/shibuya/install/shibuya/templates/controller.job.yaml b/shibuya/install/shibuya/templates/controller.job.yaml index d6ec154f..ea43642e 100644 --- a/shibuya/install/shibuya/templates/controller.job.yaml +++ b/shibuya/install/shibuya/templates/controller.job.yaml @@ -31,12 +31,6 @@ spec: limits: cpu: {{ .Values.controller.resources.limits.cpu | quote }} memory: {{ .Values.controller.resources.limits.memory | quote }} - {{- if .Values.image_pull_secrets }} - imagePullSecrets: - {{- range .Values.image_pull_secrets }} - - name: {{ .name }} - {{- end }} - {{- end }} env: {{- range .Values.controller.envvars }} - name: {{ .key | quote }} @@ -55,6 +49,12 @@ spec: restartPolicy: OnFailure serviceAccount: shibuya serviceAccountName: shibuya + {{- if .Values.image_pull_secrets }} + imagePullSecrets: + {{- range .Values.image_pull_secrets }} + - name: {{ .name }} + {{- end }} + {{- end }} volumes: - name: shibuya-config configMap: From 75e3dad7eb8a7d13bcd3733496eef0401b4973af Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 29 Sep 2023 16:16:33 +0900 Subject: [PATCH 32/47] controller should be a deployment not a job --- .../{controller.job.yaml => controller.deploy.yaml} | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) rename shibuya/install/shibuya/templates/{controller.job.yaml => controller.deploy.yaml} (92%) diff --git a/shibuya/install/shibuya/templates/controller.job.yaml b/shibuya/install/shibuya/templates/controller.deploy.yaml similarity index 92% rename from shibuya/install/shibuya/templates/controller.job.yaml rename to shibuya/install/shibuya/templates/controller.deploy.yaml index ea43642e..51689bcc 100644 --- a/shibuya/install/shibuya/templates/controller.job.yaml +++ b/shibuya/install/shibuya/templates/controller.deploy.yaml @@ -1,12 +1,17 @@ {{ if .Values.runtime.distributed_mode }} -apiVersion: batch/v1 -kind: Job +apiVersion: apps/v1 +kind: Deployment metadata: labels: app: shibuya-controller name: shibuya-controller-{{ .Values.context }} - namespace: shibuya-executors spec: + replicas: 1 + selector: + matchLabels: + {{- range .Values.controller.labels }} + {{.key }}: {{.value }} + {{- end }} template: metadata: labels: @@ -46,7 +51,6 @@ spec: subPath: config {{- end }} dnsPolicy: ClusterFirst - restartPolicy: OnFailure serviceAccount: shibuya serviceAccountName: shibuya {{- if .Values.image_pull_secrets }} From ca66702ca62ac722e82ad09d0e74c0bf7943bc08 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 7 Dec 2023 16:03:55 +0900 Subject: [PATCH 33/47] improve the format --- shibuya/install/shibuya/templates/api.deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shibuya/install/shibuya/templates/api.deploy.yaml b/shibuya/install/shibuya/templates/api.deploy.yaml index 5aad655f..c5007bf7 100644 --- a/shibuya/install/shibuya/templates/api.deploy.yaml +++ b/shibuya/install/shibuya/templates/api.deploy.yaml @@ -4,14 +4,14 @@ metadata: name: shibuya-apiserver-{{ .Values.context }} labels: {{- range .Values.apiserver.labels }} - {{.key }}: {{.value }} + {{ .key }}: {{ .value }} {{- end }} spec: replicas: 1 selector: matchLabels: {{- range .Values.apiserver.labels }} - {{.key }}: {{.value }} + {{ .key }}: {{ .value }} {{- end }} template: metadata: From 681290978d637463a5e5761c4bef5985e7bd5daa Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 7 Dec 2023 16:04:12 +0900 Subject: [PATCH 34/47] add the port name --- shibuya/install/shibuya/templates/api.service.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/shibuya/install/shibuya/templates/api.service.yaml b/shibuya/install/shibuya/templates/api.service.yaml index b313f7a8..41709e52 100644 --- a/shibuya/install/shibuya/templates/api.service.yaml +++ b/shibuya/install/shibuya/templates/api.service.yaml @@ -11,6 +11,7 @@ spec: - port: 8080 protocol: TCP targetPort: 8080 + name: http selector: {{- range .Values.apiserver.labels }} {{.key }}: {{.value }} From 1a46d94ee375b628148477f67c48648138daf681 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 7 Dec 2023 16:04:38 +0900 Subject: [PATCH 35/47] render the json list --- shibuya/install/shibuya/templates/configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shibuya/install/shibuya/templates/configmap.yaml b/shibuya/install/shibuya/templates/configmap.yaml index dbce2d8c..ca3d6ef7 100644 --- a/shibuya/install/shibuya/templates/configmap.yaml +++ b/shibuya/install/shibuya/templates/configmap.yaml @@ -8,7 +8,7 @@ data: "enable_sid": true, "distributed_mode": {{ .Values.runtime.distributed_mode }}, "auth_config": { - "admin_users": {{ .Values.runtime.auth_config.admin_users }}, + "admin_users": {{ .Values.runtime.auth_config.admin_users | toJson }}, "ldap_server": {{ .Values.runtime.auth_config.ldap_server | quote }}, "ldap_port": {{ .Values.runtime.auth_config.ldap_port | quote }}, "system_user": {{ .Values.runtime.auth_config.system_user | quote }}, From b52e014e66b25b0d3f57ac2d5166bb2a058c7f62 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 7 Dec 2023 16:05:42 +0900 Subject: [PATCH 36/47] fix labels and format --- shibuya/install/shibuya/templates/controller.deploy.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shibuya/install/shibuya/templates/controller.deploy.yaml b/shibuya/install/shibuya/templates/controller.deploy.yaml index 51689bcc..e2feada8 100644 --- a/shibuya/install/shibuya/templates/controller.deploy.yaml +++ b/shibuya/install/shibuya/templates/controller.deploy.yaml @@ -3,20 +3,22 @@ apiVersion: apps/v1 kind: Deployment metadata: labels: - app: shibuya-controller + {{- range .Values.controller.labels }} + {{ .key }}: {{ .value }} + {{- end }} name: shibuya-controller-{{ .Values.context }} spec: replicas: 1 selector: matchLabels: {{- range .Values.controller.labels }} - {{.key }}: {{.value }} + {{ .key }}: {{ .value }} {{- end }} template: metadata: labels: {{- range .Values.controller.labels }} - {{.key }}: {{.value }} + {{ .key }}: {{ .value }} {{- end }} {{- if .Values.controller.annotations }} annotations: From c2de9399c9d4a0f85670af160a157b333f521fe9 Mon Sep 17 00:00:00 2001 From: iandyh Date: Thu, 7 Dec 2023 16:14:06 +0900 Subject: [PATCH 37/47] handle the auth keys that required for connecting with gcp services --- shibuya/install/shibuya/templates/api.deploy.yaml | 10 ++++++++++ .../install/shibuya/templates/controller.deploy.yaml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/shibuya/install/shibuya/templates/api.deploy.yaml b/shibuya/install/shibuya/templates/api.deploy.yaml index c5007bf7..0f09f78b 100644 --- a/shibuya/install/shibuya/templates/api.deploy.yaml +++ b/shibuya/install/shibuya/templates/api.deploy.yaml @@ -60,6 +60,11 @@ spec: mountPath: /root/.kube/config subPath: config {{- end }} + {{- if eq .Values.runtime.object_storage.provider "gcp" }} + - name: shibuya-gcp-auth + mountPath: /auth/shibuya-gcp.json + subPath: shibuya-gcp.json + {{- end }} volumes: - name: shibuya-config configMap: @@ -70,4 +75,9 @@ spec: defaultMode: 420 name: shibuya-token-{{ .Values.cluster_name }} {{- end }} + {{- if eq .Values.runtime.object_storage.provider "gcp" }} + - name: shibuya-gcp-auth + secret: + secretName: shibuya-auth-keys-gcp + {{- end }} diff --git a/shibuya/install/shibuya/templates/controller.deploy.yaml b/shibuya/install/shibuya/templates/controller.deploy.yaml index e2feada8..ab3ef400 100644 --- a/shibuya/install/shibuya/templates/controller.deploy.yaml +++ b/shibuya/install/shibuya/templates/controller.deploy.yaml @@ -52,6 +52,11 @@ spec: mountPath: /root/.kube/config subPath: config {{- end }} + {{- if eq .Values.runtime.object_storage.provider "gcp" }} + - name: shibuya-gcp-auth + mountPath: /auth/shibuya-gcp.json + subPath: shibuya-gcp.json + {{- end }} dnsPolicy: ClusterFirst serviceAccount: shibuya serviceAccountName: shibuya @@ -71,4 +76,9 @@ spec: defaultMode: 420 name: shibuya-token-{{ .Values.cluster_name }} {{- end }} + {{- if eq .Values.runtime.object_storage.provider "gcp" }} + - name: shibuya-gcp-auth + secret: + secretName: shibuya-auth-keys-gcp + {{- end }} {{ end }} From 7d81fd05b90682fbddf5f07105d40ebb07e961ee Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 8 Dec 2023 13:34:21 +0900 Subject: [PATCH 38/47] fix missing configs --- shibuya/install/shibuya/templates/configmap.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shibuya/install/shibuya/templates/configmap.yaml b/shibuya/install/shibuya/templates/configmap.yaml index ca3d6ef7..22843f34 100644 --- a/shibuya/install/shibuya/templates/configmap.yaml +++ b/shibuya/install/shibuya/templates/configmap.yaml @@ -29,7 +29,9 @@ data: }, "executors": { "cluster": { - "on_demand": {{ .Values.runtime.executors.cluster.on_demand }} + "on_demand": {{ .Values.runtime.executors.cluster.on_demand }}, + "service_type": {{ .Values.runtime.executors.cluster.service_type | quote }}, + "gc_duration": {{ .Values.runtime.executors.cluster.gc_duration }} }, "in_cluster": {{ .Values.runtime.executors.in_cluster }}, "namespace": {{ .Values.runtime.executors.namespace | quote }}, @@ -40,6 +42,7 @@ data: }, "pull_secret": {{ .Values.runtime.executors.pull_secret | quote }}, "pull_policy": {{ .Values.runtime.executors.pull_policy | quote }} + {{- if len .Values.runtime.executors.node_affinity }} ",node_affinity": [ {{- range .Values.runtime.executors.node_affinity }} From 928ae0f1f124ccdfc2392d48aeb39411b6469cf1 Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 16 Feb 2024 15:42:46 +0900 Subject: [PATCH 39/47] fix configmap template in tolerations --- shibuya/install/shibuya/templates/configmap.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shibuya/install/shibuya/templates/configmap.yaml b/shibuya/install/shibuya/templates/configmap.yaml index 22843f34..15e40d4b 100644 --- a/shibuya/install/shibuya/templates/configmap.yaml +++ b/shibuya/install/shibuya/templates/configmap.yaml @@ -44,7 +44,7 @@ data: "pull_policy": {{ .Values.runtime.executors.pull_policy | quote }} {{- if len .Values.runtime.executors.node_affinity }} - ",node_affinity": [ + ,"node_affinity": [ {{- range .Values.runtime.executors.node_affinity }} { "key": {{ .key }}, @@ -54,7 +54,7 @@ data: ] {{- end }} {{- if len .Values.runtime.executors.tolerations -}} - ,tolerations: [ + ,"tolerations": [ {{- range .Values.runtime.executors.tolerations }} { "key": {{ .key }}, From 1d17ce2e77aea7b144ef8a6e896858717d98dbab Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 16 Feb 2024 17:29:57 +0900 Subject: [PATCH 40/47] fix configmap template in tolerations --- .../install/shibuya/templates/configmap.yaml | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/shibuya/install/shibuya/templates/configmap.yaml b/shibuya/install/shibuya/templates/configmap.yaml index 15e40d4b..9d5cb8b5 100644 --- a/shibuya/install/shibuya/templates/configmap.yaml +++ b/shibuya/install/shibuya/templates/configmap.yaml @@ -43,24 +43,30 @@ data: "pull_secret": {{ .Values.runtime.executors.pull_secret | quote }}, "pull_policy": {{ .Values.runtime.executors.pull_policy | quote }} - {{- if len .Values.runtime.executors.node_affinity }} + {{- $node_affinity := .Values.runtime.executors.node_affinity -}} + {{- $count := len $node_affinity -}} + {{- if $count }} ,"node_affinity": [ - {{- range .Values.runtime.executors.node_affinity }} + {{- range $index, $item := $node_affinity }} + {{- $t := add $index 1 -}} { - "key": {{ .key }}, - "value": {{ .value }} - } + "key": {{ $item.key | quote }}, + "value": {{ $item.value | quote }} + }{{- if lt $t $count }},{{- end }} {{- end }} ] {{- end }} - {{- if len .Values.runtime.executors.tolerations -}} + {{- $tolerations := .Values.runtime.executors.tolerations -}} + {{- $count := len $tolerations -}} + {{- if $count }} ,"tolerations": [ - {{- range .Values.runtime.executors.tolerations }} + {{- range $index, $item := $tolerations }} + {{- $t := add $index 1 -}} { - "key": {{ .key }}, - "value": {{ .value }}, - "effect": {{ .effect }} - } + "key": {{ $item.key | quote }}, + "value": {{ $item.value | quote }}, + "effect": {{ $item.effect | quote }} + }{{- if lt $t $count }},{{- end }} {{- end }} ] {{- end }} From 6f4e5d970147a976e6551027585b2ae87a4b438a Mon Sep 17 00:00:00 2001 From: iandyh Date: Tue, 20 Feb 2024 09:58:40 +0900 Subject: [PATCH 41/47] add master branch to event hook --- .github/workflows/build-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 447c1b9a..8f937c53 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -14,7 +14,7 @@ name: Build and Deploy to GCP registry on: push: - branches: [ "split" ] + branches: [ "split", "master" ] env: GAR_LOCATION: asia-northeast1 # TODO: update region of the Artifact Registry From fafce57125d3590866ffa3944b3dd4a7cf14c853 Mon Sep 17 00:00:00 2001 From: iandyh Date: Tue, 20 Feb 2024 16:13:15 +0900 Subject: [PATCH 42/47] specify helm version --- .github/workflows/build-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 8f937c53..3b298598 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -63,6 +63,8 @@ jobs: - name: Install Helm uses: azure/setup-helm@v3 + with: + version: "v3.13.3" - name: Run chart-releaser uses: helm/chart-releaser-action@v1.5.0 From e1adab80e3442911575052304429dfed6e3b4481 Mon Sep 17 00:00:00 2001 From: iandyh Date: Fri, 17 May 2024 10:48:01 +0900 Subject: [PATCH 43/47] should use the color of value files --- shibuya/install/shibuya/templates/configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shibuya/install/shibuya/templates/configmap.yaml b/shibuya/install/shibuya/templates/configmap.yaml index 9d5cb8b5..31262b53 100644 --- a/shibuya/install/shibuya/templates/configmap.yaml +++ b/shibuya/install/shibuya/templates/configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 data: config.json: | { - "bg_color": "#f5f5f5", + "bg_color": {{ .Values.runtime.bg_color | quote }}, "project_home": "https://confluence.rakuten-it.com/confluence/display/SPRJ/Shibuya+Project+Home", "upload_file_help": "https://confluence.rakuten-it.com/confluence/display/SPRJ/Uploading+your+files+to+Shibuya", "enable_sid": true, From 6afd1260df14ebfd1de924b0c6de2628ad0953f4 Mon Sep 17 00:00:00 2001 From: "Kejun Huang a.k.a Andy" Date: Thu, 13 Jun 2024 14:38:58 +0900 Subject: [PATCH 44/47] add some logs --- shibuya/controller/garbage.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shibuya/controller/garbage.go b/shibuya/controller/garbage.go index eea81931..b8ce5c11 100644 --- a/shibuya/controller/garbage.go +++ b/shibuya/controller/garbage.go @@ -40,6 +40,7 @@ func (c *Controller) CheckRunningThenTerminate() { for { runningPlans, err := model.GetRunningPlans() if err != nil { + log.Error(err) continue } localCache := make(map[int64]*model.Collection) @@ -47,6 +48,7 @@ func (c *Controller) CheckRunningThenTerminate() { var collection *model.Collection var ok bool collection, ok = localCache[rp.CollectionID] + log.Info("handling: ", rp.CollectionID) if !ok { collection, err = model.GetCollection(rp.CollectionID) if err != nil { @@ -108,6 +110,7 @@ func isCollectionStale(rh *model.RunHistory, launchTime time.Time) (bool, error) } func (c *Controller) AutoPurgeDeployments() { + log.Info("Start the loop for purging idle engines") for { deployedCollections, err := c.Scheduler.GetDeployedCollections() if err != nil { @@ -152,6 +155,7 @@ func (c *Controller) AutoPurgeDeployments() { // 1. If none of the collections has a run, it will be the last launch time of the engines of a collection // 2. If any of the collection has a run, it will be the end time of that run func (c *Controller) AutoPurgeProjectIngressController() { + log.Info("Start the loop for purging idle ingress controllers") projectLastUsedTime := make(map[int64]time.Time) ingressLifespan, err := time.ParseDuration(config.SC.IngressConfig.Lifespan) if err != nil { From 4cbd4ad9588ca910ca666d8240a9638797bce841 Mon Sep 17 00:00:00 2001 From: "Kejun Huang a.k.a Andy" Date: Thu, 13 Jun 2024 15:01:59 +0900 Subject: [PATCH 45/47] add some logs --- shibuya/controller/garbage.go | 1 - 1 file changed, 1 deletion(-) diff --git a/shibuya/controller/garbage.go b/shibuya/controller/garbage.go index b8ce5c11..74dd8512 100644 --- a/shibuya/controller/garbage.go +++ b/shibuya/controller/garbage.go @@ -48,7 +48,6 @@ func (c *Controller) CheckRunningThenTerminate() { var collection *model.Collection var ok bool collection, ok = localCache[rp.CollectionID] - log.Info("handling: ", rp.CollectionID) if !ok { collection, err = model.GetCollection(rp.CollectionID) if err != nil { From f71f1350d89145e85158133df4f1311d0d5fc3c8 Mon Sep 17 00:00:00 2001 From: "Kejun Huang a.k.a Andy" Date: Thu, 13 Jun 2024 15:34:33 +0900 Subject: [PATCH 46/47] trigger the goroutine funcs first --- shibuya/controller/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shibuya/controller/main.go b/shibuya/controller/main.go index 3ca74c4c..9add4745 100644 --- a/shibuya/controller/main.go +++ b/shibuya/controller/main.go @@ -76,9 +76,9 @@ func (c *Controller) StartRunning() { // In distributed mode, the func will be running as a standalone process // In non-distributed mode, the func will be run as a goroutine. func (c *Controller) IsolateBackgroundTasks() { - c.CheckRunningThenTerminate() go c.AutoPurgeDeployments() go c.AutoPurgeProjectIngressController() + c.CheckRunningThenTerminate() } func (c *Controller) streamToApi() { From 354fdb2f7a86de11eaa92d8a795152ae72ecad52 Mon Sep 17 00:00:00 2001 From: "Kejun Huang a.k.a Andy" Date: Thu, 13 Jun 2024 17:52:47 +0900 Subject: [PATCH 47/47] move engine health checks out from isolated controller loop --- shibuya/controller/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/shibuya/controller/main.go b/shibuya/controller/main.go index 9add4745..890afa02 100644 --- a/shibuya/controller/main.go +++ b/shibuya/controller/main.go @@ -67,6 +67,10 @@ func (c *Controller) StartRunning() { go c.readConnectedEngines() go c.fetchEngineMetrics() go c.cleanLocalStore() + // We can only move this func to an isolated controller process later + // because when we are terminating, we also need to close the opening connections + // Otherwise we might face connection leaks + go c.CheckRunningThenTerminate() if !config.SC.DistributedMode { log.Info("Controller is running in non-distributed mode!") go c.IsolateBackgroundTasks() @@ -77,8 +81,7 @@ func (c *Controller) StartRunning() { // In non-distributed mode, the func will be run as a goroutine. func (c *Controller) IsolateBackgroundTasks() { go c.AutoPurgeDeployments() - go c.AutoPurgeProjectIngressController() - c.CheckRunningThenTerminate() + c.AutoPurgeProjectIngressController() } func (c *Controller) streamToApi() {