Skip to content

Commit

Permalink
Add image-pull-secret option (#54)
Browse files Browse the repository at this point in the history
Added image-pull-secret option to specify an image pull secret for a job that uses an image in a private registry.
  • Loading branch information
clbx authored Feb 9, 2023
1 parent d733bfa commit 9a156ca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ Whether to always pull the latest image before running the command. Sets [imageP

Default: `false`

### ``image-pull-secret`` (optional, string)

The name of the secret that holds the credentials for a remote container registry.


### `command` (optional, array)

Sets the command for the container. Useful if the container image has an entrypoint, but requires extra arguments.
Expand Down
9 changes: 9 additions & 0 deletions lib/job.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function(jobName, agentEnv={}, stepEnvFile='', patchFunc=identity) patchFunc({
BUILDKITE_PLUGIN_K8S_AGENT_TOKEN_SECRET_KEY: 'buildkite-agent-token',
BUILDKITE_PLUGIN_K8S_INIT_IMAGE: 'embarkstudios/k8s-buildkite-agent@sha256:1d88791315ed6b0b49a64055bc71c5a9a0b1953e387f99d25299ed06ccea5dbd',
BUILDKITE_PLUGIN_K8S_ALWAYS_PULL: false,
BUILDKITE_PLUGIN_K8S_IMAGE_PULL_SECRET: '',
BUILDKITE_PLUGIN_K8S_BUILD_PATH_HOST_PATH: '',
BUILDKITE_PLUGIN_K8S_BUILD_PATH_PVC: '',
BUILDKITE_PLUGIN_K8S_GIT_MIRRORS_HOST_PATH: '',
Expand Down Expand Up @@ -273,6 +274,12 @@ function(jobName, agentEnv={}, stepEnvFile='', patchFunc=identity) patchFunc({

local deadline = std.parseInt(env.BUILDKITE_TIMEOUT) * 60,

local imagePullSecrets =
if env.BUILDKITE_PLUGIN_K8S_IMAGE_PULL_SECRET == '' then []
else [
{name: env.BUILDKITE_PLUGIN_K8S_IMAGE_PULL_SECRET},
],

apiVersion: 'batch/v1',
kind: 'Job',
metadata: {
Expand All @@ -297,6 +304,8 @@ function(jobName, agentEnv={}, stepEnvFile='', patchFunc=identity) patchFunc({
restartPolicy: 'Never',
serviceAccountName: env.BUILDKITE_PLUGIN_K8S_SERVICE_ACCOUNT_NAME,
initContainers: initContainers,
imagePullSecrets: imagePullSecrets,

containers: [
{
name: 'step',
Expand Down
2 changes: 2 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ configuration:
properties:
image:
type: string
image-pull-secret:
type: string
always-pull:
type: boolean
command:
Expand Down

0 comments on commit 9a156ca

Please sign in to comment.