Skip to content

Commit

Permalink
create helm template for benchmark operator (#2027)
Browse files Browse the repository at this point in the history
* ✨ create helm template for benchmark operator

Signed-off-by: vankichi <[email protected]>

* ✨ refactor helm template

Signed-off-by: vankichi <[email protected]>

* style: Format code with gofumpt and prettier

---------

Signed-off-by: vankichi <[email protected]>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
  • Loading branch information
vankichi and deepsource-autofix[bot] committed Dec 12, 2023
1 parent fa37c63 commit ed65d72
Show file tree
Hide file tree
Showing 36 changed files with 6,505 additions and 1,297 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/dockers-benchmark-job-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ on:
- "internal/**"
- "!internal/**/*_test.go"
- "!internal/db/**"
- "!internal/k8s/**"
- "apis/grpc/**"
- "pkg/benchmark/job/**"
- "cmd/benchmark/job/**"
- "dockers/benchmark/job/Dockerfile"
- "versions/GO_VERSION"
- "versions/NGT_VERSION"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref != 'refs/heads/main' && github.ref || github.sha }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
build:
strategy:
Expand Down Expand Up @@ -114,7 +117,7 @@ jobs:
name: Slack notification
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || startsWith( github.ref, 'refs/tags/')
if: github.ref == 'refs/heads/main' || startsWith( github.ref, 'refs/tags/')
steps:
- uses: technote-space/workflow-conclusion-action@v2
with:
Expand Down
132 changes: 132 additions & 0 deletions .github/workflows/dockers-benchmark-operator-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: "Build docker image: benchmark-operator"
on:
push:
branches:
- master
tags:
- "*.*.*"
- "v*.*.*"
- "*.*.*-*"
- "v*.*.*-*"
paths:
- ".github/actions/docker-build/actions.yaml"
- ".github/workflows/dockers-benchmak-operator-image.yml"
- "go.mod"
- "go.sum"
- "internal/**"
- "!internal/**/*_test.go"
- "!internal/db/**"
- "!internal/k8s/**"
- "apis/grpc/**"
- "pkg/benchmark/operator/**"
- "cmd/benchmark/operator/**"
- "dockers/benchmark/operator/Dockerfile"
- "versions/GO_VERSION"
- "versions/NGT_VERSION"
pull_request:
paths:
- ".github/actions/docker-build/actions.yaml"
- ".github/workflows/dockers-benchmak-operator-image.yml"
- "go.mod"
- "go.sum"
- "internal/**"
- "!internal/**/*_test.go"
- "!internal/db/**"
- "apis/grpc/**"
- "pkg/benchmark/operator/**"
- "cmd/benchmark/operator/**"
- "dockers/benchmark/operator/Dockerfile"
- "versions/GO_VERSION"
- "versions/NGT_VERSION"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref != 'refs/heads/main' && github.ref || github.sha }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
build:
strategy:
max-parallel: 4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: "--debug"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.PACKAGE_USER }}
password: ${{ secrets.PACKAGE_TOKEN }}
- name: Build and Publish
id: build_and_publish
uses: ./.github/actions/docker-build
with:
target: benchmark-operator
builder: ${{ steps.buildx.outputs.name }}
- name: Initialize CodeQL
if: startsWith( github.ref, 'refs/tags/')
uses: github/codeql-action/init@v2
- name: Run vulnerability scanner (table)
if: startsWith( github.ref, 'refs/tags/')
uses: aquasecurity/trivy-action@master
with:
image-ref: "${{ steps.build_and_publish.outputs.IMAGE_NAME }}:${{ steps.build_and_publish.outputs.PRIMARY_TAG }}"
format: "table"
- name: Run vulnerability scanner (sarif)
if: startsWith( github.ref, 'refs/tags/')
uses: aquasecurity/trivy-action@master
with:
image-ref: "${{ steps.build_and_publish.outputs.IMAGE_NAME }}:${{ steps.build_and_publish.outputs.PRIMARY_TAG }}"
format: "template"
template: "@/contrib/sarif.tpl"
output: "trivy-results.sarif"
- name: Upload Trivy scan results to Security tab
if: startsWith( github.ref, 'refs/tags/')
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
slack:
name: Slack notification
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith( github.ref, 'refs/tags/')
steps:
- uses: technote-space/workflow-conclusion-action@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: 8398a7/action-slack@v3
with:
author_name: benchmark-operator image build
status: ${{ env.WORKFLOW_CONCLUSION }}
only_mention_fail: channel
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_WEBHOOK_URL }}
42 changes: 42 additions & 0 deletions Makefile.d/helm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ charts/vald-helm-operator/values.schema.json: \
GOPRIVATE=$(GOPRIVATE) \
go run -mod=readonly hack/helm/schema/gen/main.go charts/vald-helm-operator/values.yaml > charts/vald-helm-operator/values.schema.json

.PHONY: helm/schema/vald-benchmark-job
## generate json schema for Vald Benchmark Job Chart
helm/schema/vald-benchmark-job: charts/vald-benchmark-operator/job-values.schema.json

charts/vald-benchmark-operator/job-values.schema.json: \
charts/vald-benchmark-operator/schemas/job-values.yaml \
hack/helm/schema/gen/main.go
GOPRIVATE=$(GOPRIVATE) \
go run -mod=readonly hack/helm/schema/gen/main.go charts/vald-benchmark-operator/schemas/job-values.yaml > charts/vald-benchmark-operator/job-values.schema.json

.PHONY: helm/schema/vald-benchmark-job
## generate json schema for Vald Benchmark Job Chart
helm/schema/vald-benchmark-scenario: charts/vald-benchmark-operator/scenario-values.schema.json

charts/vald-benchmark-operator/scenario-values.schema.json: \
charts/vald-benchmark-operator/schemas/scenario-values.yaml \
hack/helm/schema/gen/main.go
GOPRIVATE=$(GOPRIVATE) \
go run -mod=readonly hack/helm/schema/gen/main.go charts/vald-benchmark-operator/schemas/scenario-values.yaml > charts/vald-benchmark-operator/scenario-values.schema.json

.PHONY: helm/schema/vald-benchmark-operator
## generate json schema for Vald Benchmark Operator Chart
helm/schema/vald-benchmark-operator: charts/vald-benchmark-operator/values.schema.json
Expand Down Expand Up @@ -133,6 +153,28 @@ helm/schema/crd/vald-helm-operator: \
$(BINDIR)/yq eval-all 'select(fileIndex==0).spec.versions[0].schema.openAPIV3Schema.properties.spec = select(fileIndex==1).spec | select(fileIndex==0)' \
$(TEMP_DIR)/valdhelmoperatorrelease.yaml $(TEMP_DIR)/valdhelmoperatorrelease-spec.yaml > charts/vald-helm-operator/crds/valdhelmoperatorrelease.yaml

.PHONY: helm/schema/crd/vald-benchmark-job
## generate OpenAPI v3 schema for ValdBenchmarkJobRelease
helm/schema/crd/vald-benchmark-job: \
yq/install
mv charts/vald-benchmark-operator/crds/valdbenchmarkjob.yaml $(TEMP_DIR)/valdbenchmarkjob.yaml
GOPRIVATE=$(GOPRIVATE) \
go run -mod=readonly hack/helm/schema/crd/main.go \
charts/vald-benchmark-operator/schemas/job-values.yaml > $(TEMP_DIR)/valdbenchmarkjob-spec.yaml
$(BINDIR)/yq eval-all 'select(fileIndex==0).spec.versions[0].schema.openAPIV3Schema.properties.spec = select(fileIndex==1).spec | select(fileIndex==0)' \
$(TEMP_DIR)/valdbenchmarkjob.yaml $(TEMP_DIR)/valdbenchmarkjob-spec.yaml > charts/vald-benchmark-operator/crds/valdbenchmarkjob.yaml

.PHONY: helm/schema/crd/vald-benchmark-scenario
## generate OpenAPI v3 schema for ValdBenchmarkScenarioRelease
helm/schema/crd/vald-benchmark-scenario: \
yq/install
mv charts/vald-benchmark-operator/crds/valdbenchmarkscenario.yaml $(TEMP_DIR)/valdbenchmarkscenario.yaml
GOPRIVATE=$(GOPRIVATE) \
go run -mod=readonly hack/helm/schema/crd/main.go \
charts/vald-benchmark-operator/schemas/scenario-values.yaml > $(TEMP_DIR)/valdbenchmarkscenario-spec.yaml
$(BINDIR)/yq eval-all 'select(fileIndex==0).spec.versions[0].schema.openAPIV3Schema.properties.spec = select(fileIndex==1).spec | select(fileIndex==0)' \
$(TEMP_DIR)/valdbenchmarkscenario.yaml $(TEMP_DIR)/valdbenchmarkscenario-spec.yaml > charts/vald-benchmark-operator/crds/valdbenchmarkscenario.yaml

.PHONY: helm/schema/crd/vald-benchmark-operator
## generate OpenAPI v3 schema for ValdBenchmarkOperatorRelease
helm/schema/crd/vald-benchmark-operator: \
Expand Down
45 changes: 45 additions & 0 deletions Makefile.d/k8s.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ k8s/manifest/helm-operator/update: \
rm -rf $(TEMP_DIR)
cp -r charts/vald-helm-operator/crds k8s/operator/helm/crds

.PHONY: k8s/manifest/benchmark-operator/clean
## clean k8s manifests for benchmark-operator
k8s/manifest/benchmark-operator/clean:
rm -rf \
k8s/tools/benchmark/operator

.PHONY: k8s/manifest/benchmark-operator/update
## update k8s manifests for benchmark-operator using helm templates
k8s/manifest/benchmark-operator/update: \
k8s/manifest/benchmark-operator/clean
helm template \
--output-dir $(TEMP_DIR) \
charts/vald-benchmark-operator
mkdir -p k8s/tools/benchmark
mv $(TEMP_DIR)/vald-benchmark-operator/templates k8s/tools/benchmark/operator
rm -rf $(TEMP_DIR)
cp -r charts/vald-benchmark-operator/crds k8s/tools/benchmark/operator/crds

.PHONY: k8s/vald/deploy
## deploy vald sample cluster to k8s
Expand Down Expand Up @@ -169,6 +186,34 @@ k8s/vr/delete: \
k8s/metrics/metrics-server/delete
kubectl delete vr vald-cluster

.PHONY: k8s/vald-benchmark-operator/deploy
## deploy vald-benchmark-operator to k8s
k8s/vald-benchmark-operator/deploy:
helm template \
--output-dir $(TEMP_DIR) \
--set image.tag=${VERSION} \
--include-crds \
charts/vald-benchmark-operator
kubectl create -f $(TEMP_DIR)/vald-benchmark-operator/crds/valdbenchmarkjob.yaml
kubectl create -f $(TEMP_DIR)/vald-benchmark-operator/crds/valdbenchmarkscenario.yaml
kubectl create -f $(TEMP_DIR)/vald-benchmark-operator/crds/valdbenchmarkoperatorrelease.yaml
kubectl apply -f $(TEMP_DIR)/vald-benchmark-operator/templates
sleep 2
kubectl wait --for=condition=ready pod -l name=vald-benchmark-operator --timeout=600s

.PHONY: k8s/vald-benchmark-operator/delete
## delete vald-benchmark-operator from k8s
k8s/vald-benchmark-operator/delete:
helm template \
--output-dir $(TEMP_DIR) \
--set image.tag=${VERSION} \
--include-crds \
charts/vald-benchmark-operator
kubectl delete -f $(TEMP_DIR)/vald-benchmark-operator/templates
kubectl wait --for=delete pod -l name=vald-benchmark-operator --timeout=600s
kubectl delete -f $(TEMP_DIR)/vald-benchmark-operator/crds
rm -rf $(TEMP_DIR)

.PHONY: k8s/external/cert-manager/deploy
## deploy cert-manager
k8s/external/cert-manager/deploy:
Expand Down
62 changes: 62 additions & 0 deletions charts/vald-benchmark-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
appVersion: "1.16.0"
#
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

apiVersion: v2
name: vald-benchmark-operator
version: v1.7.5
description: A benchmark operator for benchmarking the Vald cluster.
type: application
keywords:
- Vald
- NGT
- vector
- search
- approximate-nearest-neighbor-search
- nearest-neighbor-search
- vector-search-engine
- similarity-search
- image-search
- Kubernetes
- k8s
- AI
- artificial-intelligence
home: https://vald.vdaas.org
icon: https://raw.githubusercontent.com/vdaas/vald/main/assets/image/svg/symbol.svg
sources:
- https://github.com/vdaas/vald
maintainers:
- name: kpango
email: [email protected]
- name: vankichi
email: [email protected]
- name: kmrmt
email: [email protected]
Loading

0 comments on commit ed65d72

Please sign in to comment.