-
Notifications
You must be signed in to change notification settings - Fork 111
/
helm-template.yaml
146 lines (143 loc) · 4.63 KB
/
helm-template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright 2020 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: deploy-helm-chart
spec:
params:
- name: namespace
description: Namespace to deploy to in the target cluster
- name: chartName
description: The name of the chart to be deployed
- name: chartVersion
description: The version of the chart to be deployed
default: latest
- name: chartRepo
description: The repo from where to install the chart
default: https://kubernetes-charts.storage.googleapis.com/
- name: chartParams
description: A comma separated list of key/values
default: ""
- name: preDeployResources
description: >-
Some charts require resources to be deployed firt, usually CRDs.
When provided this should be the URL to a YAML file with resources.
default: ""
workspaces:
- name: targetCluster
description: kubeconfig of the target Cluster/ServiceAccount
stepTemplate:
env:
- name: KUBECONFIG
value: $(workspaces.targetCluster.path)/kubeconfig
- name: CHART_NAME
value: $(params.chartName)
- name: CHART_VERSION
value: $(params.chartVersion)
- name: CHART_REPO
value: $(params.chartRepo)
- name: CHART_PARAMS
value: $(params.chartParams)
- name: NAMESPACE
value: $(params.namespace)
- name: PRE_DEPLOY_RESOURCES
value: $(params.preDeployResources)
steps:
- name: pre-deploy-from-url
image: gcr.io/tekton-releases/dogfooding/kubectl
script: |
#!/bin/sh
set -ex
# Check if we have something to be done
if [ "${PRE_DEPLOY_RESOURCES}" == "" ]; then
echo "No pre-deploy resources to deploy, continue"
exit 0
fi
# Apply the resources to the same namespace
kubectl apply \
--validate=false \
-n ${NAMESPACE} \
-f ${PRE_DEPLOY_RESOURCES}
- name: helm-deploy
image: alpine/helm:3.1.2
script: |
#!/bin/sh
set -ex
echo "Running install/upgrade"
echo "with ${CHART_PARAMS}"
helm upgrade \
--debug \
${CHART_NAME}-tektoncd-maintained \
${CHART_NAME} \
--install \
--version ${CHART_VERSION} \
--repo ${CHART_REPO} \
--namespace=${NAMESPACE} \
--set "${CHART_PARAMS}" \
--wait --timeout 5m
---
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: deploy-helm-chart
spec:
params:
- name: namespace
description: Namespace to deploy to in the target cluster
- name: clusterResource
description: Name of the cluster resource that points to the target cluster
- name: chartName
description: The name of the chart to be deployed
- name: chartVersion
description: The version of the chart to be deployed
default: latest
- name: chartRepo
description: The repo from where to install the chart
default: https://kubernetes-charts.storage.googleapis.com/
- name: chartDescription
description: Used for a descriptive TaskRun name
- name: chartParams
description: A comma separated list of key/values
default: ""
- name: preDeployResources
description: >-
Some charts require resources to be deployed first, usually CRDs.
When provided this should be the URL to a YAML file with resources.
default: ""
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: deploy-helm-$(tt.params.chartDescription)-
spec:
taskRef:
name: deploy-helm-chart
params:
- name: chartName
value: $(tt.params.chartName)
- name: chartVersion
value: $(tt.params.chartVersion)
- name: chartRepo
value: $(tt.params.chartRepo)
- name: chartParams
value: $(tt.params.chartParams)
- name: namespace
value: $(tt.params.namespace)
- name: preDeployResources
value: $(tt.params.preDeployResources)
workspaces:
- name: targetCluster
secret:
secretName: tektoncd-$(tt.params.clusterResource)