diff --git a/charts/runner/.helmignore b/charts/runner/.helmignore new file mode 100644 index 0000000..47c3a48 --- /dev/null +++ b/charts/runner/.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/ + +values/ diff --git a/charts/runner/Chart.yaml b/charts/runner/Chart.yaml new file mode 100644 index 0000000..5b43870 --- /dev/null +++ b/charts/runner/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: runner +description: Helm Chart for DeepSource Runner +maintainers: + - name: DeepSource + email: support@deepsource.io + +# 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" diff --git a/charts/runner/README.md b/charts/runner/README.md new file mode 100644 index 0000000..83ff2ca --- /dev/null +++ b/charts/runner/README.md @@ -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` | diff --git a/charts/runner/templates/NOTES.txt b/charts/runner/templates/NOTES.txt new file mode 100644 index 0000000..d9df937 --- /dev/null +++ b/charts/runner/templates/NOTES.txt @@ -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 }} diff --git a/charts/runner/templates/_helpers.tpl b/charts/runner/templates/_helpers.tpl new file mode 100644 index 0000000..a75fda5 --- /dev/null +++ b/charts/runner/templates/_helpers.tpl @@ -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 }} diff --git a/charts/runner/templates/artifact-secret.yaml b/charts/runner/templates/artifact-secret.yaml new file mode 100644 index 0000000..a8693b2 --- /dev/null +++ b/charts/runner/templates/artifact-secret.yaml @@ -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 }} diff --git a/charts/runner/templates/deployment.yaml b/charts/runner/templates/deployment.yaml new file mode 100644 index 0000000..a258366 --- /dev/null +++ b/charts/runner/templates/deployment.yaml @@ -0,0 +1,77 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "runner.fullname" . }} + labels: + {{- include "runner.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "runner.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "runner.selectorLabels" . | nindent 8 }} + spec: + imagePullSecrets: + - name: {{ include "runner.fullname" . }}-image-registry + serviceAccountName: {{ include "runner.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["/app/runner"] + args: ["--config", "/config/config.yaml", "--debug", "true"] + env: + - name: RQLITE_HOST + value: {{ include "rqlite.fullname" . }}-svc + - name: RQLITE_PORT + value: "4001" + - name: TASK_IMAGE_PULL_SECRET_NAME + value: {{ include "runner.fullname" . }}-image-registry + - name: TASK_IMAGE_REGISTRY_URL + value: {{ .Values.imageRegistry.registryUrl }} + - name: TASK_NAMESPACE + value: {{ .Release.Namespace }} + - name: TASK_NODE_SELECTOR + value: {{ .Values.nodeSelector | toYaml | toString | quote }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: secret + mountPath: "/config" + readOnly: true + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: secret + secret: + secretName: {{ include "runner.fullname" . }} + items: + - key: config + path: config.yaml \ No newline at end of file diff --git a/charts/runner/templates/hpa.yaml b/charts/runner/templates/hpa.yaml new file mode 100644 index 0000000..471ad8f --- /dev/null +++ b/charts/runner/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "runner.fullname" . }} + labels: + {{- include "runner.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "runner.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/runner/templates/image-pull-secret.yaml b/charts/runner/templates/image-pull-secret.yaml new file mode 100644 index 0000000..5a1452d --- /dev/null +++ b/charts/runner/templates/image-pull-secret.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "runner.fullname" . }}-image-registry + namespace: {{ .Release.Namespace }} +type: kubernetes.io/dockerconfigjson +stringData: + .dockerconfigjson: |- +{{- $auth := printf "%s:%s" .Values.imageRegistry.username .Values.imageRegistry.password | b64enc }} + { + "auths": { + "{{ .Values.imageRegistry.registryUrl }}": { + "username": "{{ .Values.imageRegistry.username }}", + "password": "{{ .Values.imageRegistry.password }}", + "auth": "{{ $auth }}" + } + } + } diff --git a/charts/runner/templates/ingress.yaml b/charts/runner/templates/ingress.yaml new file mode 100644 index 0000000..4df6e2f --- /dev/null +++ b/charts/runner/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "runner.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "runner.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/runner/templates/role.yaml b/charts/runner/templates/role.yaml new file mode 100644 index 0000000..f066251 --- /dev/null +++ b/charts/runner/templates/role.yaml @@ -0,0 +1,9 @@ +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: "runner-jobs" + namespace: {{ .Release.Namespace }} +rules: +- apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["get", "list", "create", "delete"] diff --git a/charts/runner/templates/rolebinding.yaml b/charts/runner/templates/rolebinding.yaml new file mode 100644 index 0000000..86858cb --- /dev/null +++ b/charts/runner/templates/rolebinding.yaml @@ -0,0 +1,13 @@ +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: "runner-jobs" + namespace: {{ .Release.Namespace }} +subjects: +- kind: ServiceAccount + name: "runner" + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: "runner-jobs" + apiGroup: rbac.authorization.k8s.io diff --git a/charts/runner/templates/rqlite-internal-service.yaml b/charts/runner/templates/rqlite-internal-service.yaml new file mode 100644 index 0000000..ed860d3 --- /dev/null +++ b/charts/runner/templates/rqlite-internal-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "rqlite.fullname" . }}-svc-internal +spec: + clusterIP: None + publishNotReadyAddresses: True + selector: + app: {{ include "rqlite.name" . }} + ports: + - protocol: TCP + port: 4001 + targetPort: 4001 diff --git a/charts/runner/templates/rqlite-service.yaml b/charts/runner/templates/rqlite-service.yaml new file mode 100644 index 0000000..710b7c2 --- /dev/null +++ b/charts/runner/templates/rqlite-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "rqlite.fullname" . }}-svc +spec: + selector: + app: {{ include "rqlite.name" . }} + ports: + - protocol: TCP + port: 4001 + targetPort: 4001 diff --git a/charts/runner/templates/rqlite-statefulset.yaml b/charts/runner/templates/rqlite-statefulset.yaml new file mode 100644 index 0000000..43ae761 --- /dev/null +++ b/charts/runner/templates/rqlite-statefulset.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "rqlite.fullname" . }} +spec: + selector: + matchLabels: + app: {{ include "rqlite.name" . }} + serviceName: {{ include "rqlite.fullname" . }}-svc-internal + replicas: {{ .Values.rqlite.replicaCount }} + podManagementPolicy: "Parallel" + template: + metadata: + labels: + app: {{ include "rqlite.name" . }} + spec: + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: 10 + containers: + - name: {{ include "rqlite.name" . }} + image: {{ .Values.rqlite.image.repository }}:{{ .Values.rqlite.image.tag }} + imagePullPolicy: {{ .Values.rqlite.image.pullPolicy }} + args: + - "-disco-mode=dns" + - "-disco-config={\"name\":\"{{ include "rqlite.fullname" . }}-svc-internal\"}" + - "-bootstrap-expect={{ .Values.rqlite.replicaCount }}" + - "-join-interval=1s" + - "-join-attempts=120" + ports: + - containerPort: 4001 + name: rqlite + resources: + {{- toYaml .Values.resources | nindent 12 }} + readinessProbe: + httpGet: + scheme: HTTP + path: /readyz + port: 4001 + periodSeconds: 5 + timeoutSeconds: 2 + initialDelaySeconds: 2 + livenessProbe: + httpGet: + scheme: HTTP + path: /readyz?noleader + port: rqlite + initialDelaySeconds: 5 + timeoutSeconds: 2 + failureThreshold: 3 + volumeMounts: + - name: rqlite-file + mountPath: /rqlite/file + volumeClaimTemplates: + - metadata: + name: rqlite-file + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: {{ .Values.rqlite.storageSize }} diff --git a/charts/runner/templates/secret.yaml b/charts/runner/templates/secret.yaml new file mode 100644 index 0000000..d33da85 --- /dev/null +++ b/charts/runner/templates/secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "runner.fullname" . }} + namespace: {{ .Release.Namespace }} +type: Generic +data: + config: | +{{ .Values.config | toYaml | toString | b64enc | indent 4 }} diff --git a/charts/runner/templates/service.yaml b/charts/runner/templates/service.yaml new file mode 100644 index 0000000..f8b4901 --- /dev/null +++ b/charts/runner/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "runner.fullname" . }} + labels: + {{- include "runner.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 8080 + protocol: TCP + name: http + selector: + {{- include "runner.selectorLabels" . | nindent 4 }} diff --git a/charts/runner/templates/serviceaccount.yaml b/charts/runner/templates/serviceaccount.yaml new file mode 100644 index 0000000..288876c --- /dev/null +++ b/charts/runner/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "runner.serviceAccountName" . }} + labels: + {{- include "runner.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/runner/templates/tests/test-connection.yaml b/charts/runner/templates/tests/test-connection.yaml new file mode 100644 index 0000000..6f971db --- /dev/null +++ b/charts/runner/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "runner.fullname" . }}-test-connection" + labels: + {{- include "runner.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "runner.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/runner/values.schema.json b/charts/runner/values.schema.json new file mode 100644 index 0000000..68d6596 --- /dev/null +++ b/charts/runner/values.schema.json @@ -0,0 +1,269 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "properties": { + "config": { + "type": "object", + "properties": { + "runner": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "host": { + "type": "string" + }, + "clientId": { + "type": "string" + }, + "clientSecret": { + "type": "string" + }, + "privateKey": { + "type": "string" + }, + "webhookSecret": { + "type": "string" + } + } + }, + "deepsource": { + "type": "object", + "properties": { + "host": { + "type": "string" + }, + "publicKey": { + "type": "string" + } + } + }, + "apps": { + "type": "array" + }, + "saml": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "metadataUrl": { + "type": "string" + }, + "certificate": { + "type": "string" + }, + "key": { + "type": "string" + } + } + }, + "objectStorage": { + "type": "object", + "properties": { + "backend": { + "type": "string" + }, + "bucket": { + "type": "string" + }, + "credential": { + "type": "string" + } + } + } + } + }, + "replicaCount": { + "type": "integer" + }, + "image": { + "type": "object", + "properties": { + "repository": { + "type": "string" + }, + "pullPolicy": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "imagePullSecrets": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ] + } + }, + "nameOverride": { + "type": "string" + }, + "fullnameOverride": { + "type": "string" + }, + "serviceAccount": { + "type": "object", + "properties": { + "create": { + "type": "boolean" + }, + "annotations": { + "type": "object" + }, + "name": { + "type": "string" + } + } + }, + "podAnnotations": { + "type": "object" + }, + "podSecurityContext": { + "type": "object" + }, + "securityContext": { + "type": "object" + }, + "service": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "port": { + "type": "integer" + } + } + }, + "ingress": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "className": { + "type": "string" + }, + "annotations": { + "type": "object" + }, + "hosts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "host": { + "type": "string" + }, + "paths": { + "type": "array", + "items": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "pathType": { + "type": "string" + } + } + } + } + } + } + }, + "tls": { + "type": "array", + "items": { + "type": "object", + "properties": { + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "secretName": { + "type": "string" + } + }, + "required": [ + "hosts", + "secretName" + ] + } + } + } + }, + "resources": { + "type": "object", + "properties": { + "limits": { + "type": "object" + }, + "requests": { + "type": "object" + } + } + }, + "nodeSelector": { + "type": "object" + }, + "tolerations": { + "type": "array", + "items": { + "type": "object" + } + }, + "affinity": { + "type": "object" + }, + "rqlite": { + "type": "object", + "properties": { + "image": { + "type": "object", + "properties": { + "repository": { + "type": "string" + }, + "pullPolicy": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "replicaCount": { + "type": "integer" + }, + "resources": { + "type": "object", + "properties": { + "limits": { + "type": "object" + }, + "requests": { + "type": "object" + } + } + }, + "storageSize": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/charts/runner/values.yaml b/charts/runner/values.yaml new file mode 100644 index 0000000..6f1ba19 --- /dev/null +++ b/charts/runner/values.yaml @@ -0,0 +1,276 @@ +## @section Runner configuration Parameters +## + +## The configuration values for deepsource runner, this will create a secret to be used by the runner +## +config: + ## @param config.apps Configuration values for the VCS apps to be used by the runner + ## apps: + ## - name: app1 + ## provider: github + ## github: + ## apiHost: "" + ## appId: "" + ## clientId: "" + ## clientSecret: "" + ## host: "" + ## privateKey: "" + ## slug: "" + ## webhookSecret: "" + ## + apps: [] + ## Configuration values for the deepsource remote host + deepsource: + ## @param config.deepsource.host The host of the deepsource remote + host: "" + ## @param config.deepsource.publicKey The public key to use for the deepsource remote + publicKey: "" + ## Configuration values for the object storage to use for the runner + ## + objectStorage: + ## @param config.objectStorage.backend The backend to use for the object storage (e.g gcs) + ## + backend: "" + ## @param config.objectStorage.bucket The bucket to use for the object storage + ## + bucket: "" + ## @param config.objectStorage.credential The credentials value to use for the object storage + ## + credential: "" + ## Configuration values for the runner + ## + runner: + ## @param config.runner.id The id of the runner + ## + id: "" + ## @param config.runner.host The host of the runner to use + ## + host: "" + ## @param config.runner.clientId The client id to use for the runner + ## + clientId: "" + ## @param config.runner.clientSecret The client secret to use for the runner + ## + clientSecret: "" + ## @param config.runner.privateKey The private key to use for the runner + ## + privateKey: "" + ## @param config.runner.webhookSecret The webhook secret to use for the runner + ## + webhookSecret: "" + ## Configuration values for the SAML2.0 identity provider + ## + saml: + ## @param config.saml.enabled Whether to enable SAML2.0 authentication + ## + enabled: false + ## @param config.saml.certificate The certificate to use for the runner as service provider + ## + certificate: "" + ## @param config.saml.key The private key to use for the runner as service provider + ## + key: "" + ## @param config.saml.metadataUrl The metadata url to use for the identity provider + metadataUrl: "" + +## @section Common Parameters +## + +## @param replicaCount Number of deepsource runner replicas to deploy +## +replicaCount: 1 + +## Deepsource runner image version +## @param image.repository deepsource runner image repository +## @param image.pullPolicy deepsource runner image pull policy +## @param image.tag deepsource runner image tag +## +image: + repository: proxy.deepsource.com/images/deepsource-production/runner + pullPolicy: Always + tag: "" + +## Deepsource runner image registry configuration +## @param imageRegistry.registryUrl The registry url to use for the task images +## @param imageRegistry.username The username to use for the image registry +## @param imageRegistry.password The password to use for the image registry +imageRegistry: + registryUrl: "" + username: "" + password: "" + +## @param nameOverride String to partially override runner.name +## +nameOverride: "" + +## @param fullnameOverride String to partially override runner.name +## +fullnameOverride: "" + +## ServiceAccount configuration +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ +## @param serviceAccount.create Specifies whether a ServiceAccount should be created +## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. Only used if `create` is `true`. +## @param serviceAccount.name Name of the service account to use. If not set and create is true, a name is generated using the fullname template. +## +serviceAccount: + create: true + annotations: {} + name: "" + +## @param podAnnotations Annotations for the deepsource runner pods +## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +## +podAnnotations: {} + +## @param podSecurityContext Security context policies to add to the deepsource runner pods +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod +## +podSecurityContext: {} + +## @param securityContext Security context policies to add to the containers +## +securityContext: {} + +## deepsource runner service parameters +## +service: + ## @param service.type deepsource runner service type + ## + type: ClusterIP + ## @param service.port deepsource runner service HTTP port + ## + port: 80 + +## DeepSource runner ingress parameters +## ref: https://kubernetes.io/docs/user-guide/ingress/ +## +ingress: + ## @param ingress.enabled Enable ingress record generation for deepsource runner + ## + enabled: false + ## @param ingress.className IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) + ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster. + ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/ + ## + className: "" + ## @param ingress.annotations Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. + ## Use this parameter to set the required annotations for cert-manager, see + ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations + ## e.g: + ## annotations: + ## kubernetes.io/ingress.class: nginx + ## cert-manager.io/cluster-issuer: cluster-issuer-name + ## + annotations: {} + ## @param ingress.hosts Deepsource runner Ingress hosts + ## hosts: + ## - host: runner.example.com + ## paths: + ## - path: / + ## pathType: ImplementationSpecific + hosts: [] + ## @param ingress.tls Deepsource runner Ingress TLS configuration + ## tls: + ## - secretName: tls-runner-deepsource-com + ## hosts: + ## - runner.example.com + tls: [] + +## DeepSource runner resource requests and limits +## ref: https://kubernetes.io/docs/user-guide/compute-resources/ +## +resources: + ## The resources limits for the deepsource runner containers + ## + limits: + ## @param resources.limits.cpu The resources limits for the deepsource runner containers + ## + cpu: 200m + ## @param resources.limits.memory The resources limits for the deepsource runner containers + ## + memory: 1Gi + ## The requested resources for the deepsource runner containers + ## + requests: + ## @param resources.requests.cpu The requested cpu for the deepsource runner containers + ## + cpu: 100m + ## @param resources.requests.memory The requested memory for the deepsource runner containers + ## + memory: 128Mi + +## Autoscaling parameters +## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ +## @param autoscaling.enabled Enable Horizontal POD autoscaling for deepsource runner +## @param autoscaling.minReplicas Minimum number of deepsource runner replicas +## @param autoscaling.maxReplicas Maximum number of deepsource runner replicas +## @param autoscaling.targetCPUUtilizationPercentage Target CPU utilization percentage +## @param autoscaling.targetMemoryUtilizationPercentage Target Memory utilization percentage +## +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + +## @param nodeSelector Node labels for deepsource runner pods assignment +## ref: https://kubernetes.io/docs/user-guide/node-selection/ +## +nodeSelector: {} + +## @param tolerations Tolerations for deepsource runner pods assignment +## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ +## +tolerations: [] + +## @param affinity Affinity for deepsource runner pods assignment +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +## +affinity: {} + +## @section RQLite configuration parameters +## + +## RQLite configuration parameters +rqlite: + ## RQLite image version + ## @param rqlite.image.repository RQLite image repository + ## @param rqlite.image.pullPolicy RQLite image pull policy + ## @param rqlite.image.tag RQLite image tag + ## + image: + repository: "rqlite/rqlite" + pullPolicy: IfNotPresent + tag: "7.20.6" + + ## @param rqlite.replicaCount Number of rqlite replicas to deploy + ## + replicaCount: 1 + + ## @param rqlite.storageSize The size of the persistent volume to use for the rqlite database + ## + storageSize: 1Gi + + ## RQLite resource requests and limits + ## ref: https://kubernetes.io/docs/user-guide/compute-resources/ + resources: + ## The resources limits for the rqlite containers + ## + limits: + ## @param rqlite.resources.limits.cpu The resources limits for the rqlite containers + ## + cpu: 200m + ## @param rqlite.resources.limits.memory The resources limits for the rqlite containers + ## + memory: 1Gi + ## The requested resources for the rqlite containers + ## + requests: + ## @param rqlite.resources.requests.cpu The requested cpu for the rqlite containers + ## + cpu: 100m + ## @param rqlite.resources.requests.memory The requested memory for the rqlite containers + ## + memory: 128Mi