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

[agent] chart overhaul #45

Merged
merged 34 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c41591e
initial
jamiezieziula Sep 19, 2022
6403248
adding rbac
jamiezieziula Sep 19, 2022
df08aab
Merge branch 'main' of github.com:PrefectHQ/prefect-helm into chart-o…
jamiezieziula Sep 19, 2022
403c64a
added q & removed unneeded values
jamiezieziula Sep 19, 2022
ba8c5fb
additional resources
jamiezieziula Sep 19, 2022
9836318
rename
jamiezieziula Sep 19, 2022
edf9a58
update workspace var
jamiezieziula Sep 19, 2022
bc8c872
test extra arg
jamiezieziula Sep 19, 2022
124104f
testing @param
jamiezieziula Sep 19, 2022
4f0587c
added descriptions
jamiezieziula Sep 19, 2022
8be56a7
remove unneeded comment
jamiezieziula Sep 19, 2022
ebecd9a
testing lint workflow
jamiezieziula Sep 19, 2022
23624f7
test with real key
jamiezieziula Sep 19, 2022
b909139
undu helper
jamiezieziula Sep 19, 2022
b8c0024
add namespace to secret creation
jamiezieziula Sep 19, 2022
7683822
passing ns arguement
jamiezieziula Sep 19, 2022
0538a78
update ns & remove default value
jamiezieziula Sep 19, 2022
bbc2827
introduce better logic for api url determination
jamiezieziula Sep 19, 2022
aae1888
different ns
jamiezieziula Sep 19, 2022
66f794d
minor adjustments
jamiezieziula Sep 19, 2022
52194d6
switching order within action
jamiezieziula Sep 19, 2022
40d02ec
testing different qorkqueue name
jamiezieziula Sep 19, 2022
13af691
testing inline
jamiezieziula Sep 19, 2022
fbe5e12
cli flag
jamiezieziula Sep 19, 2022
ed15531
updating wq name
jamiezieziula Sep 19, 2022
4312f44
fix pathing
jamiezieziula Sep 19, 2022
90ab3f7
other values
jamiezieziula Sep 19, 2022
b58fe85
testing specific linter
jamiezieziula Sep 19, 2022
b816b64
release label config
jamiezieziula Sep 19, 2022
109f4d2
remove if for kind cluster
jamiezieziula Sep 19, 2022
41f4d06
adding orion test
jamiezieziula Sep 19, 2022
e7a3d55
rmeove duplicate quote
jamiezieziula Sep 19, 2022
1d29ad5
removing containersecurity & adding default name
jamiezieziula Sep 19, 2022
194b8ba
add replica count
jamiezieziula Sep 21, 2022
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
8 changes: 8 additions & 0 deletions .github/linters/agent-ct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://github.com/helm/chart-testing#configuration
charts:
- charts/prefect-agent
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
helm-extra-args: --timeout 600s
namespace: prefect
release-label: prefect
6 changes: 2 additions & 4 deletions .github/linters/ct.yaml → .github/linters/orion-ct.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# See https://github.com/helm/chart-testing#configuration
remote: origin
target-branch: main
chart-dirs:
- charts
charts:
- charts/prefect-orion
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
helm-extra-args: --timeout 600s
39 changes: 39 additions & 0 deletions .github/workflows/agent-lint-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Lint and Test Prefect Agent Chart

on:
pull_request:
paths:
- .github/workflows/agent-lint-and-test.yaml
- .github/linters/agent-ct.yaml
- 'charts/prefect-agent/**'

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v3.3
with:
version: v3.9.2

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.3.0

- name: Run chart-testing (lint)
run: ct lint --config .github/linters/agent-ct.yaml

- name: Create kind cluster
uses: helm/kind-action@v1.3.0

- name: Create API Secret for Agent Chart
run: |
kubectl create ns prefect
kubectl create secret generic prefect-api-key --from-literal=key=${{ secrets.PREFECT_CLOUD_API_KEY }} -n prefect

- name: Run chart-testing (install)
run: ct install --config .github/linters/agent-ct.yaml --helm-extra-set-args "--set=agent.config.workQueueName=test-helm --set=agent.config.accountId=${{ secrets.PREFECT_CLOUD_ACCOUNT_ID }} --set=agent.config.workspaceId=${{ secrets.PREFECT_CLOUD_WORKSPACE_ID }}"
42 changes: 0 additions & 42 deletions .github/workflows/linting.yaml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/orion-lint-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint and Test Prefect Orion Chart

on:
pull_request:
paths:
- .github/workflows/orion-lint-and-test.yaml
- .github/linters/orion-ct.yaml
- 'charts/prefect-orion/**'

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v3.3
with:
version: v3.9.2

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.3.0

- name: Run chart-testing (lint)
run: ct lint --config .github/linters/orion-ct.yaml

- name: Create kind cluster
uses: helm/kind-action@v1.3.0

- name: Run chart-testing (install)
run: ct install --config .github/linters/orion-ct.yaml --helm-extra-set-args "--set=postgresql.auth.password=TESTING"
21 changes: 14 additions & 7 deletions charts/prefect-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
apiVersion: v2
name: prefect-agent
description: Prefect orion application bundle
type: application
appVersion: latest
dependencies:
- name: common
jawnsy marked this conversation as resolved.
Show resolved Hide resolved
repository: https://charts.bitnami.com/bitnami
tags:
- bitnami-common
version: 2.0.3
description: Prefect Agent application bundle
engine: gotpl
home: https://github.com/PrefectHQ
# This version is never actually shipped. github actions will replace it at build-time
# with the appropriate version
version: 1.0.0
appVersion: "latest"
maintainers:
- name: gabcoyne
email: george@prefect.io
- name: jamiezieziula
email: jamie@prefect.io
name: prefect-agent
sources:
- https://github.com/PrefectHQ/prefect-helm
type: application
# This version is never actually shipped. github actions will replace it at build-time
# with the appropriate version
version: 1.0.0
jawnsy marked this conversation as resolved.
Show resolved Hide resolved
63 changes: 39 additions & 24 deletions charts/prefect-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)

Prefect orion application bundle
Prefect Agent application bundle

**Homepage:** <https://github.com/PrefectHQ>

Expand All @@ -17,33 +17,48 @@ Prefect orion application bundle

* <https://github.com/PrefectHQ/prefect-helm>

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| https://charts.bitnami.com/bitnami | common | 2.0.3 |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| annotations | object | `{}` | |
| config.accountId | string | `""` | |
| config.apiKeySecret | object | `{"key":"","name":""}` | Prefect cloud API key |
| config.apiUrl | string | `"https://api.prefect.cloud"` | |
| config.commonLabels | object | `{}` | |
| config.debugEnabled | bool | `true` | |
| config.workQueueName | string | `"prd"` | |
| config.workspaceName | string | `""` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"prefecthq/prefect"` | |
| image.tag | string | `"2-latest"` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podLabels | object | `{}` | |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| tolerations | list | `[]` | |
| agent.affinity | object | `{}` | affinity for agent pods assignment |
| agent.config.accountId | string | `""` | prefect account ID |
| agent.config.apiKeySecret.key | string | `"key"` | prefect API secret key |
| agent.config.apiKeySecret.name | string | `"prefect-api-key"` | prefect API secret name |
| agent.config.apiUrl | string | `"https://api.prefect.cloud"` | prefect API url |
| agent.config.workQueueName | string | `""` | prefect workqueue name |
| agent.config.workspaceId | string | `""` | prefect workspace ID |
| agent.extraEnvVars | list | `[]` | array with extra environment variables to add to agent nodes |
| agent.extraEnvVarsCM | string | `""` | name of existing ConfigMap containing extra env vars to add to agent nodes |
| agent.extraEnvVarsSecret | string | `""` | name of existing Secret containing extra env vars to add to agent nodes |
| agent.image.debug | bool | `false` | enable agent image debug mode |
| agent.image.pullPolicy | string | `"IfNotPresent"` | agent image pull policy |
| agent.image.pullSecrets | list | `[]` | agent image pull secrets |
| agent.image.repository | string | `"prefecthq/prefect"` | agent image repository |
| agent.image.tag | string | `"2-latest"` | agent image tag (immutable tags are recommended) |
| agent.nodeSelector | object | `{}` | node labels for agent pods assignment |
| agent.podAnnotations | object | `{}` | extra annotations for agent pod |
| agent.podLabels | object | `{}` | extra labels for agent pod |
| agent.podSecurityContext.enabled | bool | `true` | enabled agent pods' security context |
| agent.podSecurityContext.fsGroup | int | `1001` | set agent pod's security context fsGroup |
| agent.replicaCount | int | `1` | number of agent replicas to deploy |
| agent.resources.limits | object | `{}` | the requested limits for the agent container |
| agent.resources.requests | object | `{}` | the requested resources for the agent container |
| agent.tolerations | list | `[]` | tolerations for agent pods assignment |
| commonAnnotations | object | `{}` | annotations to add to all deployed objects |
| commonLabels | object | `{}` | labels to add to all deployed objects |
| fullnameOverride | string | `"prefect-agent"` | fully override common.names.fullname |
| nameOverride | string | `""` | partially overrides common.names.name |
| namespaceOverride | string | `""` | fully override common.names.namespace |
| serviceAccount.annotations | object | `{}` | additional service account annotations (evaluated as a template) |
| serviceAccount.create | bool | `true` | specifies whether a ServiceAccount should be created |
| serviceAccount.name | string | `""` | the name of the ServiceAccount to use. if not set and create is true, a name is generated using the common.names.fullname template |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
2 changes: 1 addition & 1 deletion charts/prefect-agent/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1. Check Prefect agent connections in the prefect UI at {{ .Values.config.apiUrl }}
1. Check Prefect agent connections in the prefect UI at {{ .Values.agent.config.apiUrl }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't need to be in this PR, but should we have a more comprehensive notes file, since this is shown whenever helm install or helm upgrade finishes?

79 changes: 12 additions & 67 deletions charts/prefect-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,77 +1,22 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "prefect-agent.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 "prefect-agent.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 "prefect-agent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

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

{{/*
prefect-agent.apiUrl:
agent.apiUrl:
Define API URL for workspace or for
*/}}
{{- define "prefect-agent.apiUrl" -}}
{{- if ne .Values.config.apiUrl "https://api.prefect.cloud" }}
{{- .Values.config.apiUrl | quote }}
{{- define "agent.apiUrl" -}}
{{- if and .Values.agent.config.accountId .Values.agent.config.workspaceId }}
{{- printf "%s/api/accounts/%s/workspaces/%s" .Values.agent.config.apiUrl .Values.agent.config.accountId .Values.agent.config.workspaceId | quote }}
{{- else }}
{{- printf "%s/api/accounts/%s/workspaces/%s" .Values.config.apiUrl .Values.config.accountId .Values.config.workspaceName | quote }}
{{- .Values.agent.config.apiUrl | quote }}
{{- end }}
{{- end }}
49 changes: 0 additions & 49 deletions charts/prefect-agent/templates/agent/deployment.yaml

This file was deleted.

Loading