Skip to content

Commit

Permalink
feat(acceleration): add initial chart (#51)
Browse files Browse the repository at this point in the history
Harbor Acceleration Chart
  • Loading branch information
oliverbaehler authored Jan 21, 2024
1 parent afe9e8e commit 5033eea
Show file tree
Hide file tree
Showing 17 changed files with 786 additions and 49 deletions.
1 change: 1 addition & 0 deletions .github/configs/ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ validate-maintainers: true
validate-yaml: false
excluded-charts:
- "library"
- "manifests"
23 changes: 23 additions & 0 deletions charts/acceleration/.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/
24 changes: 24 additions & 0 deletions charts/acceleration/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: acceleration
description: Harbor Acceleration Service
type: application
version: 0.1.0
keywords:
- docker
- registry
- harbor
home: https://github.com/goharbor/acceleration-service
icon: https://raw.githubusercontent.com/goharbor/website/main/static/img/logos/harbor-icon-color.png
sources:
- https://goharbor.io
- https://github.com/goharbor/harbor
appVersion: "0.2.13"
maintainers:
- name: oliverbaehler
email: [email protected]
- name: chifu1234
email: [email protected]
dependencies:
- name: library
version: "3.0.0-rc.3"
repository: https://buttahtoast.github.io/helm-charts/
97 changes: 97 additions & 0 deletions charts/acceleration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# acceleration

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.13](https://img.shields.io/badge/AppVersion-0.2.13-informational?style=flat-square)

Harbor Acceleration Service

**Homepage:** <https://github.com/goharbor/acceleration-service>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| oliverbaehler | <[email protected]> | |
| chifu1234 | <[email protected]> | |

## Source Code

* <https://goharbor.io>
* <https://github.com/goharbor/harbor>

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| https://buttahtoast.github.io/helm-charts/ | library | 3.0.0-rc.3 |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| config.converter | object | `{"driver":{"config":{"with_referrer":true},"type":"nydus"},"harbor_annotation":true,"platforms":"","rules":{"additional":[],"overwrite":[]},"worker":5}` | Converter Configuration |
| config.converter.driver.config | object | `{"with_referrer":true}` | driver configuration |
| config.converter.driver.type | string | `"nydus"` | select which driver to use, `nydus` or `estargz` |
| config.converter.harbor_annotation | bool | `true` | enable to add harbor specified annotations to converted image for tracking. |
| config.converter.platforms | string | `""` | only convert images for specific platforms, leave empty for all platforms (eg. `linux/amd64,linux/arm64`) |
| config.converter.rules | object | `{"additional":[],"overwrite":[]}` | Additional rules |
| config.converter.rules.additional | list | `[]` | Additional rules (appened to driver preset rules) |
| config.converter.rules.overwrite | list | `[]` | Overwrite rules (overwrite driver preset rules) |
| config.converter.worker | int | `5` | number of worker for executing conversion task |
| config.customConfiguration | object | `{}` | Custom Configuration (instead of using template). Can be map or multiline string, templating is supported. |
| config.harbor.auth | string | `""` | Authentication Token |
| config.harbor.host | string | `"harbor.company.com"` | |
| config.harbor.insecure | bool | `false` | skip verifying server certs for HTTPS source registry |
| config.template | string | `"# Configuration file of Harbor Acceleration Service\n\n# http related config\nserver:\n name: API\n # listened host for http\n host: 0.0.0.0\n # port for http\n port: 2077\n\nmetric:\n # export metrics on `/metrics` endpoint\n enabled: true\n\nprovider:\n source:\n # hostname of harbor service\n {{ $.Values.config.harbor.host }}:\n # base64 encoded `<robot-name>:<robot-secret>` for robot\n # account created in harbor\n # auth: YTpiCg==\n # skip verifying server certs for HTTPS source registry\n insecure: {{ $.Values.config.harbor.insecure }}\n webhook:\n # webhook request auth header configured in harbor\n auth_header: header\n localhost:\n # If auth is not provided, it will attempt to read from docker config\n # auth: YWRtaW46SGFyYm9yMTIzNDU=\n # work directory of acceld\n work_dir: {{ $.Values.config.workDir.path }}\n gcpolicy:\n # size threshold that triggers GC, the oldest used blobs will be reclaimed if exceeds the size.\n threshold: 1000MB\n # remote cache record capacity of converted layers, default is 200.\n cache_size: 200\n # remote cache version, cache in remote must match the specified version, or discard cache.\n cache_version: v1 \n\nconverter:\n worker: {{ $.Values.config.converter.worker }}\n harbor_annotation: {{ $.Values.config.converter.harbor_annotation }}\n platforms: {{ $.Values.config.converter.platforms }}\n rules:\n {{- if $.Values.config.converter.overwrite }}\n {{- toYaml $.Values.config.converter.overwrite | nindent 8 }}\n {{- else }}\n {{- if (include \"acceleration.driver.is.nydus\" $) }}\n # add suffix to tag of source image reference as target image reference\n - tag_suffix: -nydus\n # set tag of source image reference as remote cache reference, leave empty to disable remote cache.\n - cache_tag: nydus-cache\n {{- end }}\n {{- if (include \"acceleration.driver.is.estargz\" $) }}\n - tag_suffix: -esgz\n {{- end }}\n {{- with $.Values.config.converter.rules.additional }}\n {{- toYaml . | nindent 8 }}\n {{- end }}\n {{- end }}\n\n driver:\n # accelerator driver type: `nydus`\n {{- if (include \"acceleration.driver.is.nydus\" $) }}\n type: nydus\n {{- end }}\n {{- if (include \"acceleration.driver.is.estargz\" $) }}\n type: estargz\n {{- end }}\n config:\n work_dir: {{ $.Values.config.workDir.path }}\n {{- if (include \"acceleration.driver.is.estargz\" $) }}\n docker2oci: true\n {{- end }}\n {{- if (include \"acceleration.driver.is.nydus\" $) }}\n with_referrer: true\n {{- end }}\n {{- with $.Values.config.converter.driver.config }}\n {{- toYaml . | nindent 6 }}\n {{- end }}\n"` | Configuration Template |
| config.workDir | object | `{"emptyDir":{"enabled":true,"medium":"","sizeLimit":""},"path":"/tmp"}` | Working Directory (EmptyDir) |
| config.workDir.emptyDir.enabled | bool | `true` | Enable EmptyDir for working directory |
| config.workDir.emptyDir.medium | string | `""` | EmptyDir medium |
| config.workDir.emptyDir.sizeLimit | string | `""` | EmptyDir size limit |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"goharbor/harbor-acceld"` | |
| image.tag | string | `""` | |
| imagePullSecrets | list | `[]` | |
| ingress.annotations | object | `{}` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts[0].host | string | `"chart-example.local"` | |
| ingress.hosts[0].paths[0].path | string | `"/"` | |
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.ingressClassName | string | `""` | |
| ingress.tls | list | `[]` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| service.annotations | object | `{}` | |
| service.clusterIP | string | `""` | |
| service.labels | object | `{}` | |
| service.loadBalancerIP | string | `""` | |
| service.loadBalancerSourceRanges | list | `[]` | |
| service.port | int | `80` | |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| serviceMonitor.annotations | object | `{}` | Assign additional Annotations |
| serviceMonitor.enabled | bool | `false` | Enable ServiceMonitor |
| serviceMonitor.endpoint.interval | string | `"15s"` | Set the scrape interval for the endpoint of the serviceMonitor |
| serviceMonitor.endpoint.metricRelabelings | list | `[]` | Set metricRelabelings for the endpoint of the serviceMonitor |
| serviceMonitor.endpoint.relabelings | list | `[]` | Set relabelings for the endpoint of the serviceMonitor |
| serviceMonitor.endpoint.scrapeTimeout | string | `""` | Set the scrape timeout for the endpoint of the serviceMonitor |
| serviceMonitor.jobLabel | string | `"app.kubernetes.io/name"` | Set JobLabel for the serviceMonitor |
| serviceMonitor.labels | object | `{}` | Assign additional labels according to Prometheus' serviceMonitorSelector matching labels |
| serviceMonitor.matchLabels | object | `{}` | Change matching labels |
| serviceMonitor.namespace | string | `""` | Install the ServiceMonitor into a different Namespace, as the monitoring stack one (default: the release one) |
| serviceMonitor.targetLabels | list | `[]` | Set targetLabels for the serviceMonitor |
| tolerations | list | `[]` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
101 changes: 101 additions & 0 deletions charts/acceleration/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "acceleration.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 "acceleration.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 "acceleration.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "acceleration.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "acceleration.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Used Driver
*/}}
{{- define "acceleration.driver" -}}
{{- $driver := $.Values.config.converter.driver.type -}}
{{- if or (eq $driver "estargz") (eq $driver "nydus") -}}
{{- printf "%s" $driver -}}
{{- else -}}
{{- fail "invalid driver" -}}
{{- end -}}
{{- end }}


{{/*
Driver Check
*/}}
{{- define "acceleration.driver.is" -}}
{{- $driver := $.ctx.Values.config.converter.driver.type -}}
{{- if eq $.driver $driver -}}
{{- true -}}
{{- end -}}
{{- end }}

{{- define "acceleration.driver.is.nydus" -}}
{{- $driver := "nydus" -}}
{{- if (include "acceleration.driver.is" (dict "driver" $driver "ctx" $)) -}}
{{- true -}}
{{- end -}}
{{- end }}

{{- define "acceleration.driver.is.estargz" -}}
{{- $driver := "estargz" -}}
{{- if (include "acceleration.driver.is" (dict "driver" $driver "ctx" $)) -}}
{{- true -}}
{{- end -}}
{{- end }}


84 changes: 84 additions & 0 deletions charts/acceleration/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "acceleration.fullname" . }}
labels:
{{- include "acceleration.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "acceleration.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "acceleration.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "acceleration.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- /etc/acceleration/acceleration.yaml
ports:
- name: http
containerPort: 2077
protocol: TCP
livenessProbe:
httpGet:
path: /metrics
port: http
readinessProbe:
httpGet:
path: /metrics
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/acceleration/acceleration.yaml
subPath: config.yaml
readOnly: true
{{- if $.Values.config.workDir.emptyDir.enabled }}
- name: work-dir
mountPath: {{ $.Values.config.workDir.path | quote }}
{{- 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 }}
volumes:
{{- if $.Values.config.workDir.emptyDir.enabled }}
- name: work-dir
emptyDir:
sizeLimit: 500Mi
{{- end }}
- name: config
secret:
secretName: {{ include "acceleration.fullname" . }}
items:
- key: config.yaml
path: config.yaml
28 changes: 28 additions & 0 deletions charts/acceleration/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "acceleration.fullname" . }}
labels:
{{- include "acceleration.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "acceleration.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/acceleration/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "acceleration.fullname" . }}
labels:
{{- include "acceleration.labels" . | nindent 4 }}
{{- with $.Values.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
stringData:
config.yaml: |-
{{- $config := default $.Values.config.template $.Values.config.customConfiguration -}}
{{- $raw := (include "lib.utils.strings.template" (dict "value" $config "context" $)) }}
{{- $tpl := (fromYaml ($raw)) }}
{{- if not (include "lib.utils.errors.unmarshalingError" $tpl) }}
{{- toYaml $tpl | nindent 4 }}
{{- else -}}
{{- fail (printf "Found YAML error in config: %s: %s" ($tpl).Error $raw) -}}
{{- end -}}
Loading

0 comments on commit 5033eea

Please sign in to comment.