diff --git a/zipline/.helmignore b/zipline/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/zipline/.helmignore @@ -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/ diff --git a/zipline/Chart.yaml b/zipline/Chart.yaml new file mode 100644 index 0000000..55e23ce --- /dev/null +++ b/zipline/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: zipline +description: A Helm chart for deploying Zipline on Kubernetes + +# 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: 1.2.0-release-4-4-1 + +# 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: "4.4.1" diff --git a/zipline/templates/db-connection.secret.yaml b/zipline/templates/db-connection.secret.yaml new file mode 100644 index 0000000..5348221 --- /dev/null +++ b/zipline/templates/db-connection.secret.yaml @@ -0,0 +1,6 @@ +apiVersion: onepassword.com/v1 +kind: OnePasswordItem +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-db-secret +spec: + itemPath: {{ required "A secret-reference for the DB-Secret must be provided" .Values.config.secretRef.db }} diff --git a/zipline/templates/zipline.ingress.yaml b/zipline/templates/zipline.ingress.yaml new file mode 100644 index 0000000..8e24c99 --- /dev/null +++ b/zipline/templates/zipline.ingress.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + cert-manager.io/cluster-issuer: letsencrypt-issuer + nginx.ingress.kubernetes.io/proxy-body-size: {{ .Values.config.maxUploadFileSize }} + nginx.org/client-max-body-size: {{ .Values.config.maxUploadFileSize }} +spec: + ingressClassName: nginx + rules: + - host: {{ required "A Domain/Host must be provided" .Values.config.domain }} + http: + paths: + - backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }}-service + port: + name: http + path: / + pathType: Prefix + tls: + - hosts: + - {{ required "A Domain/Host must be provided" .Values.config.domain }} + secretName: tls-{{ .Release.Name }}-{{ .Chart.Name }}-{{ .Values.config.domain }}-ingress \ No newline at end of file diff --git a/zipline/templates/zipline.pvc.yaml b/zipline/templates/zipline.pvc.yaml new file mode 100644 index 0000000..a93a076 --- /dev/null +++ b/zipline/templates/zipline.pvc.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-vc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ required "A storage-amount must be provided" .Values.config.storage }} + storageClassName: {{ required "A storage-class must be provided" .Values.config.storageClass }} diff --git a/zipline/templates/zipline.secret.yaml b/zipline/templates/zipline.secret.yaml new file mode 100644 index 0000000..ed33632 --- /dev/null +++ b/zipline/templates/zipline.secret.yaml @@ -0,0 +1,6 @@ +apiVersion: onepassword.com/v1 +kind: OnePasswordItem +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-core-secret +spec: + itemPath: {{ required "A secret-reference for the DB-Secret must be provided" .Values.config.secretRef.zipline }} diff --git a/zipline/templates/zipline.service.yaml b/zipline/templates/zipline.service.yaml new file mode 100644 index 0000000..edef36f --- /dev/null +++ b/zipline/templates/zipline.service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-service +spec: + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }}-sfs + ports: + - protocol: TCP + port: 80 + targetPort: zipline-server + name: http + type: ClusterIP diff --git a/zipline/templates/zipline.sfs.yaml b/zipline/templates/zipline.sfs.yaml new file mode 100644 index 0000000..69fe566 --- /dev/null +++ b/zipline/templates/zipline.sfs.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: "{{ .Release.Name }}-{{ .Chart.Name }}-sfs" +spec: + selector: + matchLabels: + app: "{{ .Release.Name }}-{{ .Chart.Name }}-sfs" + serviceName: "{{ .Release.Name }}-{{ .Chart.Name }}-service" + replicas: 1 + template: + metadata: + labels: + app: "{{ .Release.Name }}-{{ .Chart.Name }}-sfs" + spec: + containers: + - name: "{{ .Release.Name }}-{{ .Chart.Name }}-sfs" + image: "ghcr.io/diced/zipline:{{ .Chart.AppVersion }}" + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-{{ .Chart.Name }}-db-secret + key: connection-url + - name: CORE_DEFAULT_DOMAIN + value: "{{ .Values.config.domain }}" + - name: CORE_SECRET + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-{{ .Chart.Name }}-core-secret + key: server-secret + - name: UPLOADER_ADMIN_LIMIT + value: 500mb + resources: + requests: + memory: "{{ .Values.zipline.resources.requests.memory }}" + cpu: "{{ .Values.zipline.resources.requests.cpu }}" + ephemeral-storage: "{{ .Values.zipline.resources.requests.ephemeralStorage }}" + limits: + memory: "{{ .Values.zipline.resources.limits.memory }}" + cpu: "{{ .Values.zipline.resources.limits.cpu }}" + ephemeral-storage: "{{ .Values.zipline.resources.limits.ephemeralStorage }}" + ports: + - name: "zipline-server" + containerPort: 3000 + protocol: TCP + volumeMounts: + - name: zipline-volume + mountPath: /zipline/uploads + subPath: uploads/ + - name: zipline-volume + mountPath: /zipline/public + subPath: public/ + - name: zipline-volume + mountPath: /zipline/themes + subPath: themes/ + automountServiceAccountToken: false + volumes: + - name: zipline-volume + persistentVolumeClaim: + claimName: {{ .Release.Name }}-{{ .Chart.Name }}-vc diff --git a/zipline/values.yaml b/zipline/values.yaml new file mode 100644 index 0000000..72bf1d4 --- /dev/null +++ b/zipline/values.yaml @@ -0,0 +1,18 @@ +config: + storage: 50Gi + storageClass: longhorn + secretRef: + db: null + zipline: null + domain: null + maxUploadFileSize: 30m +zipline: + resources: + requests: + cpu: 0.1 + memory: 265Mi + ephemeralStorage: 10Mi + limits: + cpu: 1 + memory: 768Mi + ephemeralStorage: 10Mi \ No newline at end of file