Skip to content

Commit

Permalink
cherry-pick from 0e19ca8 and update xinference cpu image version
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnleelhl committed Nov 16, 2023
1 parent ad54cd6 commit 41c3850
Show file tree
Hide file tree
Showing 26 changed files with 399 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ build-kbcli-embed-chart: helmtool create-kbcli-embed-charts-dir \
build-single-kbcli-embed-chart.postgresql-cluster \
build-single-kbcli-embed-chart.kafka-cluster \
build-single-kbcli-embed-chart.mongodb-cluster \
build-single-kbcli-embed-chart.llm-cluster \
build-single-kbcli-embed-chart.xinference-cluster \
# build-single-kbcli-embed-chart.neon-cluster
# build-single-kbcli-embed-chart.postgresql-cluster \
# build-single-kbcli-embed-chart.clickhouse-cluster \
Expand Down
5 changes: 3 additions & 2 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/dataprotection/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/extensions/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/storage/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/workloads/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions deploy/helm/templates/addons/xinference-addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: extensions.kubeblocks.io/v1alpha1
kind: Addon
metadata:
name: xinference
labels:
{{- include "kubeblocks.labels" . | nindent 4 }}
"kubeblocks.io/provider": community
{{- if .Values.keepAddons }}
annotations:
helm.sh/resource-policy: keep
{{- end }}
spec:
description: 'xinference'

type: Helm

helm:
{{- include "kubeblocks.addonChartLocationURL" ( dict "name" "xinference" "version" (default .Chart.Version .Values.versionOverride) "values" .Values) | indent 4 }}
{{- include "kubeblocks.addonChartsImage" . | indent 4 }}

installOptions:
{{- if hasPrefix "oci://" .Values.addonChartLocationBase }}
version: {{ default .Chart.Version .Values.versionOverride }}
{{- end }}

installable:
autoInstall: false

defaultInstallValues:
- enabled: false
24 changes: 24 additions & 0 deletions deploy/xinference-cluster/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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/
*.lock
27 changes: 27 additions & 0 deletions deploy/xinference-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
annotations:
category: Database
apiVersion: v2
name: xinference-cluster
type: application
version: 0.7.0-alpha.0
description: A vxinference Cluster Helm chart for KubeBlocks.
dependencies:
- name: kblib
version: 0.1.0
repository: file://../kblib
alias: extra

appVersion: "7.0.6"

keywords:
- xinference

home: https://github.com/apecloud/kubeblocks/tree/main/deploy/xinference-cluster
icon: https://kubeblocks.io/img/logo.png

maintainers:
- name: ApeCloud
url: https://kubeblocks.io/

sources:
- https://github.com/apecloud/kubeblocks/
2 changes: 2 additions & 0 deletions deploy/xinference-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:

3 changes: 3 additions & 0 deletions deploy/xinference-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{/*
Define xinference cluster component.
*/}}
20 changes: 20 additions & 0 deletions deploy/xinference-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- include "kblib.clusterCommon" . }}
clusterDefinitionRef: xinference # ref clusterDefinition.name
{{ if .Values.cpuMode }}
clusterVersionRef: {{ .Values.cpuVersion }}
{{ end }}
componentSpecs:
- name: xinference
componentDefRef: xinference # ref clusterDefinition componentDefs.name
{{- include "kblib.componentMonitor" . | indent 6 }}
replicas: {{ .Values.replicas }}
serviceAccountName: {{ include "kblib.serviceAccountName" . }}
{{ if .Values.cpuMode }}
{{- include "kblib.componentResources" . | indent 6 }}
{{ else }}
resources:
limits:
nvidia.com/gpu: {{ .Values.gpu }}
requests:
nvidia.com/gpu: {{ .Values.gpu }}
{{ end }}
1 change: 1 addition & 0 deletions deploy/xinference-cluster/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- include "kblib.rbac" . }}
12 changes: 12 additions & 0 deletions deploy/xinference-cluster/templates/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{/*
Validate cpu, memory and storage
*/}}
{{- $cpu := (float64 .Values.cpu) }}
{{- $memory := (float64 .Values.memory) }}
{{- $storage := (float64 .Values.storage) }}
{{- if or (lt $cpu 0.5) (gt $cpu 64.0) }}
{{- fail (print "cpu must be between 0.5 and 64, got " $cpu) }}
{{- end }}
{{- if or (lt $memory 0.5) (gt $memory 1000.0) }}
{{- fail (print "memory must be between 0.5 and 1000, got " $memory) }}
{{- end }}
61 changes: 61 additions & 0 deletions deploy/xinference-cluster/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"cpuMode": {
"title": "CPU Mode",
"description": "Set to true if no GPU is available",
"type": "boolean",
"default": false
},
"version": {
"title": "Version",
"description": "Cluster version.",
"type": "string",
"default": "xinference-latest"
},
"replicas": {
"title": "Replicas",
"description": "The number of replicas, for standalone mode, the replicas is 1, for replication mode, the default replicas is 2.",
"type": "integer",
"default": 1,
"minimum": 1,
"maximum": 5
},
"cpu": {
"title": "CPU",
"description": "CPU cores.",
"type": [
"number",
"string"
],
"default": 2,
"minimum": 0.5,
"maximum": 64,
"multipleOf": 0.5
},
"memory": {
"title": "Memory(Gi)",
"description": "Memory, the unit is Gi.",
"type": [
"number",
"string"
],
"default": 6,
"minimum": 0.5,
"maximum": 1000
},
"gpu": {
"title": "GPU",
"description": "GPU cores.",
"type": [
"number",
"string"
],
"default": 1,
"minimum": 0,
"maximum": 64,
"multipleOf": 1
}
}
}
27 changes: 27 additions & 0 deletions deploy/xinference-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Default values for xinference-cluster.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

## @param version xinference cluster version
##
version: xinference-latest

cpuVersion: xinference-cpu-latest

## @param replicas specify cluster replicas
##
replicas: 1

## @param cpu
##
cpu: 3

## @param memory, the unit is Gi
##
memory: 7

## @param gpu
##
gpu: 1

cpuMode: false
24 changes: 24 additions & 0 deletions deploy/xinference/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: xinference
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"
Empty file.
33 changes: 33 additions & 0 deletions deploy/xinference/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "xinference.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Selector labels
*/}}
{{- define "xinference.selectorLabels" -}}
app.kubernetes.io/name: {{ include "xinference.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
43 changes: 43 additions & 0 deletions deploy/xinference/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterDefinition
metadata:
name: xinference
labels:
{{- include "xinference.labels" . | nindent 4}}
spec:
componentDefs:
- name: xinference
workloadType: Stateful
characterType: xinference
scriptSpecs:
- name: xinference-scripts
templateRef: xinference-scripts
namespace: {{ .Release.Namespace }}
volumeName: scripts
defaultMode: 493
service:
ports:
- name: xinference
port: 9997
targetPort: xinference
podSpec:
containers:
- name: xinference
imagePullPolicy: {{default .Values.image.pullPolicy "IfNotPresent"}}
securityContext:
runAsUser: 0
privileged: true
allowPrivilegeEscalation: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- name: scripts
mountPath: /scripts
command:
- /scripts/start.sh
ports:
- name: xinference
containerPort: 9997
connectionCredential:
username: root
password: ""
Loading

0 comments on commit 41c3850

Please sign in to comment.