-
Notifications
You must be signed in to change notification settings - Fork 21
/
Dispatchfile
208 lines (175 loc) · 10.3 KB
/
Dispatchfile
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!mesosphere/dispatch-starlark:v0.6
# vi:syntax=python
load("github.com/mesosphere/cluster-claim-controller/starlark/claim@master", "make_kind_cluster", "fetch_kubeconfig", "cleanup")
load("github.com/mesosphere/dispatch-catalog/starlark/stable/[email protected]", "dindTask")
load("github.com/mesosphere/dispatch-catalog/starlark/stable/[email protected]", "git_resource")
load("github.com/mesosphere/dispatch-catalog/starlark/stable/[email protected]", "secret_var")
load("github.com/mesosphere/dispatch-catalog/starlark/stable/[email protected]", "push", "pull_request", "cron", "clean", "task_step_result", "storage_resource")
load("github.com/mesosphere/dispatch-tasks/bump_charts/bump_charts@master", "bump_charts")
git_clone_dirname = "kba-git-src"
kind_cluster_name = "kba-kind-cluster"
kind_install_cluster_name = "kba-install-cluster"
kind_upgrade_cluster_name = "kba-upgrade-cluster"
resource("artifacts", type="storage", params={
"type": "gcs",
"location": "s3://artifacts",
"dir": "yes"
}, secrets={
"BOTO_CONFIG": k8s.corev1.SecretKeySelector(key="boto", localObjectReference=k8s.corev1.LocalObjectReference(name="s3-config"))
})
git_resource(git_clone_dirname, url="$(context.git.url)", revision="$(context.git.commit)")
git_resource("ui-git", url="[email protected]:mesosphere/kommander.git", revision="v6.37.0")
kind_cluster = make_kind_cluster(kind_cluster_name, git_clone_dirname)
install_kind_cluster = make_kind_cluster(kind_install_cluster_name, git_clone_dirname)
upgrade_kind_cluster = make_kind_cluster(kind_upgrade_cluster_name, git_clone_dirname)
common_env = [
k8s.corev1.EnvVar(name="ADDON_TESTS_PER_ADDON_WAIT_DURATION", value="10m"),
k8s.corev1.EnvVar(name="ADDON_TESTS_SETUP_WAIT_DURATION", value="60m"),
k8s.corev1.EnvVar(name="AWS_ACCESS_KEY_ID", valueFrom=secret_var( "d2iq-dispatch-aws-creds", "AWS_ACCESS_KEY_ID")),
k8s.corev1.EnvVar(name="AWS_REGION", value="us-west-2"),
k8s.corev1.EnvVar(name="AWS_SECRET_ACCESS_KEY", valueFrom=secret_var( "d2iq-dispatch-aws-creds", "AWS_SECRET_ACCESS_KEY")),
k8s.corev1.EnvVar(name="DISPATCH_BUILD_NAME", value="$(context.build.name)"),
k8s.corev1.EnvVar(name="DISPATCH_CI", value="true"),
k8s.corev1.EnvVar(name="GIT_TERMINAL_PROMPT", value="1"),
k8s.corev1.EnvVar(name="GITHUB_TOKEN", valueFrom=secret_var("d2iq-dispatch-basic-auth", "password")),
k8s.corev1.EnvVar(name="GOPRIVATE", value="github.com/mesosphere"),
k8s.corev1.EnvVar(name="KONVOY_VERSION", value="v1.8.0"),
k8s.corev1.EnvVar(name="KUBEADDONS_ADDON_DELETE_DURATION", value="5m"),
k8s.corev1.EnvVar(name="SSH_KEY_BASE64", valueFrom=secret_var( "d2iq-dispatch-git-ssh-base64", "ssh-privatekey-base64")),
]
dindTask("lint-yaml",
inputs=[git_clone_dirname],
steps=[
k8s.corev1.Container(
name="fetch-branches",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
args=["git", "fetch", "origin"]
),
k8s.corev1.Container(
name="yamllint",
image="cytopia/yamllint:1.23@sha256:a16045dacb68f34a6e2a5c25e8175265105f48a8ee3033e0bdc36689e2911ff9",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
command=["yamllint", "--config-file", "test/yamllint.yaml", "."],
),
])
dindTask("test-install",
inputs=[git_clone_dirname],
deps=[install_kind_cluster],
steps=[
fetch_kubeconfig(kind_install_cluster_name, git_clone_dirname),
k8s.corev1.Container(
name="fetch-branches",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
args=["git", "fetch", "origin"]),
k8s.corev1.Container(
name="test-install",
image="mesosphere/kubeaddons-ci:dispatch@sha256:80a6f3c8775133b4ad2fab3d44ab4fbb4b541dbc03fcdb296b13f67611427d8c",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
command=["/entrypoint.sh", "make", "dispatch-test-install-upgrade"],
env= common_env + [
k8s.corev1.EnvVar(name="CLAIM_NAME", value=task_step_result(kind_install_cluster_name, "cluster-claim")),
k8s.corev1.EnvVar(name="KBA_TESTGROUP_TYPE", value="install"),
],
resources=k8s.corev1.ResourceRequirements(
requests={
"cpu": k8s.resource_quantity("1000m"),
"memory": k8s.resource_quantity("2Gi")}))
])
dindTask("test-upgrade",
inputs=[git_clone_dirname],
deps=[upgrade_kind_cluster],
steps=[
fetch_kubeconfig(kind_upgrade_cluster_name, git_clone_dirname),
k8s.corev1.Container(
name="fetch-branches",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
args=["git", "fetch", "origin"]),
k8s.corev1.Container(
name="test-upgrade",
image="mesosphere/kubeaddons-ci:dispatch@sha256:80a6f3c8775133b4ad2fab3d44ab4fbb4b541dbc03fcdb296b13f67611427d8c",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
command=["/entrypoint.sh", "make", "dispatch-test-install-upgrade"],
env= common_env + [
k8s.corev1.EnvVar(name="CLAIM_NAME", value=task_step_result(kind_upgrade_cluster_name, "cluster-claim")),
k8s.corev1.EnvVar(name="KBA_TESTGROUP_TYPE", value="upgrade"),
],
resources=k8s.corev1.ResourceRequirements(
requests={
"cpu": k8s.resource_quantity("1000m"),
"memory": k8s.resource_quantity("2Gi")}))
])
konvoy_artifacts_resource_name = "konvoy-artifacts-install"
konvoy_artifacts_resource = storage_resource(konvoy_artifacts_resource_name)
konvoy_artifacts_upgrade_name = "konvoy-artifacts-upgrade"
konvoy_artifacts_upgrade_resource = storage_resource(konvoy_artifacts_upgrade_name)
dindTask("test-aws-install-addons",
inputs=[git_clone_dirname],
outputs=[konvoy_artifacts_resource_name],
steps=[
k8s.corev1.Container(
name="fetch-branches",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
args=["git", "fetch", "origin"]),
k8s.corev1.Container(
name="test-addons",
image="mesosphere/kubeaddons-ci:dispatch@sha256:80a6f3c8775133b4ad2fab3d44ab4fbb4b541dbc03fcdb296b13f67611427d8c",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
command=["/entrypoint.sh", "make", "test-aws"],
env=common_env + [
k8s.corev1.EnvVar(name="ARTIFACTS_DIR", value="$(resources.outputs.{}.path)".format(
konvoy_artifacts_resource_name)),
k8s.corev1.EnvVar(name="KBA_TESTGROUP_TYPE", value="install"),
],
resources=k8s.corev1.ResourceRequirements(
requests={
"cpu": k8s.resource_quantity("1000m"),
"memory": k8s.resource_quantity("3Gi")},
limits={
"cpu": k8s.resource_quantity("8000m"),
"memory": k8s.resource_quantity("15Gi")}
)
)])
dindTask("test-aws-upgrade-addons",
inputs=[git_clone_dirname],
outputs=[konvoy_artifacts_upgrade_name],
steps=[
k8s.corev1.Container(
name="fetch-branches",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
args=["git", "fetch", "origin"]),
k8s.corev1.Container(
name="test-addons",
image="mesosphere/kubeaddons-ci:dispatch@sha256:80a6f3c8775133b4ad2fab3d44ab4fbb4b541dbc03fcdb296b13f67611427d8c",
workingDir="/workspace/{git_clone_dirname}/".format(git_clone_dirname=git_clone_dirname),
command=["/entrypoint.sh", "make", "test-aws"],
env=common_env + [
k8s.corev1.EnvVar(name="ARTIFACTS_DIR", value="$(resources.outputs.{}.path)".format(
konvoy_artifacts_upgrade_name)),
k8s.corev1.EnvVar(name="KBA_TESTGROUP_TYPE", value="upgrade"),
],
resources=k8s.corev1.ResourceRequirements(
requests={
"cpu": k8s.resource_quantity("1000m"),
"memory": k8s.resource_quantity("3Gi")
},
limits={
"cpu": k8s.resource_quantity("8000m"),
"memory": k8s.resource_quantity("15Gi")}
)
)])
clean_install_kind = cleanup(install_kind_cluster, "test-install", git_clone_dirname)
clean_upgrade_kind = cleanup(upgrade_kind_cluster, "test-upgrade", git_clone_dirname)
# Robot Actions
action(tasks=["lint-yaml"], on=pull_request())
action(tasks=["test-install", clean_install_kind], on=pull_request(paths=["!Dispatchfile"]))
action(tasks=["test-upgrade", clean_upgrade_kind], on=pull_request(paths=["!Dispatchfile"]))
action(tasks=["test-aws-install-addons"], on=pull_request(paths=["!Dispatchfile"]))
action(tasks=["test-aws-upgrade-addons"], on=pull_request(paths=["!Dispatchfile"]))
# Chatops Actions
action(tasks=["lint-yaml"], on=pull_request(chatops=["lint", "test"]))
action(tasks=["test-install", clean_install_kind], on=pull_request(chatops=["test-install"]))
action(tasks=["test-upgrade", clean_upgrade_kind], on=pull_request(chatops=["test-upgrade"]))
action(tasks=["test-install", clean_install_kind, "test-upgrade", clean_upgrade_kind], on=pull_request(chatops=["test-all"]))
# Cron Actions
# do_bump_charts = bump_charts(repo_name="kubernetes-base-addons", task_name="kba-bumps")
# action(name="bump-charts", on=cron(schedule="0 3 7,21 * *"), tasks=[do_bump_charts])