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

feat: Add support for providing cluster uuid to the agent #98

Merged
merged 5 commits into from
Dec 19, 2022
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
1 change: 1 addition & 0 deletions charts/prefect-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Prefect Agent application bundle
| agent.cloudApiConfig.apiKeySecret.name | string | `"prefect-api-key"` | prefect API secret name |
| agent.cloudApiConfig.cloudUrl | string | `"https://api.prefect.cloud/api"` | prefect cloud API url; the full URL is constructed as https://cloudUrl/accounts/accountId/workspaces/workspaceId |
| agent.cloudApiConfig.workspaceId | string | `""` | prefect workspace ID |
| agent.clusterUid | string | `""` | unique cluster identifier, if none is provided this value will be infered at time of helm install |
| agent.config.prefetchSeconds | int | `10` | when querying for runs, how many seconds in the future can they be scheduled |
| agent.config.queryInterval | int | `5` | how often the agent will query for runs |
| agent.config.workQueues | list | `["default"]` | names of prefect workqueues the agent will poll |
Expand Down
15 changes: 14 additions & 1 deletion charts/prefect-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Create the name of the service account to use

{{/*
agent.apiUrl:
Define API URL for workspace or for
Define API URL for cloud or orion agent install
*/}}
{{- define "agent.apiUrl" -}}
{{- if eq .Values.agent.apiConfig "cloud" }}
Expand All @@ -20,3 +20,16 @@ Create the name of the service account to use
{{- .Values.agent.orionApiConfig.apiUrl | quote }}
{{- end }}
{{- end }}

{{/*
agent.clusterUUID:
Define cluster UID either from user-defined UID or by doing a lookup at helm install time
*/}}
{{- define "agent.clusterUUID" -}}
{{- $defaultDict := dict "metadata" (dict "uid" "") -}}
{{- if .Values.agent.clusterUid }}
{{- .Values.agent.clusterUid | quote }}
{{- else }}
{{- (lookup "v1" "Namespace" "" "kube-system" | default $defaultDict).metadata.uid | quote }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/prefect-agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ spec:
value: {{ .Values.agent.config.queryInterval | quote }}
- name: PREFECT_API_URL
value: {{ template "agent.apiUrl" . }}
- name: PREFECT_KUBERNETES_CLUSTER_UID
value: {{ template "agent.clusterUUID" . }}
{{- if eq .Values.agent.apiConfig "cloud" }}
- name: PREFECT_API_KEY
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions charts/prefect-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ commonAnnotations: {}

## Deployment Configuration
agent:
# -- unique cluster identifier, if none is provided this value will be infered at time of helm install
clusterUid: ""

image:
# -- agent image repository
repository: prefecthq/prefect
Expand Down