diff --git a/swh-graphql/Chart.yaml b/swh-graphql/Chart.yaml new file mode 100644 --- /dev/null +++ b/swh-graphql/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: swh-graphql +description: A Helm chart to deploy the graphql service + +# 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: "1.16.0" diff --git a/swh-graphql/README.md b/swh-graphql/README.md new file mode 100644 --- /dev/null +++ b/swh-graphql/README.md @@ -0,0 +1,31 @@ +# Goal + +- Deploy a standalone graphql instance + +This chart will be merged with the global swh chart when available + +# helm + +We use helm to ease the cluster application management. + +# Install + +## Prerequisites +- Helm >= 3.0 +- Access to a kubernetes cluster +- The url of a reachable swh storage + +## Chart installation + +Install the worker declaration from this directory in the cluster +``` +$ helm install -f my-values.yaml graphql +``` + +With `my-values.yaml` containing some overrides of the default +values matching your environment. + +Detail of the possible values is visible with: +``` +swh-charts/swh-graphql $ helm show values . +``` diff --git a/swh-graphql/templates/configmap.yaml b/swh-graphql/templates/configmap.yaml new file mode 100644 --- /dev/null +++ b/swh-graphql/templates/configmap.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: graphql + namespace: {{ .Values.namespace }} +data: + config.yml: | + storage: + cls: remote + url: {{ .Values.storageUrl }} + + debug: yes + + server-type: wsgi diff --git a/swh-graphql/templates/deployment.yaml b/swh-graphql/templates/deployment.yaml new file mode 100644 --- /dev/null +++ b/swh-graphql/templates/deployment.yaml @@ -0,0 +1,53 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: graphql + namespace: {{ .Values.namespace }} + labels: + app: graphql +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + app: graphql + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + template: + metadata: + labels: + app: graphql + annotations: + # Force a rollout upgrade if the configuration changes + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + spec: + containers: + - name: graphql + image: {{ .Values.image.name }}:{{ .Values.image.version }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 5013 + env: + - name: PORT + value: "5013" + - name: THREADS + value: {{ .Values.gunicornThreads | quote }} + - name: WORKERS + value: {{ .Values.gunicornWorkers | quote }} + - name: LOG_LEVEL + value: {{ .Values.logLevel | quote }} + - name: TIMEOUT + value: {{ .Values.gunicornTimeout | quote }} + volumeMounts: + - name: config + mountPath: /etc/swh/config.yml + subPath: config.yml + readOnly: true + volumes: + - name: config + configMap: + name: graphql + defaultMode: 0400 + diff --git a/swh-graphql/templates/ingress.yaml b/swh-graphql/templates/ingress.yaml new file mode 100644 --- /dev/null +++ b/swh-graphql/templates/ingress.yaml @@ -0,0 +1,23 @@ +{{ if .Values.enableIngress }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: graphql + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + {{- if .Values.ingressClassName }} + ingressClassName: {{ .Values.ingressClassName }} + {{- end }} + rules: + - host: {{ .Values.ingressHost }} + http: + paths: + - path: {{ .Values.ingressHttpPath }} + pathType: Prefix + backend: + service: + name: graphql + port: + number: 5013 +{{ end }} diff --git a/swh-graphql/templates/service.yaml b/swh-graphql/templates/service.yaml new file mode 100644 --- /dev/null +++ b/swh-graphql/templates/service.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: graphql + namespace: {{ .Values.namespace }} +spec: + type: ClusterIP + selector: + app: graphql + ports: + - port: 5013 + targetPort: 5013 diff --git a/swh-graphql/values.yaml b/swh-graphql/values.yaml new file mode 100644 --- /dev/null +++ b/swh-graphql/values.yaml @@ -0,0 +1,36 @@ +# Default values for graphql. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +namespace: default + +# Number of graphql pods to deploy +replicas: 1 + +image: + # The name of the image to use + name: softwareheritage/graphql + # The version of the image to use + version: latest + pullPolicy: Always + +# The storage url to query +storageUrl: http://storage.svc.cluster.local:5002 + +# Deploy or not an ingress controller +enableIngress: true +# Specify the ingress class to use if several are available in the cluster +ingressClassName: {} + +# The ingress host to listen for +ingressHost: graphql.localdomain + +# Configure the path of the ingress +ingressHttpPath: / + +# The graphql log level. Possible values TRACE, DEBUG, INFO, ERROR +logLevel: INFO + +gunicornThreads: 4 +gunicornWorkers: 2 +gunicornTimeout: 3600