Skip to content

Commit

Permalink
fix apache#915: set right permissions on kaniko workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Oct 3, 2019
1 parent c6fe990 commit ea15c5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
15 changes: 15 additions & 0 deletions pkg/controller/build/schedule_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ func newBuildPod(build *v1alpha1.Build, operatorImage string) *corev1.Pod {
},
}

// In case the kaniko cache has not run, the /workspace dir needs to have the right permissions set
pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{
Name: "prepare-kaniko-workspace",
Image: "busybox",
ImagePullPolicy: corev1.PullIfNotPresent,
Command: []string{"/bin/sh", "-c"},
Args: []string{"chmod -R a+rwx /workspace"},
VolumeMounts: []corev1.VolumeMount{
{
Name: "camel-k-builder",
MountPath: "/workspace",
},
},
})

// Use affinity only when the operator is present in the namespaced
if build.Namespace == platform.GetOperatorNamespace() {
// Co-locate with the builder pod for sharing the host path volume as the current
Expand Down
7 changes: 2 additions & 5 deletions pkg/controller/integrationplatform/kaniko_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ func createKanikoCacheWarmerPod(ctx context.Context, client client.Client, platf
Name: "create-kaniko-cache",
Image: "busybox",
ImagePullPolicy: corev1.PullIfNotPresent,
Command: []string{
"mkdir",
"-p",
"/workspace/cache",
},
Command: []string{"/bin/sh", "-c"},
Args: []string{"mkdir -p /workspace/cache && chmod -R a+rwx /workspace"},
VolumeMounts: []corev1.VolumeMount{
{
Name: "camel-k-builder",
Expand Down

0 comments on commit ea15c5c

Please sign in to comment.