Skip to content

Commit 8b39537

Browse files
authored
Add service-account-name option (#25)
1 parent c4a2495 commit 8b39537

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ Sets [memory request](https://kubernetes.io/docs/concepts/configuration/manage-c
213213

214214
Sets [memory limit](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) for the build container.
215215

216+
### `service-account-name` (optional, string)
217+
218+
Sets the [service account](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/) for the build container.
219+
220+
Default: `default`
221+
216222
### `use-agent-node-affinity` (optional, boolean)
217223

218224
If set to `true`, the spawned jobs will use the same [node affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/) and [tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) as the buildkite agent.

lib/job.jsonnet

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function(jobName, agentEnv={}, stepEnvFile='', patchFunc=identity) patchFunc({
7373
BUILDKITE_PLUGIN_K8S_RESOURCES_LIMIT_CPU: '',
7474
BUILDKITE_PLUGIN_K8S_RESOURCES_REQUEST_MEMORY: '',
7575
BUILDKITE_PLUGIN_K8S_RESOURCES_LIMIT_MEMORY: '',
76+
BUILDKITE_PLUGIN_K8S_SERVICE_ACCOUNT_NAME: 'default',
7677
BUILDKITE_PLUGIN_K8S_WORKDIR: std.join('/', [env.BUILDKITE_BUILD_PATH, buildSubPath]),
7778
BUILDKITE_PLUGIN_K8S_JOB_TTL_SECONDS_AFTER_FINISHED: '86400',
7879
} + agentEnv,
@@ -102,7 +103,7 @@ function(jobName, agentEnv={}, stepEnvFile='', patchFunc=identity) patchFunc({
102103
secretKeyRef: if env.BUILDKITE_PLUGIN_K8S_DEFAULT_SECRET_NAME != ''
103104
then {
104105
name: env.BUILDKITE_PLUGIN_K8S_DEFAULT_SECRET_NAME,
105-
key: 'buildkite-agent-token'
106+
key: 'buildkite-agent-token',
106107
}
107108
else {
108109
name: env.BUILDKITE_PLUGIN_K8S_SECRET_NAME,
@@ -187,7 +188,7 @@ function(jobName, agentEnv={}, stepEnvFile='', patchFunc=identity) patchFunc({
187188
{ key: 'ssh-key', path: 'ssh-key' },
188189
],
189190
},
190-
}]
191+
}],
191192
},
192193

193194
local gitCredentials = {
@@ -303,11 +304,12 @@ function(jobName, agentEnv={}, stepEnvFile='', patchFunc=identity) patchFunc({
303304
labels: labels,
304305
# Take all the same annotations as the job itself on the pod, but also add the istio inject false annotation
305306
# Istio gets in the way of many jobs
306-
annotations: annotations + {'sidecar.istio.io/inject': 'false'},
307+
annotations: annotations { 'sidecar.istio.io/inject': 'false' },
307308
},
308309
spec: {
309310
activeDeadlineSeconds: deadline,
310311
restartPolicy: 'Never',
312+
serviceAccountName: env.BUILDKITE_PLUGIN_K8S_SERVICE_ACCOUNT_NAME,
311313
initContainers: [
312314
{
313315
name: 'bootstrap',

plugin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ configuration:
6161
type: string
6262
resources-limit-memory:
6363
type: string
64+
service-account-name:
65+
type: string
6466
use-agent-node-affinity:
6567
type: boolean
6668
print-resulting-job-spec:

0 commit comments

Comments
 (0)