From 81894c8405ec8d1ba5b056399e3ea46f3d8fc76e Mon Sep 17 00:00:00 2001 From: mpw Date: Wed, 4 Oct 2023 15:15:46 -0300 Subject: [PATCH] hub-uploads chart, gw route updates --- charts/hub-gateway/Chart.yaml | 2 +- charts/hub-gateway/values.yaml | 17 +++- charts/hub-uploads/.helmignore | 23 +++++ charts/hub-uploads/Chart.yaml | 27 ++++++ charts/hub-uploads/templates/NOTES.txt | 0 charts/hub-uploads/templates/_helpers.tpl | 62 ++++++++++++ charts/hub-uploads/templates/deployment.yaml | 66 +++++++++++++ charts/hub-uploads/templates/environment.yaml | 8 ++ charts/hub-uploads/templates/hpa.yaml | 28 ++++++ charts/hub-uploads/templates/netpol.yaml | 62 ++++++++++++ charts/hub-uploads/templates/secrets.yaml | 14 +++ charts/hub-uploads/templates/service.yaml | 15 +++ .../hub-uploads/templates/serviceaccount.yaml | 12 +++ charts/hub-uploads/values.yaml | 96 +++++++++++++++++++ 14 files changed, 430 insertions(+), 2 deletions(-) create mode 100644 charts/hub-uploads/.helmignore create mode 100644 charts/hub-uploads/Chart.yaml create mode 100644 charts/hub-uploads/templates/NOTES.txt create mode 100644 charts/hub-uploads/templates/_helpers.tpl create mode 100644 charts/hub-uploads/templates/deployment.yaml create mode 100644 charts/hub-uploads/templates/environment.yaml create mode 100644 charts/hub-uploads/templates/hpa.yaml create mode 100644 charts/hub-uploads/templates/netpol.yaml create mode 100644 charts/hub-uploads/templates/secrets.yaml create mode 100644 charts/hub-uploads/templates/service.yaml create mode 100644 charts/hub-uploads/templates/serviceaccount.yaml create mode 100644 charts/hub-uploads/values.yaml diff --git a/charts/hub-gateway/Chart.yaml b/charts/hub-gateway/Chart.yaml index 6b324ef..313518f 100644 --- a/charts/hub-gateway/Chart.yaml +++ b/charts/hub-gateway/Chart.yaml @@ -18,7 +18,7 @@ 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: 0.24.0 +version: 0.24.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 diff --git a/charts/hub-gateway/values.yaml b/charts/hub-gateway/values.yaml index c8d2610..bc1bdf5 100644 --- a/charts/hub-gateway/values.yaml +++ b/charts/hub-gateway/values.yaml @@ -171,7 +171,7 @@ routes: - /terms-of-service - /privacy-policy - /api/.ory/* - - /api/uploads + - /uploads - name: hub-auth-api serviceName: hydra-public @@ -230,6 +230,21 @@ routes: - "^/id/(.*)" - "/api/.ory/${1}" + - name: api-uploads + serviceName: hub-uploads + servicePort: 80 + subdomain: api + paths: + - /uploads + methods: + - POST + oauth2: + enabled: true + regexUri: + - '/graphql' + - '/' + + apisixPlugins: session: serviceName: kratos-public diff --git a/charts/hub-uploads/.helmignore b/charts/hub-uploads/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/hub-uploads/.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/charts/hub-uploads/Chart.yaml b/charts/hub-uploads/Chart.yaml new file mode 100644 index 0000000..c983779 --- /dev/null +++ b/charts/hub-uploads/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: hub-uploads +description: Helm chart for hub-uploads +maintainers: + - name: Holaplex Engineering + email: engineering@holaplex.com + +# 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: 0.1.0 + +# 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: 0.1.0 diff --git a/charts/hub-uploads/templates/NOTES.txt b/charts/hub-uploads/templates/NOTES.txt new file mode 100644 index 0000000..e69de29 diff --git a/charts/hub-uploads/templates/_helpers.tpl b/charts/hub-uploads/templates/_helpers.tpl new file mode 100644 index 0000000..2a80f09 --- /dev/null +++ b/charts/hub-uploads/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "hub-uploads.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 "hub-uploads.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 "hub-uploads.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "hub-uploads.labels" -}} +helm.sh/chart: {{ include "hub-uploads.chart" . }} +{{ include "hub-uploads.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "hub-uploads.selectorLabels" -}} +app.kubernetes.io/name: {{ include "hub-uploads.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "hub-uploads.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "hub-uploads.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/hub-uploads/templates/deployment.yaml b/charts/hub-uploads/templates/deployment.yaml new file mode 100644 index 0000000..d2c64a9 --- /dev/null +++ b/charts/hub-uploads/templates/deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hub-uploads.fullname" . }} + labels: + {{- include "hub-uploads.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "hub-uploads.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "hub-uploads.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "hub-uploads.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ include "hub-uploads.fullname" . }} + - secretRef: + name: {{ include "hub-uploads.fullname" . }} + ports: + - name: http + containerPort: {{ .Values.environment.port }} + protocol: TCP + livenessProbe: + httpGet: + path: /health + port: http + readinessProbe: + httpGet: + path: /health + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/hub-uploads/templates/environment.yaml b/charts/hub-uploads/templates/environment.yaml new file mode 100644 index 0000000..9caa071 --- /dev/null +++ b/charts/hub-uploads/templates/environment.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "hub-uploads.fullname" . }} +data: + {{- with .Values.environment }} + PORT: {{ .port | quote }} + {{- end }} diff --git a/charts/hub-uploads/templates/hpa.yaml b/charts/hub-uploads/templates/hpa.yaml new file mode 100644 index 0000000..5836f3b --- /dev/null +++ b/charts/hub-uploads/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "hub-uploads.fullname" . }} + labels: + {{- include "hub-uploads.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "hub-uploads.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 }} diff --git a/charts/hub-uploads/templates/netpol.yaml b/charts/hub-uploads/templates/netpol.yaml new file mode 100644 index 0000000..6bbc9b3 --- /dev/null +++ b/charts/hub-uploads/templates/netpol.yaml @@ -0,0 +1,62 @@ +{{- if .Values.networkPolicies.enabled }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ include "hub-uploads.fullname" . }} + labels: + {{- include "hub-uploads.labels" . | nindent 4 }} +spec: + podSelector: + matchLabels: + {{- include "hub-uploads.selectorLabels" . | nindent 8 }} + egress: + - to: + - ipBlock: + cidr: 0.0.0.0/0 + except: + - 10.0.0.0/8 + - 192.168.0.0/16 + - 172.16.0.0/20 + - to: + - namespaceSelector: {} + podSelector: + matchLabels: + k8s-app: kube-dns + ports: + - port: 53 + protocol: UDP + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + k8s-app: node-local-dns + ports: + - port: 53 + protocol: UDP +{{- if .Values.networkPolicies.extraEgress }} +{{ toYaml .Values.networkPolicies.extraEgress | indent 4 }} +{{- end }} + ingress: + - from: + - podSelector: + matchLabels: + app.kubernetes.io/instance: hub-nfts + ports: + - port: {{ .Values.environment.port }} + protocol: TCP + - from: + - podSelector: + matchLabels: + app.kubernetes.io/instance: hub-ui + ports: + - port: {{ .Values.environment.port }} + protocol: TCP +{{- if .Values.networkPolicies.extraIngress }} +{{ toYaml .Values.networkPolicies.extraIngress | indent 4 }} +{{- end }} + policyTypes: + - Ingress + - Egress +{{- end }} diff --git a/charts/hub-uploads/templates/secrets.yaml b/charts/hub-uploads/templates/secrets.yaml new file mode 100644 index 0000000..a34449e --- /dev/null +++ b/charts/hub-uploads/templates/secrets.yaml @@ -0,0 +1,14 @@ +{{- with .Values.secrets }} +{{- if .enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "hub-uploads.fullname" $ }} + annotations: + "helm.sh/hook": pre-install +type: Opaque +data: + WEB3_UP_KEY: {{ .entries.web3UpKey | b64enc }} + WEB3_UP_PROOF: {{ .entries.web3UpProof | b64enc }} +{{- end }} +{{- end }} diff --git a/charts/hub-uploads/templates/service.yaml b/charts/hub-uploads/templates/service.yaml new file mode 100644 index 0000000..ab6f8ed --- /dev/null +++ b/charts/hub-uploads/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hub-uploads.fullname" . }} + labels: + {{- include "hub-uploads.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "hub-uploads.selectorLabels" . | nindent 4 }} diff --git a/charts/hub-uploads/templates/serviceaccount.yaml b/charts/hub-uploads/templates/serviceaccount.yaml new file mode 100644 index 0000000..baec33e --- /dev/null +++ b/charts/hub-uploads/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "hub-uploads.serviceAccountName" . }} + labels: + {{- include "hub-uploads.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/hub-uploads/values.yaml b/charts/hub-uploads/values.yaml new file mode 100644 index 0000000..2e00db1 --- /dev/null +++ b/charts/hub-uploads/values.yaml @@ -0,0 +1,96 @@ +# Default values for hub-uploads. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: holaplex/hub-uploads + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 10000 + runAsGroup: 10000 + +service: + type: ClusterIP + port: 80 + +serviceMonitor: + enabled: true + scheme: http + scrapeInterval: 60s + scrapeTimeout: 30s + labels: {} + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +networkPolicies: + enabled: false + extraEgress: [] + extraIngress: [] + # Example: + # extraEgress: + # - to: + # - ipBlock: + # cidr: 1.2.3.4/16 + # - to: + # - podSelector: + # matchLabels: + # app.kubernetes.io/name: hub-services-db + # extraIngress: [] + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +secrets: + enabled: true + entries: + web3UpKey: "" + web3UpProof: "" + +environment: + port: "3000"