From b189e5985e1f1edcb854848064315264517649c0 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Wed, 8 Mar 2023 16:17:42 -0600 Subject: [PATCH] :sparkles: (obico): Create Obico chart --- README.md | 1 + charts/obico/.helmignore | 25 ++++ charts/obico/Chart.lock | 9 ++ charts/obico/Chart.yaml | 29 +++++ charts/obico/README.md | 113 ++++++++++++++++ charts/obico/README_CONFIG.md.gotmpl | 9 ++ charts/obico/templates/NOTES.txt | 4 + charts/obico/templates/ml-api.yaml | 12 ++ charts/obico/templates/server.yaml | 85 ++++++++++++ charts/obico/values.yaml | 186 +++++++++++++++++++++++++++ 10 files changed, 473 insertions(+) create mode 100644 charts/obico/.helmignore create mode 100644 charts/obico/Chart.lock create mode 100644 charts/obico/Chart.yaml create mode 100644 charts/obico/README.md create mode 100644 charts/obico/README_CONFIG.md.gotmpl create mode 100644 charts/obico/templates/NOTES.txt create mode 100644 charts/obico/templates/ml-api.yaml create mode 100644 charts/obico/templates/server.yaml create mode 100644 charts/obico/values.yaml diff --git a/README.md b/README.md index 2d1286f2c..3370c9ba7 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ helm delete my- | [mnemonic-ninja](charts/mnemonic-ninja/) | Mnemonic Ninja is a website to convert between a number and its corresponding word to aid in memorization. | | [monica](charts/monica/) | Personal CRM. Remember everything about your friends, family and business relationships. | | [nightscout](charts/nightscout/) | Web-based CGM (Continuous Glucose Monitor) to allow multiple caregivers to remotely view a patient's glucose data in real time. | +| [obico](charts/obico/) | Obico is a community-built, open-source smart 3D printing platform used by makers, enthusiasts, and tinkerers around the world. | | [pictshare](charts/pictshare/) | PictShare is an open source image, mp4, pastebin hosting service with a simple resizing and upload API that you can host yourself. | | [podgrab](charts/podgrab/) | A self-hosted podcast manager to download episodes as soon as they become live. | | [portfolio](charts/portfolio/) | My personal portfolio website | diff --git a/charts/obico/.helmignore b/charts/obico/.helmignore new file mode 100644 index 000000000..f56cea6b7 --- /dev/null +++ b/charts/obico/.helmignore @@ -0,0 +1,25 @@ +# 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/ +# helm-docs templates +*.gotmpl diff --git a/charts/obico/Chart.lock b/charts/obico/Chart.lock new file mode 100644 index 000000000..a060ededc --- /dev/null +++ b/charts/obico/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: common + repository: https://bjw-s.github.io/helm-charts + version: 1.3.2 +- name: redis + repository: https://charts.bitnami.com/bitnami + version: 17.8.0 +digest: sha256:c00e28a4fcecc4d6e3798d95eba9bdbe3f57c29b4f0406d89315b53db2cf20ec +generated: "2023-03-08T13:56:46.491098-06:00" diff --git a/charts/obico/Chart.yaml b/charts/obico/Chart.yaml new file mode 100644 index 000000000..79131bf52 --- /dev/null +++ b/charts/obico/Chart.yaml @@ -0,0 +1,29 @@ +apiVersion: v2 +name: obico +description: Obico is a community-built, open-source smart 3D printing platform used by makers, enthusiasts, and tinkerers around the world. +home: https://charts.gabe565.com/charts/obico +icon: https://raw.githubusercontent.com/TheSpaghettiDetective/OctoPrint-Obico/master/octoprint_obico/static/img/logo-square.svg +type: application +version: 0.0.1 +# renovate datasource=docker depName=ghcr.io/gabe565/obico/web +appVersion: sha-72b26dfa6f35800388816c621870664e5501dd19 +kubeVersion: ">=1.22.0-0" +keywords: + - 3d-printing + - machine-learning +dependencies: + - name: common + repository: https://bjw-s.github.io/helm-charts + version: 1.3.2 + - name: redis + repository: https://charts.bitnami.com/bitnami + version: 17.8.0 + condition: redis.enabled +sources: + - https://github.com/gabe565/charts/tree/main/charts/obico + - https://github.com/TheSpaghettiDetective/obico-server + - https://github.com/gabe565/docker-obico +annotations: + artifacthub.io/changes: |- + - kind: added + description: Initial release diff --git a/charts/obico/README.md b/charts/obico/README.md new file mode 100644 index 000000000..22177da56 --- /dev/null +++ b/charts/obico/README.md @@ -0,0 +1,113 @@ +# obico + +obico logo + +![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat) +![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat) +![AppVersion: sha-72b26dfa6f35800388816c621870664e5501dd19](https://img.shields.io/badge/AppVersion-sha--72b26dfa6f35800388816c621870664e5501dd19-informational?style=flat) + +Obico is a community-built, open-source smart 3D printing platform used by makers, enthusiasts, and tinkerers around the world. + +**Homepage:** + +**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/gabe565/charts/issues/new)** + +## Source Code + +* +* +* + +## Requirements + +Kubernetes: `>=1.22.0-0` + +## Dependencies + +| Repository | Name | Version | +|------------|------|---------| +| | common | 1.3.2 | +| | redis | 17.8.0 | + +## TL;DR + +```console +helm repo add gabe565 https://charts.gabe565.com +helm repo update +helm install obico gabe565/obico +``` + +## Installing the Chart + +To install the chart with the release name `obico` + +```console +helm install obico gabe565/obico +``` + +## Uninstalling the Chart + +To uninstall the `obico` deployment + +```console +helm uninstall obico +``` + +The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release. + +## Configuration + +Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values. +Other values may be used from the [values.yaml](https://github.com/bjw-s/helm-charts/tree/main/charts/library/common/values.yaml) from the [bjw-s common library](https://github.com/bjw-s/helm-charts/tree/main/charts/library/common). + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +```console +helm install obico \ + --set env.TZ="America/New York" \ + gabe565/obico +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. + +```console +helm install obico gabe565/obico -f values.yaml +``` + +## Custom configuration + +N/A + +## Values + +**Important**: When deploying an application Helm chart you can add more values from the bjw-s common library chart [here](https://github.com/bjw-s/helm-charts/tree/main/charts/library/common) + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| ml-api.command | list | See [values.yaml](./values.yaml) | Command to run ML API. | +| ml-api.controller.strategy | string | `"RollingUpdate"` | Set the ML API upgrade strategy | +| ml-api.env.DEBUG | string | `"True"` | Enables debug logging | +| ml-api.image.pullPolicy | string | `"IfNotPresent"` | ML API image pull policy | +| ml-api.image.repository | string | `"ghcr.io/gabe565/obico/ml-api"` | ML API image repository | +| ml-api.image.tag | string | chart.appVersion | ML API image tag | +| ml-api.service | object | See [values.yaml](./values.yaml) | Configures service settings for the ML API. | +| podSecurityContext.fsGroup | int | `65534` | Volume binds will be granted to `nobody` group | +| podSecurityContext.runAsGroup | int | `65534` | Run as `nobody` group | +| podSecurityContext.runAsUser | int | `65534` | Run as `nobody` user | +| redis | object | See [values.yaml](./values.yaml) | Enable and configure redis subchart under this key. [[ref]](https://github.com/bitnami/charts/tree/master/bitnami/redis) | +| server.additionalContainers.tasks.command | list | See [values.yaml](./values.yaml) | Task command. | +| server.command | list | See [values.yaml](./values.yaml) | Command to run Obico server. | +| server.env | string | See [values.yaml](./values.yaml) | Server environment variables. [[ref]](https://github.com/TheSpaghettiDetective/obico-server/blob/master/dotenv.example) | +| server.image.pullPolicy | string | `"IfNotPresent"` | Server image pull policy | +| server.image.repository | string | `"ghcr.io/gabe565/obico/web"` | Server image repository | +| server.image.tag | string | chart.appVersion | Server image tag | +| server.ingress.main | object | See [values.yaml](./values.yaml) | Enable and configure ingress settings for the chart under this key. | +| server.initContainers.collectstatic.command | list | See [values.yaml](./values.yaml) | Static asset generation command. | +| server.initContainers.migrate.command | list | See [values.yaml](./values.yaml) | Database migration command. | +| server.persistence.data | object | See [values.yaml](./values.yaml) | Data persistence config. | +| server.persistence.media | object | See [values.yaml](./values.yaml) | Media persistence config. | +| server.persistence.static | object | See [values.yaml](./values.yaml) | Static asset persistence config. | +| server.service | object | See [values.yaml](./values.yaml) | Configures service settings for the ML API. | + +--- +Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs) diff --git a/charts/obico/README_CONFIG.md.gotmpl b/charts/obico/README_CONFIG.md.gotmpl new file mode 100644 index 000000000..e93d80bfa --- /dev/null +++ b/charts/obico/README_CONFIG.md.gotmpl @@ -0,0 +1,9 @@ +{{- define "custom.custom.configuration.header" -}} +## Custom configuration +{{- end -}} + +{{- define "custom.custom.configuration" -}} +{{ template "custom.custom.configuration.header" . }} + +N/A +{{- end -}} diff --git a/charts/obico/templates/NOTES.txt b/charts/obico/templates/NOTES.txt new file mode 100644 index 000000000..9087aa595 --- /dev/null +++ b/charts/obico/templates/NOTES.txt @@ -0,0 +1,4 @@ +{{- $ctx := deepCopy . -}} +{{- $_ := mergeOverwrite $ctx.Values .Values.server -}} +{{- $_ = include "obico.server.hardcodedValues" . | fromYaml | merge $ctx.Values -}} +{{- include "bjw-s.common.lib.chart.notes" $ctx -}} diff --git a/charts/obico/templates/ml-api.yaml b/charts/obico/templates/ml-api.yaml new file mode 100644 index 000000000..533b68971 --- /dev/null +++ b/charts/obico/templates/ml-api.yaml @@ -0,0 +1,12 @@ +{{- define "obico.mlApi.hardcodedValues" -}} +global: + nameOverride: ml-api + +env: + FLASK_APP: server.py +{{- end }} + +{{- $ctx := deepCopy . -}} +{{- $_ := get .Values "ml-api" | mergeOverwrite $ctx.Values -}} +{{- $_ = include "obico.mlApi.hardcodedValues" . | fromYaml | merge $ctx.Values -}} +{{- include "bjw-s.common.loader.all" $ctx }} diff --git a/charts/obico/templates/server.yaml b/charts/obico/templates/server.yaml new file mode 100644 index 000000000..64255a29b --- /dev/null +++ b/charts/obico/templates/server.yaml @@ -0,0 +1,85 @@ +{{- define "obico.server.redisValues" -}} +{{- with .Values.redis }} +{{- if .enabled }} + REDIS_PASSWORD: + secretKeyRef: + name: {{ $.Release.Name }}-redis + key: redis-password + REDIS_URL: "redis://:$(REDIS_PASSWORD)@{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-redis-master:{{ default .master.service.ports.redis 6379 }}" +{{- end }} +{{- end }} +{{- end -}} + +{{- define "obico.server.env" -}} +DEBUG: "False" +DATABASE_URL: "sqlite:////data/db.sqlite3" +WEBPACK_LOADER_ENABLED: "False" + +{{- with .Values.server.ingress.main }} +SITE_USES_HTTPS: "{{ if .tls }}True{{ else }}False{{ end }}" +{{- end }} + +INTERNAL_MEDIA_HOST: "http://{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-server:{{ .Values.server.service.main.ports.http.port }}" +ML_API_HOST: "http://{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-ml-api:{{ (get .Values "ml-api").service.main.ports.http.port }}" +{{- end -}} + +{{- define "obico.server.hardcodedValues" -}} +{{- $env := deepCopy .Values.server.env }} +{{- $_ := include "obico.server.redisValues" . | fromYaml | merge $env }} +{{- $_ = include "obico.server.env" . | fromYaml | merge $env }} + +global: + nameOverride: server + +env: {{ toYaml $env | nindent 2 }} + +initContainers: + collectstatic: + image: {{ .Values.server.image.repository }}:{{ .Values.server.image.tag }} + env: {{ toYaml $env | nindent 6 }} + {{- with .Values.server.persistence }} + volumeMounts: + {{- if .data.enabled }} + - name: data + mountPath: /data + {{- end }} + {{- if .static.enabled }} + - name: static + mountPath: /app/static_build + {{- end }} + {{- end }} + securityContext: + runAsUser: 0 + runAsGroup: 0 + migrate: + image: {{ .Values.server.image.repository }}:{{ .Values.server.image.tag }} + env: {{ toYaml $env | nindent 6 }} + {{- with .Values.server.persistence }} + volumeMounts: + {{- if .data.enabled }} + - name: data + mountPath: /data + {{- end }} + {{- end }} + +additionalContainers: + tasks: + image: {{ .Values.server.image.repository }}:{{ .Values.server.image.tag }} + env: {{ toYaml $env | nindent 6 }} + {{- with .Values.server.persistence }} + volumeMounts: + {{- if .data.enabled }} + - name: data + mountPath: /data + {{- end }} + {{- if .media.enabled }} + - name: media + mountPath: /app/static_build/media + {{- end }} + {{- end }} +{{- end -}} + +{{- $ctx := deepCopy . -}} +{{- $_ := mergeOverwrite $ctx.Values .Values.server -}} +{{- $_ = include "obico.server.hardcodedValues" . | fromYaml | merge $ctx.Values -}} +{{- include "bjw-s.common.loader.all" $ctx }} diff --git a/charts/obico/values.yaml b/charts/obico/values.yaml new file mode 100644 index 000000000..8abc009f9 --- /dev/null +++ b/charts/obico/values.yaml @@ -0,0 +1,186 @@ +# +# IMPORTANT NOTE +# +# This chart inherits from our common library chart. You can check the default values/options here: +# https://github.com/bjw-s/helm-charts/blob/main/charts/library/common/values.yaml +# + +server: + image: + # -- Server image repository + repository: ghcr.io/gabe565/obico/web + # -- Server image pull policy + pullPolicy: IfNotPresent + # -- Server image tag + # @default -- chart.appVersion + tag: sha-72b26dfa6f35800388816c621870664e5501dd19 + + # -- Command to run Obico server. + # @default -- See [values.yaml](./values.yaml) + command: + - python + - manage.py + - runserver + - --nostatic + - --noreload + - 0.0.0.0:3334 + + initContainers: + collectstatic: + # -- Static asset generation command. + # @default -- See [values.yaml](./values.yaml) + command: + - python + - manage.py + - collectstatic + - --verbosity=2 + - --noinput + - --link + migrate: + # -- Database migration command. + # @default -- See [values.yaml](./values.yaml) + command: + - python + - manage.py + - migrate + + additionalContainers: + tasks: + # -- Task command. + # @default -- See [values.yaml](./values.yaml) + command: + - celery + - --app=config + - worker + - --beat + - --loglevel=info + - --concurrency=2 + - --queues=realtime,celery + - --schedule=/tmp/celerybeat-schedule + + # -- Server environment variables. [[ref]](https://github.com/TheSpaghettiDetective/obico-server/blob/master/dotenv.example) + # @default -- See [values.yaml](./values.yaml) + env: + # EMAIL_HOST: + # EMAIL_PORT: "587" + # EMAIL_USE_TLS: 'True' + # EMAIL_HOST_USER: + # EMAIL_HOST_PASSWORD: + # DEFAULT_FROM_EMAIL: + # ADMIN_IP_WHITELIST: + # SITE_IS_PUBLIC: "False" + # ACCOUNT_ALLOW_SIGN_UP: "False" + # SOCIAL_LOGIN: "False" + # OCTOPRINT_TUNNEL_PORT_RANGE: "0-0" + # TELEGRAM_BOT_TOKEN: + # TWILIO_ACCOUNT_SID: + # TWILIO_AUTH_TOKEN: + # TWILIO_FROM_NUMBER: + # SENTRY_DSN: + # PUSHOVER_APP_TOKEN: + # SLACK_CLIENT_ID: + # SLACK_CLIENT_SECRET: + + persistence: + # -- Data persistence config. + # @default -- See [values.yaml](./values.yaml) + data: + enabled: false + # storageClass: + # accessMode: ReadWriteOnce + # size: + + # -- Media persistence config. + # @default -- See [values.yaml](./values.yaml) + media: + enabled: false + mountPath: /app/static_build/media + # storageClass: + # accessMode: ReadWriteOnce + # size: + + # -- Static asset persistence config. + # @default -- See [values.yaml](./values.yaml) + static: + enabled: true + type: emptyDir + mountPath: /app/static_build + + # -- Configures service settings for the ML API. + # @default -- See [values.yaml](./values.yaml) + service: + main: + ports: + http: + port: 3334 + + ingress: + # -- Enable and configure ingress settings for the chart under this key. + # @default -- See [values.yaml](./values.yaml) + main: + enabled: false + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: 64m + # hosts: + # - host: example.com + # paths: + # - path: / + # tls: + # - secretName: example.com-tls + # hosts: + # - example.com + +ml-api: + image: + # -- ML API image repository + repository: ghcr.io/gabe565/obico/ml-api + # -- ML API image pull policy + pullPolicy: IfNotPresent + # -- ML API image tag + # @default -- chart.appVersion + tag: sha-72b26dfa6f35800388816c621870664e5501dd19 + + controller: + # -- Set the ML API upgrade strategy + strategy: RollingUpdate + + env: + # -- Enables debug logging + DEBUG: "True" + + # -- Command to run ML API. + # @default -- See [values.yaml](./values.yaml) + command: + - gunicorn + - --bind=0.0.0.0:3333 + - --workers=1 + - --access-logfile=- + - wsgi + + # -- Configures service settings for the ML API. + # @default -- See [values.yaml](./values.yaml) + service: + main: + ports: + http: + port: 3333 + +podSecurityContext: + # -- Run as `nobody` user + runAsUser: 65534 + # -- Run as `nobody` group + runAsGroup: 65534 + # -- Volume binds will be granted to `nobody` group + fsGroup: 65534 + +# -- Enable and configure redis subchart under this key. [[ref]](https://github.com/bitnami/charts/tree/master/bitnami/redis) +# @default -- See [values.yaml](./values.yaml) +redis: + enabled: true + auth: + enabled: true + master: + persistence: + enabled: false + replica: + replicaCount: 0