Skip to content

Commit

Permalink
feat: add client and seed client templates to charts (#215)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Jan 2, 2024
1 parent 2cc9294 commit 24603ea
Show file tree
Hide file tree
Showing 15 changed files with 1,693 additions and 672 deletions.
23 changes: 14 additions & 9 deletions charts/dragonfly/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: dragonfly
description: Dragonfly is an intelligent P2P based image and file distribution system
icon: https://raw.githubusercontent.com/dragonflyoss/Dragonfly2/main/docs/images/logo/dragonfly.svg
type: application
version: 1.1.11
appVersion: 2.1.22
version: 1.1.12
appVersion: 2.1.28
keywords:
- dragonfly
- d7y
Expand All @@ -26,8 +26,9 @@ sources:

annotations:
artifacthub.io/changes: |
- Update dragonfly image tag to v2.1.22.
- Add maxScheduleCount to scheduler.
- Add client template to dragonfly charts.
- Add seed client template to dragonfly charts.
- Update dragonfly image tag to v2.1.28.
artifacthub.io/links: |
- name: Chart Source
Expand All @@ -36,13 +37,17 @@ annotations:
url: https://github.com/dragonflyoss/Dragonfly2
artifacthub.io/images: |
- name: manager
image: dragonflyoss/manager:v2.1.22
- name: dfdaemon
image: dragonflyoss/dfdaemon:v2.1.22
image: dragonflyoss/manager:v2.1.28
- name: scheduler
image: dragonflyoss/scheduler:v2.1.22
image: dragonflyoss/scheduler:v2.1.28
- name: client
image: dragonflyoss/client:v0.1.4
- name: seed-client
image: dragonflyoss/client:v0.1.4
- name: dfdaemon
image: dragonflyoss/dfdaemon:v2.1.28
- name: trainer
image: dragonflyoss/scheduler:v2.1.22
image: dragonflyoss/scheduler:v2.1.28
- name: triton
image: nvcr.io/nvidia/tritonserver:23.06-py3
Expand Down
144 changes: 135 additions & 9 deletions charts/dragonfly/README.md

Large diffs are not rendered by default.

28 changes: 22 additions & 6 deletions charts/dragonfly/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified manager name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dragonfly.manager.fullname" -}}
{{ template "dragonfly.fullname" . }}-{{ .Values.manager.name }}
{{- end -}}

{{/*
Create a default fully qualified scheduler name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
Expand All @@ -32,19 +40,27 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- end -}}

{{/*
Create a default fully qualified seed peer name.
Create a default fully qualified client name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dragonfly.seedPeer.fullname" -}}
{{ template "dragonfly.fullname" . }}-{{ .Values.seedPeer.name }}
{{- define "dragonfly.client.fullname" -}}
{{ template "dragonfly.fullname" . }}-{{ .Values.client.name }}
{{- end -}}

{{/*
Create a default fully qualified manager name.
Create a default fully qualified seed client name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dragonfly.manager.fullname" -}}
{{ template "dragonfly.fullname" . }}-{{ .Values.manager.name }}
{{- define "dragonfly.seedClient.fullname" -}}
{{ template "dragonfly.fullname" . }}-{{ .Values.seedClient.name }}
{{- end -}}

{{/*
Create a default fully qualified seed peer name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dragonfly.seedPeer.fullname" -}}
{{ template "dragonfly.fullname" . }}-{{ .Values.seedPeer.name }}
{{- end -}}

{{/*
Expand Down
47 changes: 47 additions & 0 deletions charts/dragonfly/templates/client/client-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- if .Values.client.enable }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dragonfly.client.fullname" . }}
labels:
app: {{ template "dragonfly.fullname" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.client.name }}
data:
dfdaemon.yaml: |-
host:
{{ toYaml .Values.client.config.host | indent 6 }}
server:
{{ toYaml .Values.client.config.server | indent 6 }}
download:
{{ toYaml .Values.client.config.download | indent 6 }}
upload:
{{ toYaml .Values.client.config.upload | indent 6 }}
manager:
addrs:
{{- if .Values.client.config.scheduler.manager.addrs }}
{{ toYaml .Values.client.config.scheduler.manager.netAddrs | indent 6 }}
{{- else if .Values.manager.enable }}
- {{ template "dragonfly.manager.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ .Values.manager.grpcPort }}
{{- else }}
- {{ .Values.externalManager.host }}:{{ .Values.externalManager.grpcPort }}
{{- end }}
scheduler:
{{ toYaml .Values.client.config.scheduler | indent 6 }}
dynconfig:
{{ toYaml .Values.client.config.dynconfig | indent 6 }}
storage:
{{ toYaml .Values.client.config.storage | indent 6 }}
gc:
{{ toYaml .Values.client.config.gc | indent 6 }}
proxy:
{{ toYaml .Values.client.config.proxy | indent 6 }}
security:
{{ toYaml .Values.client.config.security | indent 6 }}
metrics:
{{ toYaml .Values.client.config.metrics | indent 6 }}
tracing:
{{ toYaml .Values.client.config.tracing | indent 6 }}
{{- end }}
145 changes: 145 additions & 0 deletions charts/dragonfly/templates/client/client-daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{{- if .Values.client.enable }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ template "dragonfly.client.fullname" . }}
labels:
app: {{ template "dragonfly.fullname" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.client.name }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/client/client-configmap.yaml") . | sha256sum }}
{{- if .Values.client.daemonsetAnnotations }}
{{ toYaml .Values.client.daemonsetAnnotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "dragonfly.fullname" . }}
component: "{{ .Values.client.name }}"
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "dragonfly.fullname" . }}
component: "{{ .Values.client.name }}"
release: {{ .Release.Name }}
{{- if .Values.client.podLabels }}
{{ toYaml .Values.client.podLabels | indent 8 }}
{{- end }}
{{- if .Values.client.podAnnotations }}
annotations:
{{ toYaml .Values.client.podAnnotations | indent 8 }}
{{- end }}
spec:
{{- if .Values.client.nodeSelector }}
nodeSelector:
{{ toYaml .Values.client.nodeSelector | indent 8 }}
{{- end }}
hostNetwork: {{ .Values.client.hostNetwork }}
{{- if .Values.client.hostNetwork }}
dnsPolicy: "ClusterFirstWithHostNet"
{{- end }}
hostPID: {{ .Values.client.hostPID }}
{{- if .Values.client.tolerations }}
tolerations:
{{ toYaml .Values.client.tolerations | indent 8 }}
{{- end }}
{{- if .Values.client.affinity }}
affinity:
{{ toYaml .Values.client.affinity | indent 8 }}
{{- end }}
{{- if quote .Values.client.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.client.terminationGracePeriodSeconds }}
{{- end }}
{{- if and (.Capabilities.APIVersions.Has "scheduling.k8s.io/v1beta1") (.Values.client.priorityClassName) }}
priorityClassName: {{ .Values.client.priorityClassName }}
{{- end }}
{{- with .Values.client.pullSecrets | default .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.client.hostAliases }}
hostAliases:
{{ toYaml .Values.client.hostAliases | indent 8 }}
{{- end }}
initContainers:
{{- if .Values.scheduler.enable }}
- name: wait-for-scheduler
image: {{ .Values.client.initContainer.image }}:{{ .Values.client.initContainer.tag }}
imagePullPolicy: {{ .Values.client.initContainer.pullPolicy }}
command: ['sh', '-c', 'until nslookup {{ template "dragonfly.scheduler.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }} && nc -vz {{ template "dragonfly.scheduler.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }} {{ .Values.scheduler.config.server.port }}; do echo waiting for scheduler; sleep 2; done;']
{{- end }}
containers:
- name: client
image: {{ .Values.client.image }}:{{ .Values.client.tag }}
imagePullPolicy: {{ .Values.client.pullPolicy | quote }}
resources:
{{ toYaml .Values.client.resources | indent 12 }}
env:
{{- if .Values.client.maxProcs }}
- name: GOMAXPROCS
value: {{ .Values.client.maxProcs }}
{{- end }}
ports:
- containerPort: {{ .Values.client.config.upload.server.port }}
protocol: TCP
{{- if .Values.client.metrics.enable }}
- containerPort: {{ .Values.client.config.metrics.port }}
protocol: TCP
{{- end }}
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:{{ .Values.client.config.upload.server.port }}"]
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:{{ .Values.client.config.upload.server.port }}"]
initialDelaySeconds: 15
periodSeconds: 10
volumeMounts:
- name: config
mountPath: "/etc/dragonfly"
- name: storage
mountPath: {{ .Values.client.config.storage.dir }}
{{- if .Values.client.extraVolumeMounts }}
{{- toYaml .Values.client.extraVolumeMounts | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ template "dragonfly.client.fullname" . }}
{{- if not (.Values.client.persistence.enable) }}
- name: storage
emptyDir: {}
{{- end }}
{{- if .Values.client.extraVolumes }}
{{- toYaml .Values.client.extraVolumes | nindent 6 }}
{{- end }}
{{- if .Values.client.persistence.enable }}
volumeClaimTemplates:
- metadata:
name: storage
{{- range $key, $value := .Values.client.persistence.annotations }}
{{ $key }}: {{ $value }}
{{- end }}
spec:
accessModes:
{{- range .Values.client.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.client.persistence.size | quote }}
{{- if .Values.client.persistence.storageClass }}
{{- if (eq "-" .Values.client.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.client.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
{{- end }}
33 changes: 33 additions & 0 deletions charts/dragonfly/templates/client/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if and .Values.client.metrics.enable .Values.client.metrics.podMonitor.enable }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ template "dragonfly.client.fullname" . }}
labels:
app: {{ template "dragonfly.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.client.name }}
{{- if .Values.client.metrics.podMonitor.additionalLabels }}
{{ toYaml .Values.client.metrics.podMonitor.additionalLabels | indent 4 }}
{{- end }}
spec:
podMetricsEndpoints:
- port: {{ .Values.client.config.metrics.port }}
path: /metrics
{{- if .Values.client.metrics.podMonitor.interval }}
interval: {{ .Values.client.metrics.podMonitor.interval }}
{{- end }}
{{- if .Values.client.metrics.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.client.metrics.podMonitor.scrapeTimeout }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "dragonfly.name" . }}
release: {{ .Release.Name }}
component: {{ .Values.client.name }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/dragonfly/templates/client/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if and .Values.client.metrics.enable .Values.client.metrics.prometheusRule.enable }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "dragonfly.client.fullname" . }}
labels:
app: {{ template "dragonfly.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.client.name }}
{{- if .Values.client.metrics.prometheusRule.additionalLabels }}
{{ toYaml .Values.client.metrics.prometheusRule.additionalLabels | indent 4 }}
{{- end }}
spec:
groups:
- name: {{ template "dragonfly.client.fullname" $ }}
rules:
{{ toYaml .Values.client.metrics.prometheusRule.rules | indent 8 }}
{{- end }}
30 changes: 0 additions & 30 deletions charts/dragonfly/templates/dfdaemon/metrics-svc.yaml

This file was deleted.

Loading

0 comments on commit 24603ea

Please sign in to comment.