Skip to content

Commit

Permalink
Merge pull request #115 from port-labs/ocean-cron-deployment
Browse files Browse the repository at this point in the history
Add deployment kind of workload for port-ocean chart
  • Loading branch information
yairsimantov20 authored Jun 10, 2024
2 parents 107b64e + 96852d7 commit 21a3fb3
Show file tree
Hide file tree
Showing 10 changed files with 355 additions and 48 deletions.
2 changes: 1 addition & 1 deletion charts/port-ocean/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: port-ocean
description: A Helm chart for Port Ocean integrations
type: application
version: 0.1.26
version: 0.2.0
appVersion: "0.1.0"
home: https://getport.io/
sources:
Expand Down
11 changes: 8 additions & 3 deletions charts/port-ocean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,23 @@ The following table lists the configuration parameters of the `port-ocean` chart
| `port.clientSecret` | Client secret for Port API authentication (irrelevant if secret.useExistingSecret=true). | |
| `port.baseUrl` | Base URL for the Port API. | `https://api.getport.io/v1` |
| `initializePortResources` | When set to true, creates a default JQ mapping and the relevant blueprints | `true` |
| `scheduledResyncInterval` | The number in minutes to reschedule and poll data from the 3rd party system | `null` |
| `sendRawDataExamples` | Enable sending raw data examples from the third party API to port for testing and managing the integration mapping | `true` |
| `scheduledResyncInterval` | The number in minutes to reschedule and poll data from the 3rd party system. When workload.kind is set to CronJob this parameter is required and should be in a format of a cron string | `null` |
| `sendRawDataExamples` | Enable sending raw data examples from the third party API to port for testing and managing the integration mapping | `true` |
| `podAnnotations` | Annotations to be added to the pod. | `{}` |
| `podSecurityContext` | Security context applied to the pod. | `{}` |
| `containerSecurityContext` | Security context applied to the container. | `{}` |
| `extraInitContainers` | Additional init containers to be added to the pod. | `[]` |
| `workload.kind` | Kind of the workload. Can be either Deployment or CronJob | `Deployment` |
| `workload.deployment.rolloutStrategy` | Deployment rollout strategy. | `Recreate` |
| `workload.cron.resyncTimeoutMinutes` | Timeout in minutes for the resync cron job. When set to 0 or null, the cron job will not have a timeout. | `60` |
| `securityContext` | Security context applied to the container. | `{}` |
| `resources` | Container resource requests and limits. | `{}` |
| `nodeSelector` | NodeSelector applied to the pod. | `{}` |
| `tolerations` | Tolerations applied to the pod. | `[]` |
| `affinity` | Affinity applied to the pod. | `{}` |
| `imageRegistry` | Image registry override. | `""` |
| `imagePullSecrets` | Image pull secrets | `[]` |
| `secret.name` | Secret object name. Can also be a list of strings when useExistingSecret is set to true, allowing the deployment to pull multiple secrets into the environment variables | `""` |
| `secret.name` | Secret object name. Can also be a list of strings when useExistingSecret is set to true, allowing the deployment to pull multiple secrets into the environment variables | `""` |
| `secret.useExistingSecret` | Enable this if you wish to create your own secret with credentials.<br>You must provide the following secrets:<br>`OCEAN__PORT__CLIENT_ID`<br>`OCEAN__PORT__CLIENT_SECRET`<br>Moreover, you need to provide sensitive configurations (required ones are **MUST**) for the selected integration:<br>Secret key format:`OCEAN__INTEGRATION__CONFIG__{{ $configName \| snakecase \| upper }}`<br>Example (if config name is `clusterConfMapping`): `OCEAN__INTEGRATION__CONFIG__CLUSTER_CONF_MAPPING` | `false` |
| `service.enabled` | Specifies whether the service is enabled or not. | `true` |
| `service.type` | Service type for the Port application. | `ClusterIP` |
Expand Down
36 changes: 28 additions & 8 deletions charts/port-ocean/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Common labels
*/}}
{{- define "port-ocean.labels" -}}
helm.sh/chart: {{ include "port-ocean.chart" . }}
{{ include "port-ocean.selectorLabels" . }}
{{- include "port-ocean.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -48,7 +48,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "port-ocean.selectorLabels" -}}
{{- define "port-ocean.selectorLabels" }}
app.kubernetes.io/name: {{ include "port-ocean.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Expand All @@ -61,57 +61,77 @@ Get prefix of ocean resource metadata.name
{{- end }}

{{/*
Get config map name per integration
Get config map name
*/}}
{{- define "port-ocean.configMapName" -}}
{{ $prefix:= include "port-ocean.metadataNamePrefix" . }}
{{- printf "%s-config" $prefix }}
{{- end }}

{{/*
Get secret name per integration
Get secret name
*/}}
{{- define "port-ocean.secretName" -}}
{{ $prefix:= include "port-ocean.metadataNamePrefix" . }}
{{- default (printf "%s-secret" $prefix) .Values.secret.name }}
{{- end }}

{{/*
Get ingress name per integration
Get ingress name
*/}}
{{- define "port-ocean.ingressName" -}}
{{ $prefix:= include "port-ocean.metadataNamePrefix" . }}
{{- printf "%s-ingress" $prefix }}
{{- end }}

{{/*
Get service name per integration
Get service name
*/}}
{{- define "port-ocean.serviceName" -}}
{{ $prefix:= include "port-ocean.metadataNamePrefix" . }}
{{- printf "%s-service" $prefix }}
{{- end }}

{{/*
Get container name per integration
Get container name
*/}}
{{- define "port-ocean.containerName" -}}
{{ $prefix:= include "port-ocean.metadataNamePrefix" . }}
{{- printf "%s-container" $prefix }}
{{- end }}

{{/*
Get deployment name per integration
Get deployment name
*/}}
{{- define "port-ocean.deploymentName" -}}
{{ $prefix:= include "port-ocean.metadataNamePrefix" . }}
{{- printf "%s-deployment" $prefix }}
{{- end }}

{{/*
Get cron job name
*/}}
{{- define "port-ocean.cronJobName" -}}
{{ $prefix:= include "port-ocean.metadataNamePrefix" . }}
{{- printf "%s-cron-job" $prefix }}
{{- end }}

{{/*
Get self signed cert secret name
*/}}
{{- define "port-ocean.selfSignedCertName" -}}
{{ $prefix:= include "port-ocean.metadataNamePrefix" . }}
{{- printf "%s-cert" $prefix }}
{{- end }}

{{- define "port-ocean.additionalSecrets" }}
{{- $secretsArray := list (include "port-ocean.secretName" .) }}
{{- /* If the secretName is already an array we don't wrap it in an array */}}
{{- if kindIs "slice" .Values.secret.name }}
{{- $secretsArray = .Values.secret.name }}
{{- end }}
{{- range $secretsArray }}
- secretRef:
name: {{ . }}
{{- end }}
{{- end }}
11 changes: 6 additions & 5 deletions charts/port-ocean/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{{- $eventListener := .Values.integration.eventListener }}
{{- if eq .Values.workload.kind "CronJob" }}
{{- $eventListener = dict "type" "ONCE" }}
{{- end}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "port-ocean.configMapName" . }}
data:
OCEAN__PORT__BASE_URL: {{ .Values.port.baseUrl | quote }}
OCEAN__INITIALIZE_PORT_RESOURCES: "{{ .Values.initializePortResources | default false }}"
{{- if .Values.scheduledResyncInterval }}
{{- if and .Values.scheduledResyncInterval (not (eq .Values.workload.kind "CronJob")) }}
OCEAN__SCHEDULED_RESYNC_INTERVAL: "{{ .Values.scheduledResyncInterval }}"
{{- end }}
{{- if .Values.clientTimeout }}
OCEAN__CLIENT_TIMEOUT: "{{ .Values.clientTimeout }}"
{{- end }}
OCEAN__SEND_RAW_DATA_EXAMPLES: "{{ .Values.sendRawDataExamples | default true }}"
OCEAN__EVENT_LISTENER: {{ .Values.integration.eventListener | toJson | quote }}
OCEAN__EVENT_LISTENER: {{ $eventListener | toJson | quote }}
{{- if .Values.integration.identifier }}
OCEAN__INTEGRATION__IDENTIFIER: "{{ .Values.integration.identifier }}"
{{- end }}
{{- if .Values.integration.type }}
OCEAN__INTEGRATION__TYPE: "{{ .Values.integration.type }}"
{{- end }}
{{- if .Values.integration.config }}
{{- range $key, $value := .Values.integration.config }}
OCEAN__INTEGRATION__CONFIG__{{ $key | snakecase | upper }}: {{ $value | quote }}
Expand Down
1 change: 1 addition & 0 deletions charts/port-ocean/templates/cron-job/_helpers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ define "port-ocean.cron.job-query-rbac-prefix" }}{{.Release.Name}}-job-query{{ end }}
Loading

0 comments on commit 21a3fb3

Please sign in to comment.