mirror of
https://github.com/tektoncd/catalog.git
synced 2024-11-24 06:15:46 +00:00
This Task
can be used to install/upgrade a helm chart into a Kubernetes/OpenShift Cluster.
Signed-off-by: Florian Hopfensperger <florian.hopfensperger@de.ibm.com>
This commit is contained in:
parent
4ce31b6c8d
commit
5bcf9a096f
5
helm/OWNERS
Normal file
5
helm/OWNERS
Normal file
@ -0,0 +1,5 @@
|
||||
approvers:
|
||||
- fhopfensperger
|
||||
|
||||
reviewers:
|
||||
- fhopfensperger
|
57
helm/README.md
Normal file
57
helm/README.md
Normal file
@ -0,0 +1,57 @@
|
||||
# Helm
|
||||
|
||||
This Task installs / upgrades a helm chart into your Kubernetes / OpenShift Cluster using [Helm](https://github.com/helm/helm).
|
||||
|
||||
## Install the Task
|
||||
|
||||
```
|
||||
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/helm/helm-upgrade.yaml
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- **CHARTS_DIR**: 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_VERSION**: The helm version which should be used (*default: latest*)
|
||||
|
||||
## Workspaces
|
||||
|
||||
* **source**: A `git`-type `PipelineResource` specifying the location of the helm chart.
|
||||
|
||||
|
||||
## 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
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: TaskRun
|
||||
metadata:
|
||||
name: example-helm-upgrade
|
||||
spec:
|
||||
taskRef:
|
||||
name: helm-upgrade
|
||||
params:
|
||||
- name: CHARTS_DIR
|
||||
value: helm-sample-chart
|
||||
- name: RELEASE_VERSION
|
||||
value: v1.0.0
|
||||
- name: RELEASE_NAME
|
||||
value: helm-sample
|
||||
- name: OVERWRITE_VALUES
|
||||
value: "autoscaling.enabled=true,autoscaling.maxReplicas=3"
|
||||
workspaces:
|
||||
- name: source
|
||||
persistentVolumeClaim:
|
||||
claimName: my-source
|
||||
```
|
35
helm/helm-upgrade.yaml
Normal file
35
helm/helm-upgrade.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: helm-upgrade
|
||||
spec:
|
||||
params:
|
||||
- name: CHARTS_DIR
|
||||
description: The directory in source that contains the helm chart
|
||||
- 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_VERSION
|
||||
description: "Specify a specific helm version"
|
||||
default: "latest"
|
||||
workspaces:
|
||||
- name: source
|
||||
steps:
|
||||
- name: upgrade
|
||||
image: lachlanevenson/k8s-helm:$(inputs.params.HELM_VERSION)
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
echo current installed helm releases
|
||||
helm list --namespace "$(inputs.params.RELEASE_NAMESPACE)"
|
||||
|
||||
echo installing helm chart...
|
||||
helm upgrade --install --wait --namespace "$(inputs.params.RELEASE_NAMESPACE)" --version $(inputs.params.RELEASE_VERSION) $(inputs.params.RELEASE_NAME) $(inputs.params.CHARTS_DIR) --debug --set "$(inputs.params.OVERWRITE_VALUES)"
|
20
helm/task-run.yaml
Normal file
20
helm/task-run.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: TaskRun
|
||||
metadata:
|
||||
name: example-helm-upgrade
|
||||
spec:
|
||||
taskRef:
|
||||
name: helm-upgrade
|
||||
params:
|
||||
- name: CHARTS_DIR
|
||||
value: helm-sample-chart
|
||||
- name: RELEASE_VERSION
|
||||
value: v1.0.0
|
||||
- name: RELEASE_NAME
|
||||
value: helm-sample
|
||||
- name: OVERWRITE_VALUES
|
||||
value: "autoscaling.enabled=true,autoscaling.maxReplicas=3"
|
||||
workspaces:
|
||||
- name: source
|
||||
persistentVolumeClaim:
|
||||
claimName: helm-source-pvc
|
4
helm/tests/pre-apply-task-hook.sh
Executable file
4
helm/tests/pre-apply-task-hook.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Add git-clone
|
||||
kubectl -n ${tns} apply -f ./git/git-clone.yaml
|
11
helm/tests/resources.yaml
Normal file
11
helm/tests/resources.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: helm-source-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 200Mi
|
52
helm/tests/run.yaml
Normal file
52
helm/tests/run.yaml
Normal file
@ -0,0 +1,52 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Pipeline
|
||||
metadata:
|
||||
name: helm-upgrade-test-pipeline
|
||||
spec:
|
||||
workspaces:
|
||||
- name: shared-workspace
|
||||
tasks:
|
||||
- name: fetch-repository
|
||||
taskRef:
|
||||
name: git-clone
|
||||
workspaces:
|
||||
- name: output
|
||||
workspace: shared-workspace
|
||||
params:
|
||||
- name: url
|
||||
value: https://github.com/fhopfensperger/tekton-helm-sample.git
|
||||
- name: subdirectory
|
||||
value: ""
|
||||
- name: deleteExisting
|
||||
value: "true"
|
||||
|
||||
- name: helm-upgrade
|
||||
taskRef:
|
||||
name: helm-upgrade
|
||||
runAfter:
|
||||
- fetch-repository
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: shared-workspace
|
||||
params:
|
||||
- name: CHARTS_DIR
|
||||
value: helm-sample-chart
|
||||
- name: RELEASE_VERSION
|
||||
value: v1.0.0
|
||||
- name: RELEASE_NAME
|
||||
value: helm-sample
|
||||
- name: OVERWRITE_VALUES
|
||||
value: "autoscaling.enabled=true,autoscaling.maxReplicas=3"
|
||||
---
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
name: helm-upgrade-test-pipeline-run
|
||||
spec:
|
||||
pipelineRef:
|
||||
name: helm-upgrade-test-pipeline
|
||||
workspaces:
|
||||
- name: shared-workspace
|
||||
persistentvolumeclaim:
|
||||
claimName: helm-source-pvc
|
Loading…
Reference in New Issue
Block a user