Skip to content

Commit

Permalink
Merge branch 'octopus-v1' into lm/add-mssql-subchart
Browse files Browse the repository at this point in the history
  • Loading branch information
liam-mackie authored Jul 29, 2024
2 parents 2910502 + 01d9138 commit 1bfbdb8
Show file tree
Hide file tree
Showing 38 changed files with 641 additions and 168 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-flowers-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kubernetes-agent": major
---

New values schema to allow installation of the agent as either an Octopus Deployment Target or Worker
5 changes: 5 additions & 0 deletions .changeset/empty-peas-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"octopus-deploy": minor
---

Add polling tentacle ingress support
5 changes: 5 additions & 0 deletions .changeset/modern-pumas-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"octopus-deploy": minor
---

Initial changeset for versioning Octopus Deploy chart
5 changes: 5 additions & 0 deletions .changeset/nice-tomatoes-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kubernetes-agent": minor
---

Added role for worker pods
4 changes: 3 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"kubernetes-agent": "1.7.0"
},
"changesets": [
"brave-files-explain"
"brave-files-explain",
"clean-flowers-hide",
"witty-mice-think"
]
}
2 changes: 1 addition & 1 deletion .changeset/witty-mice-think.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"kubernetes-agent": patch
---

Merge changes from 1.7.1 - 1.7.3 to latest
Merge changes from 1.7.1 - 1.10.0 to latest
30 changes: 22 additions & 8 deletions .github/workflows/create-versioning-pr.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
name: Version Kubernetes Agent chart
name: Version Charts

on:
push:
branches:
- main
- release/kubernetes-agent/v*
- release/octopus-deploy/v*
- octopus-v1
paths:
- charts/kubernetes-agent/**
- charts/octopus-deploy/**
- .github/workflows/create-versioning-pr.yaml

jobs:
publish:
runs-on: ubuntu-latest

# When a changesets generated Versioning PR is merged, we want to publish the version as a tag
if: ${{ startsWith(github.event.commits[0].message, 'Version Kubernetes Agent Chart') }}
if: ${{ startsWith(github.event.commits[0].message, 'Version Charts') }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -37,7 +40,7 @@ jobs:
runs-on: ubuntu-latest

# For all pushes that aren't creating a versioning commit
if: ${{ !startsWith(github.event.commits[0].message, 'Version Kubernetes Agent Chart') }}
if: ${{ !startsWith(github.event.commits[0].message, 'Version Charts') }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -71,13 +74,24 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
commit: 'Version Kubernetes Agent Chart'
title: 'Version Kubernetes Agent Chart'
commit: 'Version Charts'
title: 'Version Charts'
createGitHubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.CHANGESETS_GITHUB_TOKEN }}

- name: 'Update version in Octopus Deploy Chart.yaml'
run: |
version=$(jq -r .version charts/octopus-deploy/package.json)
version="$version" yq -i '.version = strenv(version)' charts/octopus-deploy/Chart.yaml
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add charts/octopus-deploy/Chart.yaml
git commit -m "Update chart version in charts/octopus-deploy/Chart.yaml"
if: steps.changesets.outputs.hasChangesets == 'true'


- name: 'Update version in Chart.yaml and pnpm-lock.yaml'
- name: 'Update version in Kubernetes Agent chart.yaml and pnpm-lock.yaml'
run: |
version=$(jq -r .version charts/kubernetes-agent/package.json)
version="$version" yq -i '.version = strenv(version)' charts/kubernetes-agent/Chart.yaml
Expand All @@ -89,15 +103,15 @@ jobs:
git commit -m "Update chart version in charts/kubernetes-agent/Chart.yaml and pnpm-lock.yaml"
if: steps.changesets.outputs.hasChangesets == 'true'

- name: 'Update version in test snapshots'
- name: 'Update version in Kubernetes Agent test snapshots'
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git
helm unittest -u charts/kubernetes-agent
git add charts/kubernetes-agent/tests/__snapshot__/*
git commit -m "Update chart version in Kubernetes agent test snapshots"
if: steps.changesets.outputs.hasChangesets == 'true'

- name: 'Update version in Readme'
- name: 'Update version in Kubernetes Agent Readme'
working-directory: charts/kubernetes-agent
run: |
npm run generate-agent-docs
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/kubernetes-agent-publish-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ jobs:
if [[ "${{steps.branch_names.outputs.branch_name}}" != "main" ]]
then
pre_release="-${{steps.branch_names.outputs.branch_name}}-$(date +'%Y%m%d%H%M%S')"
# underscores in branches make for illegal version-string, replace with "-"
cleansed_branch=`echo ${{steps.branch_names.outputs.branch_name}} | sed s/_/-/g`
pre_release="-${cleansed_branch}-$(date +'%Y%m%d%H%M%S')"
fi
full_version="$chart_version$pre_release"
Expand Down
82 changes: 67 additions & 15 deletions .github/workflows/octopus-publish-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,84 @@ name: Publish Octopus Deploy Chart

on:

# Allows you to run this workflow manually from the Actions tab
push:
branches:
- main
- release/octopus-deploy/v*

workflow_dispatch:
inputs:
octopus-version:
description: 'The SemVer version of Octopus to publish. e.g. 2022.4.20121'
required: true

jobs:
publish:
paths_filter:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.filter.outputs.octopus-deploy }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
octopus-deploy:
- charts/octopus-deploy/**
- .github/workflows/octopus-publish-chart.yml
test:
needs: paths_filter
if: needs.paths_filter.outputs.result == 'true'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 'v3.13.2'

- name: Login to DockerHub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | helm registry login registry-1.docker.io -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

version: 'v3.15.3'

- name: Run Helm unit tests
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git
helm unittest charts/octopus-deploy
- name: Login to GitHub container registry
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{github.actor}} --password-stdin

- name: Parse Chart config
uses: pietrobolcato/action-read-yaml@1.1.0
id: read_chart_yaml
with:
config: ${{ github.workspace }}/charts/kubernetes-agent/Chart.yaml

- name: Get branch names
id: branch_names
uses: OctopusDeploy/util-actions/current-branch-name@current-branch-name.0.1.0

- name: Generate chart version
id: version
shell: bash
run: |
chart_version="${{ steps.read_chart_yaml.outputs.version }}"
pre_release=""
if [[ "${{steps.branch_names.outputs.branch_name}}" != "main" ]]
then
# underscores in branches make for illegal version-string, replace with "-"
cleansed_branch=`echo ${{steps.branch_names.outputs.branch_name}} | sed s/_/-/g`
pre_release="-${cleansed_branch}-$(date +'%Y%m%d%H%M%S')"
fi
full_version="$chart_version$pre_release"
echo "CHART_VERSION=$full_version" >> $GITHUB_OUTPUT
- name: Package Chart
run: helm package --version '${{ inputs.octopus-version }}' --app-version '${{ inputs.octopus-version }}' 'charts/octopus-deploy'
run: helm package --version '${{ steps.version.outputs.CHART_VERSION }}' 'charts/octopus-deploy'

- name: Push Chart to DockerHub
run: helm push 'octopusdeploy-helm-${{ inputs.octopus-version }}.tgz' oci://registry-1.docker.io/octopusdeploy
- name: Push Chart
run: helm push "octopusdeploy-helm-${{ steps.version.outputs.CHART_VERSION }}.tgz" oci://ghcr.io/octopusdeploy


16 changes: 16 additions & 0 deletions charts/kubernetes-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# kubernetes-agent

## 2.0.0-alpha.1

### Major Changes

- 0e07367: New values schema to allow installation of the agent as either an Octopus Deployment Target or Worker

### Patch Changes

- 84f7f36: Merge changes from 1.7.1 - 1.10.0 to latest

## 2.0.0-alpha.0

### Major Changes

- 05fa04c: Creating Kubernetes Agent v2 alpha prerelease

## 1.10.0

### Minor Changes

- 7999cbb: Support configuring script pod resource requirements

## 1.9.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions charts/kubernetes-agent/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ maintainers:
email: "support@octopus.com"
url: "https://octopus.com"
type: application
version: "2.0.0-alpha.0"
version: "2.0.0-alpha.1"
# This version number should be the same as the agent.image.tag value as this is the primary application version
appVersion: "8.1.1890"
appVersion: "8.1.1925"
44 changes: 34 additions & 10 deletions charts/kubernetes-agent/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# kubernetes-agent

![Version: 2.0.0-alpha.0](https://img.shields.io/badge/Version-2.0.0--alpha.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 8.1.1890](https://img.shields.io/badge/AppVersion-8.1.1890-informational?style=flat-square) ![Octopus Deploy Version: 2024.2.6580+](https://img.shields.io/badge/Octopus_Deploy-2024.2.6580%2B-2F93E0?style=flat-square&logo=octopusdeploy&logoColor=%232F93E0&logoSize=auto)
![Version: 2.0.0-alpha.1](https://img.shields.io/badge/Version-2.0.0--alpha.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 8.1.1925](https://img.shields.io/badge/AppVersion-8.1.1925-informational?style=flat-square) ![Octopus Deploy Version: 2024.2.6580+](https://img.shields.io/badge/Octopus_Deploy-2024.2.6580%2B-2F93E0?style=flat-square&logo=octopusdeploy&logoColor=%232F93E0&logoSize=auto)

A Helm chart for the Octopus Kubernetes Agent

Expand All @@ -27,12 +27,12 @@ A Helm chart for the Octopus Kubernetes Agent
| agent.bearerToken | string | `""` | A JWT bearer token use to authenticate with the target Octopus Server |
| agent.certificate | string | `""` | A base64-encoded x509 certificate used to setup a trust between the agent and target Octopus Server |
| agent.debug.disableAutoPodCleanup | bool | `false` | Disables automatic pod cleanup |
| agent.defaultNamespace | string | `""` | The default Kubernetes namespace for deployments |
| agent.enableMetricsCapture | bool | `true` | True if events should be scraped and added to the metrics config map |
| agent.image | object | `{"pullPolicy":"IfNotPresent","repository":"octopusdeploy/kubernetes-agent-tentacle","tag":"8.1.1890"}` | The repository, pullPolicy & tag to use for the agent image |
| agent.image | object | `{"pullPolicy":"IfNotPresent","repository":"octopusdeploy/kubernetes-agent-tentacle","tag":"8.1.1925"}` | The repository, pullPolicy & tag to use for the agent image |
| agent.logLevel | string | `"Info"` | The log level of the agent. Logs are written to the pod logs as well as to file |
| agent.machinePolicyName | string | `""` | The machine policy to register the agent with |
| agent.metadata | object | `{"annotations":{},"labels":{}}` | Additional metadata to add to the agent pod & container |
| agent.name | string | `""` | The name of the agent |
| agent.pollingConnectionCount | int | `5` | The number of polling TCP connections to open with the target Octopus Server |
| agent.pollingProxy | object | `{"host":"","password":"","port":80,"username":""}` | The host, port, username and password of the proxy server to use for polling connections |
| agent.resources | object | `{"requests":{"cpu":"100m","memory":"150Mi"}}` | The resource limits and requests assigned to the agent container |
Expand All @@ -43,14 +43,37 @@ A Helm chart for the Octopus Kubernetes Agent
| agent.serverSubscriptionId | string | `""` | The subscription ID that is used to by the agent to identify itself with Octopus Server |
| agent.serverUrl | string | `""` | The URL of the target Octopus Server to register this agent with |
| agent.serviceAccount.annotations | object | `{}` | Annotations to add to the autogenerated service account |
| agent.serviceAccount.name | string | Generates a name based on `targetName` | The name of the service account for the agent pod |
| agent.serviceAccount.name | string | Generates a name based on `agent.name` | The name of the service account for the agent pod |
| agent.space | string | `"Default"` | The Space to register the agent in |
| agent.targetEnvironments | list | `[]` | The target environments to register the agent with |
| agent.targetName | string | `""` | The name of the deployment target |
| agent.targetRoles | list | `[]` | The target roles to register the agent with |
| agent.targetTenantTags | list | `[]` | The target tenant tags to register the agent with |
| agent.targetTenantedDeploymentParticipation | string | `"Untenanted"` | Can be `Untenanted`, `TenantedOrUntenanted` or `Tenanted`. |
| agent.targetTenants | list | `[]` | The target tenants to register the agent with |

### Agent as Deployment Target values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| agent.deploymentTarget.enabled | bool | `false` | Set to register the agent as a Deployment Target using the provided initial values |

### Agent as Deployment Target initial values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| agent.deploymentTarget.initial.defaultNamespace | string | `""` | The default Kubernetes namespace for deployments |
| agent.deploymentTarget.initial.environments | list | `[]` | The deployment target environments to register the agent with |
| agent.deploymentTarget.initial.tags | list | `[]` | The deployment target tags to register the agent with |
| agent.deploymentTarget.initial.tenantTags | list | `[]` | The deployment target tenant tags to register the agent with |
| agent.deploymentTarget.initial.tenantedDeploymentParticipation | string | `"Untenanted"` | Can be `Untenanted`, `TenantedOrUntenanted` or `Tenanted`. |
| agent.deploymentTarget.initial.tenants | list | `[]` | The deployment target tenants to register the agent with |

### Agent as Worker values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| agent.worker.enabled | bool | `false` | Set to register the agent as a Worker using the provided initial values |

### Agent as Worker initial values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| agent.worker.initial.workerPools | list | `[]` | The worker pools to associate with the worker |

### Persistence

Expand All @@ -71,6 +94,7 @@ A Helm chart for the Octopus Kubernetes Agent
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| scriptPods.disruptionBudgetEnabled | bool | `true` | If true, the script pods will be created with a disruption budget to prevent them from being evicted |
| scriptPods.resources | object | `{"requests":{"cpu":"25m","memory":"100Mi"}}` | The resource limits and requests assigned to script pod containers |
| scriptPods.serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| scriptPods.serviceAccount.clusterRole | object | `[{"apiGroups":["*"],"resources":["*"],"verbs":["*"]},{"nonResourceURLs":["*"],"verbs":["*"]}]` | if defined, overrides the default ClusterRole rules |
| scriptPods.serviceAccount.name | string | `""` | The name of the service account used for executing script pods |
Expand Down
2 changes: 1 addition & 1 deletion charts/kubernetes-agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kubernetes-agent",
"version": "2.0.0-alpha.0",
"version": "2.0.0-alpha.1",
"private": true,
"description": "The Octopus Kubernetes Agent",
"author": "Octopus Deploy Ptd Ltd",
Expand Down
11 changes: 10 additions & 1 deletion charts/kubernetes-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ Create the name of the pod cluster role for deleting pods
{{- printf "%s-delete-role" (include "kubernetes-agent.scriptPodServiceAccountFullName" .) }}
{{- end }}


{{/*
Create the name of the pod (namespaced) role for creating pods, and updating tentacle
*/}}
{{- define "kubernetes-agent.scriptPodWorkerRoleName" -}}
{{- printf "%s-worker-role" (include "kubernetes-agent.scriptPodServiceAccountFullName" .) }}
{{- end }}


{{/*
Create the name of the pod cluster role binding to use
*/}}
Expand Down Expand Up @@ -102,4 +111,4 @@ The name of the PersistentVolumeClaim to configure
{{- else }}
{{- include "nfs.pvcName" . }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/kubernetes-agent/templates/pod-rolebindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{{- $podClusterRoleName := include "kubernetes-agent.scriptPodClusterRoleName" . -}}
{{- $podDeleterClusterRoleName := include "kubernetes-agent.scriptPodDeleterClusterRoleName" . -}}

{{- if .Values.agent.deploymentTarget.enabled }}
{{- range $targetNamespace := $.Values.scriptPods.serviceAccount.targetNamespaces }}
---
apiVersion: rbac.authorization.k8s.io/v1
Expand All @@ -19,6 +20,7 @@ roleRef:
name: {{ $podClusterRoleName }}
apiGroup: rbac.authorization.k8s.io
{{- end -}}
{{- end -}}
{{- if and .Values.persistence.nfs.watchdog.enabled (not .Values.persistence.storageClassName)}}
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
Loading

0 comments on commit 1bfbdb8

Please sign in to comment.