Skip to content
Open
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
67 changes: 67 additions & 0 deletions task/helm-upgrade-from-repo/0.4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Helm

These tasks will install / upgrade a helm chart into your Kubernetes / OpenShift Cluster using [Helm](https://github.com/helm/helm).

## Install the Task

Comment on lines +5 to +6
Copy link
Member

@vinamra28 vinamra28 Apr 2, 2025

Choose a reason for hiding this comment

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

can we please update this section or remove as I can see that there is another section which talks about the same thing?

Copy link
Author

Choose a reason for hiding this comment

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

this section is updated.
The following has been added for reference. because this README is recentry added.

https://github.com/tektoncd/catalog/blob/main/task/42crunch-api-security-audit/0.3/README.md?plain=1

## Install the Task
Install `helm-upgrade-from-repo` task:
```
kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/helm-upgrade-from-repo/0.4/raw
```

Install `helm-upgrade-from-repo` task:

```
kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/helm-upgrade-from-repo/0.4/raw
```

#### Workspaces

* **source**: A [Workspace](https://github.com/tektoncd/pipeline/blob/main/docs/workspaces.md) volume containing the helm chart.

### helm install / upgrade from repo

```
kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/helm-upgrade-from-repo/0.4/raw
```

#### Parameters

- **chart_name**: The directory in the source repository where the installable chart should be found.
- **release_version**: The version of the release (*default: v1.0.0*)
- **release_name**: The name of the release (*default: helm-release*)
- **release_namespace**: The namespace in which the release is to be installed (*default: ""*)
- **overwrite_values**: The values to be overwritten (*default: ""*)
- **helm_image**: The helm image which should be used (default: lachlanevenson/k8s-helm:v3.5.0)
- **upgrade_extra_params**: Extra parameters passed for the helm upgrade command (*default: ""*)

#### Platforms

The Task can be run on `linux/amd64`, `linux/s390x`, `linux/arm64` and `linux/ppc64le` platforms.

## Usage

### PipelineRun

An example `Pipeline` with a `PipelineRun` can be found in the subdirectory `tests`.

### TaskRun

This `TaskRun` runs the task to retrieve a Git repo and then installs/updates the helm chart that is in the Git repo.

```yaml
# example upgrade from repo
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: example-helm-upgrade-from-repo
spec:
taskRef:
name: helm-upgrade-from-repo
params:
- name: helm_repo
value: https://kubernetes-charts.storage.googleapis.com
- name: chart_name
value: stable/envoy
- name: release_version
value: v1.0.0
- name: release_name
value: helm-repo-sample
- name: overwrite_values
value: autoscaling.enabled=true,autoscaling.maxReplicas=3
```
54 changes: 54 additions & 0 deletions task/helm-upgrade-from-repo/0.4/helm-upgrade-from-repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This Task will do a helm upgrade based on the given helm repo and chart
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: helm-upgrade-from-repo
labels:
app.kubernetes.io/version: "0.4"
annotations:
tekton.dev/categories: Deployment
tekton.dev/pipelines.minVersion: "1.4.0"
tekton.dev/tags: helm
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
spec:
description: >-
These tasks will install / upgrade a helm chart into your Kubernetes /
OpenShift Cluster using Helm

params:
- name: helm_repo
description: "Specify a specific helm repo"
- name: chart_name
description: "Specify chart name that will be deployed"
- name: release_version
description: The helm release version in semantic versioning format
default: "v1.0.0"
- name: release_name
description: The helm release name
default: "helm-release"
- name: release_namespace
description: The helm release namespace
default: ""
- name: overwrite_values
description: "Specify the values you want to overwrite, comma separated: autoscaling.enabled=true,replicas=1"
default: ""
- name: helm_image
description: "Specify a specific helm image"
default: "docker.io/lachlanevenson/k8s-helm@sha256:0a068ae407e21d1836c6a89a1e9e81af1e55fa56890998e33d5caabdbb51e77b" # tag: v3.10.2
- name: upgrade_extra_params
description: "Extra parameters passed for the helm upgrade command"
default: ""
steps:
- name: upgrade-from-repo
image: $(params.helm_image)
script: |
echo current installed helm releases
helm list --namespace "$(params.release_namespace)"
echo parsing helms repo name...
REPO=`echo "$(params.chart_name)" | cut -d "/" -f 1`
echo adding helm repo...
helm repo add $REPO "$(params.helm_repo)"
echo adding updating repo...
helm repo update
echo installing helm chart...
helm upgrade --wait --install --namespace "$(params.release_namespace)" $(params.release_name) $(params.chart_name) --debug --set "$(params.overwrite_values)" $(params.upgrade_extra_params)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: example-helm-upgrade-from-repo
spec:
taskRef:
name: helm-upgrade-from-repo
params:
- name: helm_repo
value: https://charts.helm.sh/stable
- name: chart_name
value: stable/envoy
- name: release_version
value: v1.0.0
- name: release_name
value: helm-repo-sample
- name: overwrite_values
value: autoscaling.enabled=true,autoscaling.maxReplicas=3
7 changes: 7 additions & 0 deletions task/helm-upgrade-from-repo/0.4/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Add service account
kubectl -n ${tns} create serviceaccount helm-pipeline-run-sa

# Add edit role to service account
kubectl -n ${tns} create rolebinding helm-pipeline-run-sa-edit --clusterrole edit --serviceaccount ${tns}:helm-pipeline-run-sa -o yaml --dry-run=client | kubectl apply -f -
32 changes: 32 additions & 0 deletions task/helm-upgrade-from-repo/0.4/tests/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: helm-upgrade-test-pipeline
spec:
tasks:
- name: helm-upgrade-from-repo
taskRef:
name: helm-upgrade-from-repo
params:
- name: helm_repo
value: https://dunefro.github.io/sample-charts/
- name: chart_name
value: sample-charts/sample-nginx
- name: release_version
value: v1.0.0
- name: release_name
value: helm-repo-sample
- name: overwrite_values
value: autoscaling.enabled=false,autoscaling.maxReplicas=3
- name: upgrade_extra_params
value: "--force"
---
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: helm-upgrade-test-pipeline-run
spec:
serviceAccountName: helm-pipeline-run-sa
pipelineRef:
name: helm-upgrade-test-pipeline