Skip to content

Commit

Permalink
feat: add deepsource runner helm chart (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohank-deepsource authored Jul 28, 2023
1 parent 312efe6 commit 89992a7
Show file tree
Hide file tree
Showing 21 changed files with 1,133 additions and 0 deletions.
25 changes: 25 additions & 0 deletions charts/runner/.helmignore
Original file line number Diff line number Diff line change
@@ -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/

values/
27 changes: 27 additions & 0 deletions charts/runner/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v2
name: runner
description: Helm Chart for DeepSource Runner
maintainers:
- name: DeepSource
email: [email protected]

# 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.0.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: "v1.0.0-beta.1"
75 changes: 75 additions & 0 deletions charts/runner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## Parameters

### Runner configuration Parameters

| Name | Description | Value |
| --------------------------------- | -------------------------------------------------------------- | ------- |
| `config.apps` | Configuration values for the VCS apps to be used by the runner | `[]` |
| `config.deepsource.host` | The host of the deepsource remote | `""` |
| `config.deepsource.publicKey` | The public key to use for the deepsource remote | `""` |
| `config.objectStorage.backend` | The backend to use for the object storage (e.g gcs) | `""` |
| `config.objectStorage.bucket` | The bucket to use for the object storage | `""` |
| `config.objectStorage.credential` | The credentials value to use for the object storage | `""` |
| `config.runner.id` | The id of the runner | `""` |
| `config.runner.host` | The host of the runner to use | `""` |
| `config.runner.clientId` | The client id to use for the runner | `""` |
| `config.runner.clientSecret` | The client secret to use for the runner | `""` |
| `config.runner.privateKey` | The private key to use for the runner | `""` |
| `config.runner.webhookSecret` | The webhook secret to use for the runner | `""` |
| `config.saml.enabled` | Whether to enable SAML2.0 authentication | `false` |
| `config.saml.certificate` | The certificate to use for the runner as service provider | `""` |
| `config.saml.key` | The private key to use for the runner as service provider | `""` |
| `config.saml.metadataUrl` | The metadata url to use for the identity provider | `""` |

### Common Parameters

| Name | Description | Value |
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `replicaCount` | Number of deepsource runner replicas to deploy | `1` |
| `image.repository` | deepsource runner image repository | `proxy.deepsource.com/images/deepsource-production/runner` |
| `image.pullPolicy` | deepsource runner image pull policy | `Always` |
| `image.tag` | deepsource runner image tag | `""` |
| `imageRegistry.registryUrl` | The registry url to use for the task images | `""` |
| `imageRegistry.username` | The username to use for the image registry | `""` |
| `imageRegistry.password` | The password to use for the image registry | `""` |
| `nameOverride` | String to partially override runner.name | `""` |
| `fullnameOverride` | String to partially override runner.name | `""` |
| `serviceAccount.create` | Specifies whether a ServiceAccount should be created | `true` |
| `serviceAccount.annotations` | Annotations for service account. Evaluated as a template. Only used if `create` is `true`. | `{}` |
| `serviceAccount.name` | Name of the service account to use. If not set and create is true, a name is generated using the fullname template. | `""` |
| `podAnnotations` | Annotations for the deepsource runner pods | `{}` |
| `podSecurityContext` | Security context policies to add to the deepsource runner pods | `{}` |
| `securityContext` | Security context policies to add to the containers | `{}` |
| `service.type` | deepsource runner service type | `ClusterIP` |
| `service.port` | deepsource runner service HTTP port | `80` |
| `ingress.enabled` | Enable ingress record generation for deepsource runner | `false` |
| `ingress.className` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` |
| `ingress.annotations` | Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. | `{}` |
| `ingress.hosts` | Deepsource runner Ingress hosts | `[]` |
| `ingress.tls` | Deepsource runner Ingress TLS configuration | `[]` |
| `resources.limits.cpu` | The resources limits for the deepsource runner containers | `200m` |
| `resources.limits.memory` | The resources limits for the deepsource runner containers | `1Gi` |
| `resources.requests.cpu` | The requested cpu for the deepsource runner containers | `100m` |
| `resources.requests.memory` | The requested memory for the deepsource runner containers | `128Mi` |
| `autoscaling.enabled` | Enable Horizontal POD autoscaling for deepsource runner | `false` |
| `autoscaling.minReplicas` | Minimum number of deepsource runner replicas | `1` |
| `autoscaling.maxReplicas` | Maximum number of deepsource runner replicas | `100` |
| `autoscaling.targetCPUUtilizationPercentage` | Target CPU utilization percentage | `80` |
| `autoscaling.targetMemoryUtilizationPercentage` | Target Memory utilization percentage | `80` |
| `nodeSelector` | Node labels for deepsource runner pods assignment | `{}` |
| `tolerations` | Tolerations for deepsource runner pods assignment | `[]` |
| `affinity` | Affinity for deepsource runner pods assignment | `{}` |

### RQLite configuration parameters

| Name | Description | Value |
| ---------------------------------- | ---------------------------------------------------------------- | --------------- |
| `rqlite.image.repository` | RQLite image repository | `rqlite/rqlite` |
| `rqlite.image.pullPolicy` | RQLite image pull policy | `IfNotPresent` |
| `rqlite.image.tag` | RQLite image tag | `7.20.6` |
| `rqlite.replicaCount` | Number of rqlite replicas to deploy | `1` |
| `rqlite.storageSize` | The size of the persistent volume to use for the rqlite database | `1Gi` |
| `rqlite.resources.limits.cpu` | The resources limits for the rqlite containers | `200m` |
| `rqlite.resources.limits.memory` | The resources limits for the rqlite containers | `1Gi` |
| `rqlite.resources.requests.cpu` | The requested cpu for the rqlite containers | `100m` |
| `rqlite.resources.requests.memory` | The requested memory for the rqlite containers | `128Mi` |
22 changes: 22 additions & 0 deletions charts/runner/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "runner.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "runner.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "runner.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "runner.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
79 changes: 79 additions & 0 deletions charts/runner/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "runner.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 "runner.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 "runner.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "runner.labels" -}}
helm.sh/chart: {{ include "runner.chart" . }}
{{ include "runner.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "runner.selectorLabels" -}}
app.kubernetes.io/name: {{ include "runner.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "runner.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "runner.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "rqlite.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}-rqlite
{{- end }}

{{- define "rqlite.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 "-" }}-rqlite
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}-rqlite
{{- end }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/runner/templates/artifact-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: "artifacts-credentials"
namespace: {{ .Release.Namespace }}
type: Opaque
data:
credentials: {{ .Values.config.objectStorage.credential | b64enc | indent 2 }}
Loading

0 comments on commit 89992a7

Please sign in to comment.