Skip to content

Commit 286d77c

Browse files
committed
add metax addon
Signed-off-by: rongfu.leng <lenronfu@gmail.com>
1 parent bf4a1c2 commit 286d77c

File tree

81 files changed

+4451
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4451
-1
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
/build/
44
/test/.config
55
/charts/harbor-operator/chart-harbor-operator
6-
*pycache*
6+
*pycache*
7+
charts/metax-exporter/data
8+
charts/metax-gpu-extensions/data
9+
charts/metax-operator/data

charts/metax-exporter/config

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export USE_OPENSOURCE_CHART=false
2+
export BUILD_SELF=custom.sh
3+
export MX_VERSION=0.9.0
4+
export MX_HELM_VERSION=0.5.0
5+
6+
# pr, issue, none
7+
export UPGRADE_METHOD=pr
8+
export UPGRADE_REVIWER=lengrongfu
9+
export TEST_ASSIGNER=lengrongfu
10+
11+
# push to daocloud repo
12+
export DAOCLOUD_REPO_PROJECT=addon
13+
14+
# optional, for wrapper chart
15+
# gpu-operator version
16+
export CUSTOM_VERSION=${VERSION}+1
17+

charts/metax-exporter/custom.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -z "${LOCAL+x}" ]; then
4+
echo "LOCAL is not defined, skipping..."
5+
exit 0
6+
fi
7+
8+
bash ./script/upload.sh ./data/mx-exporter.${MX_VERSION}.tgz release.daocloud.io dc-image
9+
echo "Upload image complete"
10+
11+
CHART_DIR=./mx-exporter/deployment/mx-exporter/helm/mx-exporter
12+
13+
rm -rf metax-exporter/
14+
cp -rf ./mx-exporter/deployment/mx-exporter/helm/mx-exporter metax-exporter
15+
rm -rf mx-exporter
16+
17+
yq -i '
18+
.name = "metax-exporter"
19+
' metax-exporter/Chart.yaml
20+
21+
yq -i "
22+
.image.registry=\"release.daocloud.io\" |
23+
.image.repository = \"metax/mx-exporter\" |
24+
.image.tag= \"${MX_VERSION}\"
25+
" metax-exporter/values.yaml
26+
27+
os=$(uname)
28+
echo $os
29+
if [ $os == "Darwin" ];then
30+
sed -i "" "s/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}/{{ .Values.image.registry }}\/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}/g" ./metax-exporter/templates/daemonset.yaml
31+
elif [ $os == "Linux" ]; then
32+
sed -i "s/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}/{{ .Values.image.registry }}\/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}/g" ./metax-exporter/templates/daemonset.yaml
33+
fi
34+
35+
36+
helm schema-gen metax-exporter/values.yaml > metax-exporter/values.schema.json
37+
cp -rf parent/ metax-exporter/
38+
39+
40+
bash ./script/upload.sh ./data/mx-exporter.${MX_VERSION}.tgz release.daocloud.io helm-push
41+
rm -rf metax-exporter-${MX_HELM_VERSION}.tgz
42+
echo "Push helm chart complete"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This project is offline gpu-operator helm chart
2+
3+
## How To Test
4+
5+
1. make build_chart
6+
```shell
7+
$ cd github.com/daocloud/dce-charts-repackage
8+
$ make build_chart -e PROJECT=gpu-operator
9+
```
10+
11+
2. package helm chart
12+
```shell
13+
$ cd github.com/daocloud/dce-charts-repackage/charts/gpu-operator
14+
$ helm package gpu-operator
15+
```
16+
17+
3. upload to harbor
18+
```shell
19+
$ helm repo add harbor-test-helm-repo --username=xxx --password=xxx http://harbor-test.demo.com.cn:8086/chartrepo/helm-repo
20+
$ helm push gpu-operator-v23.6.1.tgz harbor-test-helm-repo
21+
```
22+
23+
4. download charts-syncer
24+
```shell
25+
https://github.com/DaoCloud/charts-syncer
26+
```
27+
28+
5. sync to local
29+
```shell
30+
$ vim config-save-bundles.yaml
31+
# sync to local
32+
$ charts-syncer sync --config config-save-bundles.yaml --v 5
33+
```
34+
35+
6. sync offline addon to harbor
36+
```shell
37+
$ vim config-write-bundles.yaml
38+
source:
39+
intermediateBundlesPath: addon # chart tar 包所在的目录,需把 relok8s 生成的 tar 包放到此目录下
40+
target:
41+
containerRegistry: 10.6.232.5:30727 # 目标镜像仓库地址
42+
containerRepository: kangaroo # laod 镜像时 project 如果不需要修改可不填写
43+
repo:
44+
kind: HARBOR # or as any other supported Helm Chart repository kinds
45+
url: http://10.6.232.5:30727/chartrepo/kangaroo #load charts 的目标地址,改为需要的地址即可
46+
auth: ## charts仓库用户名密码
47+
username: admin
48+
password: Harbor12345
49+
containers:
50+
auth:
51+
username: admin
52+
password: Harbor12345
53+
54+
$ charts-syncer sync --config config-write-bundles.yaml --insecure=true
55+
```
56+
57+
6. schema-gen
58+
```
59+
$ helm schema-gen values-schema.yaml > values.schema.json
60+
```
61+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
source:
2+
repo:
3+
kind: HARBOR # or as any other supported Helm Chart repository kinds
4+
url: https://release.daocloud.io/chartrepo/addon
5+
auth: ## charts仓库用户名密码
6+
username: admin
7+
password: x3OFzuW0tpGYFDAr63wRx81dqms=
8+
containers:
9+
# url: https://release.daocloud.io
10+
auth:
11+
registry: release.daocloud.io
12+
username: "admin"
13+
password: ""
14+
target:
15+
# The important bit. This instructs charts-syncer to store intermediate bundles in the given directory
16+
intermediateBundlesPath: addon
17+
18+
charts:
19+
- name: metax-exporter
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- "{{ .image.registry }}/{{ .image.repository }}:{{ .image.tag }}"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: v2
2+
name: metax-exporter
3+
description: A Helm chart for MetaX GPU metrics exporter
4+
# A chart can be either an 'application' or a 'library' chart.
5+
#
6+
# Application charts are a collection of templates that can be packaged into versioned archives
7+
# to be deployed.
8+
#
9+
# Library charts provide useful utilities or functions for the chart developer. They're included as
10+
# a dependency of application charts to inject those utilities and functions into the rendering
11+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
12+
type: application
13+
# This is the chart version. This version number should be incremented each time you make changes
14+
# to the chart and its templates, including the app version.
15+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16+
version: 0.4.3
17+
# This is the version number of the application being deployed. This version number should be
18+
# incremented each time you make changes to the application. Versions are not expected to
19+
# follow Semantic Versioning. They should reflect the version the application is using.
20+
# It is recommended to use it with quotes.
21+
appVersion: "2.1.7"
22+
keywords:
23+
- gpu
24+
- compute
25+
- monitoring
26+
- telemetry
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mx-exporter.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mx-exporter.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mx-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mx-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "mx-exporter.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "mx-exporter.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "mx-exporter.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "mx-exporter.labels" -}}
37+
helm.sh/chart: {{ include "mx-exporter.chart" . }}
38+
{{ include "mx-exporter.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "mx-exporter.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "mx-exporter.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "mx-exporter.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "mx-exporter.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

0 commit comments

Comments
 (0)