Skip to content

Commit cbeddf0

Browse files
afrittolitekton-robot
authored andcommittedOct 11, 2019
Use a local registry in build-push-kaniko
This is a first step in making our E2E tests more portable and less dependent on resources outside of the k8s cluster they run into. This changes the build-push-kaniko taskrun example. There is a lot of infra setup required to make sure that the service account used by test is able to push to a registry. The test script replaces the image URL in the resource with the content of the KO_DOCKER_REPO environment variable. If that is a gcr.io url then the service account must be setup for access to it. The updated version runs a local registry as a sidecar in the pod. The task now can push to localhost:5000. The port is not exposed outside of the pod so there is no risk of interference with other tests. Partially fixes tektoncd#1372
1 parent ab2482a commit cbeddf0

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed
 

‎examples/taskruns/build-push-kaniko.yaml

+4-21
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,7 @@ spec:
66
type: image
77
params:
88
- name: url
9-
value: gcr.io/christiewilson-catfactory/leeroy-web # Replace this URL with $KO_DOCKER_REPO
10-
---
11-
# This demo modifies the cluster (deploys to it) you must use a service
12-
# account with permission to admin the cluster (or make your default user an admin
13-
# of the `default` namespace with default-cluster-admin.
14-
apiVersion: rbac.authorization.k8s.io/v1
15-
kind: ClusterRoleBinding
16-
metadata:
17-
name: default-cluster-admin
18-
subjects:
19-
- kind: ServiceAccount
20-
name: default
21-
namespace: default
22-
roleRef:
23-
kind: ClusterRole
24-
name: cluster-admin
25-
apiGroup: rbac.authorization.k8s.io
9+
value: localhost:5000/leeroy-web
2610
---
2711
apiVersion: tekton.dev/v1alpha1
2812
kind: PipelineResource
@@ -60,16 +44,15 @@ spec:
6044
steps:
6145
- name: build-and-push
6246
image: gcr.io/kaniko-project/executor:v0.9.0
63-
# specifying DOCKER_CONFIG is required to allow kaniko to detect docker credential
64-
env:
65-
- name: "DOCKER_CONFIG"
66-
value: "/builder/home/.docker/"
6747
command:
6848
- /kaniko/executor
6949
args:
7050
- --dockerfile=$(inputs.params.pathToDockerFile)
7151
- --destination=$(outputs.resources.builtImage.url)
7252
- --context=$(inputs.params.pathToContext)
53+
sidecars:
54+
- image: registry
55+
name: registry
7356
---
7457
apiVersion: tekton.dev/v1alpha1
7558
kind: TaskRun

0 commit comments

Comments
 (0)
Please sign in to comment.