Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
/build/
/test/.config
/charts/harbor-operator/chart-harbor-operator
*pycache*
*pycache*
charts/metax-exporter/data
charts/metax-gpu-extensions/data
charts/metax-operator/data
17 changes: 17 additions & 0 deletions charts/metax-exporter/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export USE_OPENSOURCE_CHART=false
export BUILD_SELF=custom.sh
export MX_VERSION=0.9.0
export MX_HELM_VERSION=0.5.0

# pr, issue, none
export UPGRADE_METHOD=pr
export UPGRADE_REVIWER=lengrongfu
export TEST_ASSIGNER=lengrongfu

# push to daocloud repo
export DAOCLOUD_REPO_PROJECT=addon

# optional, for wrapper chart
# gpu-operator version
export CUSTOM_VERSION=${VERSION}+1

42 changes: 42 additions & 0 deletions charts/metax-exporter/custom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

if [ -z "${LOCAL+x}" ]; then
echo "LOCAL is not defined, skipping..."
exit 0
fi

bash ./script/upload.sh ./data/mx-exporter.${MX_VERSION}.tgz release.daocloud.io dc-image
echo "Upload image complete"

CHART_DIR=./mx-exporter/deployment/mx-exporter/helm/mx-exporter

rm -rf metax-exporter/
cp -rf ./mx-exporter/deployment/mx-exporter/helm/mx-exporter metax-exporter
rm -rf mx-exporter

yq -i '
.name = "metax-exporter"
' metax-exporter/Chart.yaml

yq -i "
.image.registry=\"release.daocloud.io\" |
.image.repository = \"metax/mx-exporter\" |
.image.tag= \"${MX_VERSION}\"
" metax-exporter/values.yaml

os=$(uname)
echo $os
if [ $os == "Darwin" ];then
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
elif [ $os == "Linux" ]; then
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
fi


helm schema-gen metax-exporter/values.yaml > metax-exporter/values.schema.json
cp -rf parent/ metax-exporter/


bash ./script/upload.sh ./data/mx-exporter.${MX_VERSION}.tgz release.daocloud.io helm-push
rm -rf metax-exporter-${MX_HELM_VERSION}.tgz
echo "Push helm chart complete"
61 changes: 61 additions & 0 deletions charts/metax-exporter/example/README-custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This project is offline gpu-operator helm chart

## How To Test

1. make build_chart
```shell
$ cd github.com/daocloud/dce-charts-repackage
$ make build_chart -e PROJECT=gpu-operator
```

2. package helm chart
```shell
$ cd github.com/daocloud/dce-charts-repackage/charts/gpu-operator
$ helm package gpu-operator
```

3. upload to harbor
```shell
$ helm repo add harbor-test-helm-repo --username=xxx --password=xxx http://harbor-test.demo.com.cn:8086/chartrepo/helm-repo
$ helm push gpu-operator-v23.6.1.tgz harbor-test-helm-repo
```

4. download charts-syncer
```shell
https://github.com/DaoCloud/charts-syncer
```

5. sync to local
```shell
$ vim config-save-bundles.yaml
# sync to local
$ charts-syncer sync --config config-save-bundles.yaml --v 5
```

6. sync offline addon to harbor
```shell
$ vim config-write-bundles.yaml
source:
intermediateBundlesPath: addon # chart tar 包所在的目录,需把 relok8s 生成的 tar 包放到此目录下
target:
containerRegistry: 10.6.232.5:30727 # 目标镜像仓库地址
containerRepository: kangaroo # laod 镜像时 project 如果不需要修改可不填写
repo:
kind: HARBOR # or as any other supported Helm Chart repository kinds
url: http://10.6.232.5:30727/chartrepo/kangaroo #load charts 的目标地址,改为需要的地址即可
auth: ## charts仓库用户名密码
username: admin
password: Harbor12345
containers:
auth:
username: admin
password: Harbor12345

$ charts-syncer sync --config config-write-bundles.yaml --insecure=true
```

6. schema-gen
```
$ helm schema-gen values-schema.yaml > values.schema.json
```

19 changes: 19 additions & 0 deletions charts/metax-exporter/example/config-save-bundles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source:
repo:
kind: HARBOR # or as any other supported Helm Chart repository kinds
url: https://release.daocloud.io/chartrepo/addon
auth: ## charts仓库用户名密码
username: admin
password: x3OFzuW0tpGYFDAr63wRx81dqms=
containers:
# url: https://release.daocloud.io
auth:
registry: release.daocloud.io
username: "admin"
password: ""
target:
# The important bit. This instructs charts-syncer to store intermediate bundles in the given directory
intermediateBundlesPath: addon

charts:
- name: metax-exporter
23 changes: 23 additions & 0 deletions charts/metax-exporter/metax-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- "{{ .image.registry }}/{{ .image.repository }}:{{ .image.tag }}"
26 changes: 26 additions & 0 deletions charts/metax-exporter/metax-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v2
name: metax-exporter
description: A Helm chart for MetaX GPU metrics exporter
# 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.5.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: "2.1.10"
keywords:
- gpu
- compute
- monitoring
- telemetry
22 changes: 22 additions & 0 deletions charts/metax-exporter/metax-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mx-exporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mx-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mx-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
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}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions charts/metax-exporter/metax-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "mx-exporter.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 "mx-exporter.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 "mx-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "mx-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "mx-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
94 changes: 94 additions & 0 deletions charts/metax-exporter/metax-exporter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "mx-exporter.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "mx-exporter.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "mx-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "mx-exporter.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "mx-exporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-c=/etc/config/metrics"
- "-p={{.Values.service.port}}"
- "-i={{.Values.gatherInterval}}"
- "-lm={{.Values.logMonitor}}"
env:
- name: "NODE_NAME"
valueFrom:
fieldRef:
fieldPath: spec.nodeName
ports:
- name: "metrics"
containerPort: {{ .Values.service.port }}
protocol: TCP
volumeMounts:
- name: "pod-gpu-resources"
readOnly: true
mountPath: "/var/lib/kubelet/pod-resources"
- name: "all-devices"
mountPath: "/dev/dri"
- name: "config-vol"
mountPath: "/etc/config"
{{- if .Values.logMonitor }}
- name: "var-log"
readOnly: true
mountPath: "/var/log"
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: "pod-gpu-resources"
hostPath:
path: {{ .Values.kubeletPath }}
- name: "var-log"
hostPath:
path: "/var/log"
- name: "all-devices"
hostPath:
path: {{ .Values.devicePath }}
- name: "config-vol"
configMap:
name: "exporter-metrics-config-map"
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Loading
Loading