Skip to content

Commit

Permalink
feat: support weaviate standalone (apecloud#2345)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayutah authored Mar 31, 2023
1 parent 315731b commit 8a6258f
Show file tree
Hide file tree
Showing 14 changed files with 1,319 additions and 0 deletions.
9 changes: 9 additions & 0 deletions deploy/weaviate-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: weaviate-cluster
description: A weaviate cluster Helm chart for KubeBlocks.

type: application

version: 0.1.0

appVersion: "1.18.0"
2 changes: 2 additions & 0 deletions deploy/weaviate-cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. Get the application URL by running these commands:

62 changes: 62 additions & 0 deletions deploy/weaviate-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "weaviate.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "weaviate.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "weaviate.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "weaviate.labels" -}}
helm.sh/chart: {{ include "weaviate.chart" . }}
{{ include "weaviate.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "weaviate.selectorLabels" -}}
app.kubernetes.io/name: {{ include "weaviate.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "weaviate.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "weaviate.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
46 changes: 46 additions & 0 deletions deploy/weaviate-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
name: {{ .Release.Name }}
labels: {{ include "weaviate.labels" . | nindent 4 }}
spec:
clusterDefinitionRef: weaviate-standalone # ref clusterdefinition.name
clusterVersionRef: weaviate-{{ default .Chart.AppVersion .Values.clusterVersionOverride }} # ref clusterversion.name
terminationPolicy: {{ .Values.terminationPolicy }}
affinity:
{{- with .Values.topologyKeys }}
topologyKeys: {{ . | toYaml | nindent 6 }}
{{- end }}
{{- with $.Values.tolerations }}
tolerations: {{ . | toYaml | nindent 4 }}
{{- end }}
componentSpecs:
- name: weaviate # user-defined
componentDefRef: weaviate # ref clusterdefinition components.name
monitor: {{ .Values.monitor.enabled | default false }}
replicas: {{ .Values.replicaCount | default 1 }}
{{- with .Values.resources }}
resources:
{{- with .limits }}
limits:
cpu: {{ .cpu | quote }}
memory: {{ .memory | quote }}
{{- end }}
{{- with .requests }}
requests:
cpu: {{ .cpu | quote }}
memory: {{ .memory | quote }}
{{- end }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- name: data # ref clusterdefinition components.containers.volumeMounts.name
spec:
storageClassName: {{ .Values.persistence.data.storageClassName }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.persistence.data.size }}
{{- end }}

29 changes: 29 additions & 0 deletions deploy/weaviate-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Default values for wesqlcluster.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1
terminationPolicy: Delete

clusterVersionOverride: ""

monitor:
enabled: false

resources: { }
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.

# limits:
# cpu: 500m
# memory: 2Gi
# requests:
# cpu: 100m
# memory: 1Gi
persistence:
enabled: true
data:
storageClassName:
size: 10Gi
23 changes: 23 additions & 0 deletions deploy/weaviate/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
name: weaviate-standalone
description: .

type: application

# This is the chart version.
version: 0.1.0

# This is the version number of weaviate.
appVersion: "1.18.0"

home: https://weaviate.tech/
icon: https://weaviate.tech/images/logo_with_text.svg


maintainers:
- name: ApeCloud
url: https://github.com/apecloud/kubeblocks/


sources:
- https://github.com/apecloud/kubeblocks/
2 changes: 2 additions & 0 deletions deploy/weaviate/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. Get the application URL by running these commands:

52 changes: 52 additions & 0 deletions deploy/weaviate/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "weaviate.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "weaviate.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "weaviate.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "weaviate.labels" -}}
helm.sh/chart: {{ include "weaviate.chart" . }}
{{ include "weaviate.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "weaviate.selectorLabels" -}}
app.kubernetes.io/name: {{ include "weaviate.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

15 changes: 15 additions & 0 deletions deploy/weaviate/templates/backuppolicytemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: dataprotection.kubeblocks.io/v1alpha1
kind: BackupPolicyTemplate
metadata:
name: backup-policy-template-weaviate
labels:
clusterdefinition.kubeblocks.io/name: weaviate-standalone
{{- include "weaviate.labels" . | nindent 4 }}
spec:
# which backup tool to perform database backup, only support one tool.
backupToolName: volumesnapshot
ttl: 168h0m0s

credentialKeyword:
userKeyword: username
passwordKeyword: password
130 changes: 130 additions & 0 deletions deploy/weaviate/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterDefinition
metadata:
name: weaviate-standalone
labels:
{{- include "weaviate.labels" . | nindent 4 }}
spec:
connectionCredential:
username: root
password: "$(RANDOM_PASSWD)"
endpoint: "$(SVC_FQDN):$(SVC_PORT_tcp-weaviate)"
host: "$(SVC_FQDN)"
port: "$(SVC_PORT_tcp-weaviate)"
componentDefs:
- name: weaviate
workloadType: Stateful
characterType: weaviate
probes:
monitor:
builtIn: false
exporterConfig:
scrapePath: /metrics
scrapePort: 9187
logConfigs:
configSpecs:
- name: weaviate-standalone-config-template
templateRef: weaviate-standalone-config-template
volumeName: weaviate-config
namespace: {{ .Release.Namespace }}
service:
ports:
- name: tcp-weaviate
protocol: TCP
port: 8080
targetPort: tcp-weaviate
volumeTypes:
- name: data
type: data
podSpec:
securityContext:
fsGroup: 1001
containers:
- name: weaviate
imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}}
command:
- /bin/weaviate
args:
- --host
- 0.0.0.0
- --port
- "8080"
- --scheme
- http
- --config-file
- /weaviate-config/conf.yaml
- --read-timeout=60s
- --write-timeout=60s
securityContext:
runAsUser: 0
livenessProbe:
failureThreshold: 30
httpGet:
path: /v1/.well-known/live
port: 8080
scheme: HTTP
initialDelaySeconds: 900
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 3
readinessProbe:
failureThreshold: 3
httpGet:
path: /v1/.well-known/ready
port: 8080
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 3
startupProbe:
failureThreshold: 3
httpGet:
path: /v1/.well-known/ready
port: 8080
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 3
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /weaviate-config
name: weaviate-config
- mountPath: /var/lib/weaviate
name: data
dnsPolicy: ClusterFirst
enableServiceLinks: true
ports:
- name: tcp-weaviate
containerPort: 8080
- name: tcp-metrics
containerPort: 9091
env:
- name: CLUSTER_DATA_BIND_PORT
value: "7001"
- name: CLUSTER_GOSSIP_BIND_PORT
value: "7000"
- name: GOGC
value: "100"
- name: PROMETHEUS_MONITORING_ENABLED
value: "false"
- name: QUERY_MAXIMUM_RESULTS
value: "100000"
- name: REINDEX_VECTOR_DIMENSIONS_AT_STARTUP
value: "false"
- name: TRACK_VECTOR_DIMENSIONS
value: "false"
- name: STANDALONE_MODE
value: 'true'
- name: PERSISTENCE_DATA_PATH
value: '/var/lib/weaviate'
- name: DEFAULT_VECTORIZER_MODULE
value: none
- name: CLUSTER_GOSSIP_BIND_PORT
value: "7000"
- name: CLUSTER_DATA_BIND_PORT
value: "7001"
- name: CLUSTER_JOIN
value: weaviate-headless.default.svc.cluster.local
14 changes: 14 additions & 0 deletions deploy/weaviate/templates/clusterversion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterVersion
metadata:
name: weaviate-{{ default .Chart.AppVersion .Values.clusterVersionOverride }}
labels:
{{- include "weaviate.labels" . | nindent 4 }}
spec:
clusterDefinitionRef: weaviate-standalone
componentVersions:
- componentDefRef: weaviate
versionsContext:
containers:
- name: weaviate
image: {{ .Values.images.weaviate.repository }}:{{ default .Chart.AppVersion .Values.images.weaviate.tag }}
Loading

0 comments on commit 8a6258f

Please sign in to comment.