Skip to content

huggingface/helm-common

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hugging Face Common Helm Chart

Version License Tests

Helm Chart containing Hugging Face common functions

Usage

How to install

Add this chart to your chart dependencies.

apiVersion: v2
name: my-chart
description: Your Helm chart description
icon: https://huggingface.co/front/assets/huggingface_logo-noborder.svg
type: application
version: 1.0.0
appVersion: "latest"

dependencies:
  - name: common
    version: x.x.x
    repository: https://HUGGINGFACE_PRIVATE_REGISTRY/chartrepo/charts

or if your project is open-source :

apiVersion: v2
name: my-chart
description: Your Helm chart description
icon: https://huggingface.co/front/assets/huggingface_logo-noborder.svg
type: application
version: 1.0.0
appVersion: "latest"
dependencies:
    - name: common
      version: x.x.x
      repository: oci://ghcr.io/huggingface/helm-common

Docker images management

Use a public docker image

To use a public docker image (on docker hub).

values.yaml

global:
  huggingface:
    imageRegistry: ""
    imagePullSecrets: []

images:
  pullPolicy: IfNotPresent
  nginx:
    useGlobalRegistry: false
    repository: nginx
    tag: "1.22"

_helpers.yaml

{{- define "nginx.image" -}}
{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.nginx "global" .Values.global.huggingface) | quote }}
{{- end -}}

deployment.yaml

...
containers:
- name: ...
  image: {{ include "nginx.image" . }}
...

The common function will generate : image: "nginx:1.22"

Use a public docker image on specific repository (docker hub)

To use a public docker image (on docker hub).

values.yaml

global:
  huggingface:
    imageRegistry: ""
    imagePullSecrets: []

images:
  pullPolicy: IfNotPresent
  admin:
    registry: huggingface
    useGlobalRegistry: false
    repository: datasets-server
    tag: sha-27ad2f7

_helpers.yaml

{{- define "admin.image" -}}
{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.admin "global" .Values.global.huggingface) | quote }}
{{- end -}}

deployment.yaml

...
containers:
- name: ...
  image: {{ include "admin.image" . }}
...

The common function will generate : image: "huggingface/datasets-server:sha-27ad2f7"

Use a docker image from private registry (with global registry)

To use a docker image from a global private registry. A global registry is usefull to avoid duplicate your registry for all your images.

values.yaml

global:
  huggingface:
    imageRegistry: "my-registry.com"
    imagePullSecrets: []

images:
  pullPolicy: IfNotPresent
  app:
    repository: project/app
    tag: 1.0.0

_helpers.yaml

{{- define "app.image" -}}
{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.app "global" .Values.global.huggingface) | quote }}
{{- end -}}

deployment.yaml

...
containers:
- name: ...
  image: {{ include "app.image" . }}
...

The common function will generate : image: "my-registry.com/project/app:1.0.0"

Use a docker image from private registry (without global registry)

To use a docker image for a specific private private registry (not global).

values.yaml

global:
  huggingface:
    imageRegistry: "my-registry.com"
    imagePullSecrets: []

images:
  pullPolicy: IfNotPresent
  app:
    registry: my-other-registry.com
    repository: project/app
    tag: 1.0.0

_helpers.yaml

{{- define "app.image" -}}
{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.app "global" .Values.global.huggingface) | quote }}
{{- end -}}

deployment.yaml

...
containers:
- name: ...
  image: {{ include "app.image" . }}
...

The common function will generate : image: "my-other-registry.com/project/app:1.0.0"

Pull Secret management

If your registry is private, you will need an imagePullSecret to allow your cluster to pull the docker image. You can set it globally to avoid duplicate.

values.yaml

global:
  huggingface:
    imageRegistry: "my-registry.com"
    imagePullSecrets: [myregcred]

images:
  pullPolicy: IfNotPresent
  app:
    repository: project/app
    tag: 1.0.0

_helpers.yaml

{{- define "app.image" -}}
{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.app "global" .Values.global.huggingface) | quote }}
{{- end -}}

{{- define "app.imagePullSecrets" -}}
{{- include "hf.common.images.renderPullSecrets" (dict "images" (list .Values.images) "context" $) -}}
{{- end -}}

deployment.yaml

...
spec:
  {{- include "app.imagePullSecrets" . | nindent 6 }}
  containers:
    - name: app
      image: {{ include "app.image" . }}
      imagePullPolicy: {{ .Values.images.pullPolicy }}
...

The common function will generate :

...
spec:
  imagePullSecrets:
    - name: regcred
  containers:
    - name: proxy
      image: "my-registry.com/project/app:1.0.0"
      imagePullPolicy: IfNotPresent
...

Labels management

Use the common function to generate your resource labels.

_helpers.yaml

{{- define "yourComp.selectorLabels" -}}
{{ include "hf.labels.commons" . }}
app.kubernetes.io/component: your-component-name
{{- end }}

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels: {{- include "yourComp.selectorLabels" . | nindent 4 }}

Credits

This charts is inspired from Bitnami common functions.

License

Copyright © 2023 HuggingFace

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.