Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update environment variables passed to the prefect server chart #259

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions charts/prefect-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ postgresql+asyncpg://{username}:{password}@{hostname}/{database}?ssl=verify-ca
| server.containerSecurityContext.readOnlyRootFilesystem | bool | `true` | set server containers' security context readOnlyRootFilesystem |
| server.containerSecurityContext.runAsNonRoot | bool | `true` | set server containers' security context runAsNonRoot |
| server.containerSecurityContext.runAsUser | int | `1001` | set server containers' security context runAsUser |
| server.debug | bool | `false` | enable server debug mode |
| server.env | list | `[]` | array with environment variables to add to server nodes |
| server.extraContainers | list | `[]` | additional sidecar containers |
| server.extraEnvVarsCM | string | `""` | name of existing ConfigMap containing extra env vars to add to server nodes |
| server.extraEnvVarsSecret | string | `""` | name of existing Secret containing extra env vars to add to server nodes |
| server.extraVolumeMounts | list | `[]` | array with extra volumeMounts for the server pod |
| server.extraVolumes | list | `[]` | array with extra volumes for the server pod |
| server.image.debug | bool | `false` | enable server image debug mode |
| server.image.prefectTag | string | `"2-latest"` | prefect image tag (immutable tags are recommended) |
| server.image.pullPolicy | string | `"IfNotPresent"` | server image pull policy |
| server.image.pullSecrets | list | `[]` | server image pull secrets |
Expand All @@ -154,14 +154,16 @@ postgresql+asyncpg://{username}:{password}@{hostname}/{database}?ssl=verify-ca
| server.livenessProbe.config.successThreshold | int | `1` | The minimum consecutive successes required to consider the probe successful. |
| server.livenessProbe.config.timeoutSeconds | int | `5` | The number of seconds to wait for a probe response before considering it as failed. |
| server.livenessProbe.enabled | bool | `false` | |
| server.loggingLevel | string | `"WARNING"` | |
| server.nodeSelector | object | `{}` | node labels for server pods assignment |
| server.podAnnotations | object | `{}` | extra annotations for server pod |
| server.podLabels | object | `{}` | extra labels for server pod |
| server.podSecurityContext.fsGroup | int | `1001` | set server pod's security context fsGroup |
| server.podSecurityContext.runAsNonRoot | bool | `true` | set server pod's security context runAsNonRoot |
| server.podSecurityContext.runAsUser | int | `1001` | set server pod's security context runAsUser |
| server.prefectApiHost | string | `"0.0.0.0"` | sets PREFECT_SERVER_API_HOST |
| server.prefectApiUrl | string | `"http://localhost:4200/api"` | sets PREFECT_API_URL |
| server.priorityClassName | string | `""` | priority class name to use for the server pods; if the priority class is empty or doesn't exist, the server pods are scheduled without a priority class |
| server.publicApiUrl | string | `"http://localhost:4200/api"` | sets PREFECT_UI_API_URL; should be publicly accessible API URL |
| server.readinessProbe.config.failureThreshold | int | `3` | The number of consecutive failures allowed before considering the probe as failed. |
| server.readinessProbe.config.initialDelaySeconds | int | `10` | The number of seconds to wait before starting the first probe. |
| server.readinessProbe.config.periodSeconds | int | `10` | The number of seconds to wait between consecutive probes. |
Expand All @@ -172,12 +174,15 @@ postgresql+asyncpg://{username}:{password}@{hostname}/{database}?ssl=verify-ca
| server.resources.limits | object | `{}` | the requested limits for the server container |
| server.resources.requests | object | `{}` | the requested resources for the server container |
| server.tolerations | list | `[]` | tolerations for server pods assignment |
| server.uiConfig.enabled | bool | `true` | set PREFECT_UI_ENABLED; enable the UI on the server |
| server.uiConfig.prefectUiApiUrl | string | `""` | sets PREFECT_UI_API_URL |
| server.uiConfig.prefectUiUrl | string | `""` | sets PREFECT_UI_URL |
| service.annotations | object | `{}` | |
| service.clusterIP | string | `""` | service Cluster IP |
| service.externalTrafficPolicy | string | `"Cluster"` | service external traffic policy |
| service.nodePort | string | `""` | service port if defining service as type nodeport |
| service.port | int | `4200` | service port |
| service.targetPort | int | `4200` | target port of the server pod |
| service.targetPort | int | `4200` | target port of the server pod; also sets PREFECT_SERVER_API_PORT |
| service.type | string | `"ClusterIP"` | service type |
| serviceAccount.annotations | object | `{}` | additional service account annotations (evaluated as a template) |
| serviceAccount.create | bool | `true` | specifies whether a ServiceAccount should be created |
Expand Down
2 changes: 1 addition & 1 deletion charts/prefect-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.host.hostname }
Run the following command to port-forward the UI to your localhost:
$ kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ template "common.names.fullname" . }} {{ .Values.service.targetPort }}:{{ .Values.service.port }}

Visit http://localhost:4200 to use Prefect!
Visit {{ include "server.uiUrl" . }} to use Prefect!
{{- end }}
8 changes: 8 additions & 0 deletions charts/prefect-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ Create the name of the service account to use
{{- printf "%s-%s" $name "postgresql-connection" -}}
{{- end -}}
{{- end -}}

{{- define "server.uiUrl" -}}
{{- if .Values.server.uiConfig.prefectUiUrl -}}
{{- .Values.server.uiConfig.prefectUiUrl -}}
{{- else -}}
{{- printf "%s" (replace "/api" "" .Values.server.prefectApiUrl) -}}
{{- end -}}
{{- end -}}
24 changes: 17 additions & 7 deletions charts/prefect-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ spec:
- prefect
- server
- start
- --host
- 0.0.0.0
- --log-level
- WARNING
Comment on lines -67 to -70
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these values aren't changing, but are properly exposed to the end user now.

- --port
- {{ .Values.service.targetPort | quote }}
workingDir: /home/prefect
Expand All @@ -76,11 +72,25 @@ spec:
env:
- name: HOME
value: /home/prefect
- name: PREFECT_API_URL
value: {{ .Values.server.prefectApiUrl | quote }}
Comment on lines +75 to +76
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were not previously setting this, which was incorrect behavior. All other URLs are inferred from this, so it needs to be set.

- name: PREFECT_DEBUG_MODE
value: {{ .Values.server.image.debug | quote }}
{{- if .Values.server.publicApiUrl }}
value: {{ .Values.server.debug | quote }}
- name: PREFECT_LOGGING_SERVER_LEVEL
value: {{ .Values.server.loggingLevel | quote }}
- name: PREFECT_SERVER_API_HOST
value: {{ .Values.server.prefectApiHost | quote }}
- name: PREFECT_SERVER_API_PORT
value: {{ .Values.service.targetPort | quote }}
Comment on lines +78 to +84
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were already being inferred or set elsewhere, so explicitly setting them here now

- name: PREFECT_UI_ENABLED
value: {{ .Values.server.uiConfig.enabled | quote }}
Comment on lines +85 to +86
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here, this is the default behavior

{{- if .Values.server.uiConfig.prefectUiApiUrl }}
- name: PREFECT_UI_API_URL
value: {{ .Values.server.publicApiUrl | quote }}
value: {{ .Values.server.uiConfig.prefectUiApiUrl | quote }}
{{- end }}
{{- if .Values.server.uiConfig.prefectUiUrl }}
- name: PREFECT_UI_URL
value: {{ .Values.server.uiConfig.prefectUiUrl | quote }}
Comment on lines +87 to +93
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these values are only necessary if the endpoint for the UI is different than the URL set in the prefectApiUrl parameter

{{- end }}
{{- if .Values.postgresql.enabled }}
- name: PREFECT_API_DATABASE_CONNECTION_URL
Expand Down
56 changes: 47 additions & 9 deletions charts/prefect-server/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@
"items": {
"type": "string"
}
},
"debug": {
"type": "boolean",
"title": "Debug",
"description": "server image debug mode",
"form": true
}
}
},
Expand All @@ -87,12 +81,56 @@
"description": "priority class name to use for the server pods; if the priority class is empty or doesn't exist, the server pods are scheduled without a priority class",
"form": true
},
"publicApiUrl": {
"debug": {
"type": "boolean",
"title": "Debug",
"description": "server debug mode",
"form": true
},
"loggingLevel": {
"type": "string",
"title": "Logging Level",
"description": "sets PREFECT_LOGGING_SERVER_LEVEL",
"form": true
},
"prefectApiUrl": {
"type": "string",
"title": "Public API URL",
"description": "sets PREFECT_UI_API_URL; should be publicly accessible API URL",
"title": "Prefect API URL",
"description": "sets PREFECT_API_URL",
"form": true
},
"prefectApiHost": {
"type": "string",
"title": "Prefect API Host",
"description": "sets PREFECT_SERVER_API_HOST",
"form": true
},
"uiConfig": {
"type": "object",
"title": "UI Config",
"description": "Prefect UI Config",
"form": true,
"properties": {
"enabled": {
"type": "boolean",
"title": "Enable Prefect UI",
"description": "set PREFECT_UI_ENABLED; enable the UI on the server",
"form": true
},
"prefectUiApiUrl": {
"type": "string",
"title": "Prefect API URL",
"description": "sets PREFECT_UI_API_URL",
"form": true
},
"prefectUiUrl": {
"type": "string",
"title": "Prefect UI URL",
"description": "sets PREFECT_UI_URL",
"form": true
}
}
},
"env": {
"type": "array",
"title": "Environment Variables",
Expand Down
31 changes: 24 additions & 7 deletions charts/prefect-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,38 @@ server:
## - myRegistryKeySecretName
# -- server image pull secrets
pullSecrets: []
# -- enable server image debug mode
debug: false

# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass
# -- priority class name to use for the server pods; if the priority class is empty or doesn't exist, the server pods are scheduled without a priority class
priorityClassName: ""

# -- sets PREFECT_UI_API_URL; should be publicly accessible API URL
publicApiUrl: http://localhost:4200/api
# -- enable server debug mode
debug: false

# sets PREFECT_LOGGING_SERVER_LEVEL
loggingLevel: WARNING

# -- sets PREFECT_API_URL
prefectApiUrl: http://localhost:4200/api

# -- sets PREFECT_SERVER_API_HOST
prefectApiHost: 0.0.0.0

## If you want to run the UI seperately from the server, you will need to set the UI-specific URLs below
uiConfig:
# -- set PREFECT_UI_ENABLED; enable the UI on the server
enabled: true
# -- sets PREFECT_UI_API_URL
prefectUiApiUrl: ""
# -- sets PREFECT_UI_URL
prefectUiUrl: ""

# see here for a full list of possible environment variables - https://docs.prefect.io/latest/api-ref/prefect/settings/
# -- array with environment variables to add to server nodes
env: []
## env:
## - name: PREFECT_LOGGING_SERVER_LEVEL
## value: WARNING
## - name: PREFECT_API_ENABLE_HTTP2
## value: false

# Autoscaling configuration
# requests MUST be specified if using an HPA, otherwise the HPA will not know when to trigger a scale event
Expand Down Expand Up @@ -167,7 +184,7 @@ service:
type: ClusterIP
# -- service port
port: 4200
# -- target port of the server pod
# -- target port of the server pod; also sets PREFECT_SERVER_API_PORT
targetPort: 4200
# -- service Cluster IP
clusterIP: ""
Expand Down
Loading