Skip to content

Commit

Permalink
Mount the Kaniko persistent volume in the build pod
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti authored and lburgazzoli committed Apr 5, 2019
1 parent 173b643 commit 9cf1dbb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/controller/build/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,34 @@ func (action *scheduleAction) Handle(ctx context.Context, build *v1alpha1.Build)
}

func newBuildPod(build *v1alpha1.Build) *corev1.Pod {
var volumes []corev1.Volume
var volumeMounts []corev1.VolumeMount
// Mount persistent volume used to coordinate build output with Kaniko cache and image build input
if build.Spec.Platform.Build.PublishStrategy == v1alpha1.IntegrationPlatformBuildPublishStrategyKaniko {
volumes = []corev1.Volume{
{
Name: "camel-k-builder",
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: build.Spec.Platform.Build.PersistentVolumeClaim,
},
},
},
}
volumeMounts = []corev1.VolumeMount{
{
Name: "camel-k-builder",
MountPath: build.Spec.BuildDir,
},
}
}

// The pod will be scheduled to nodes that are selected by the persistent volume
// node affinity spec, if any, as provisioned by the persistent volume claim storage
// class provisioner.
// See:
// - https://kubernetes.io/docs/concepts/storage/persistent-volumes/#node-affinity
// - https://kubernetes.io/docs/concepts/storage/volumes/#local
pod := &corev1.Pod{
TypeMeta: metav1.TypeMeta{
APIVersion: corev1.SchemeGroupVersion.String(),
Expand All @@ -122,9 +150,11 @@ func newBuildPod(build *v1alpha1.Build) *corev1.Pod {
build.Namespace,
build.Name,
},
VolumeMounts: volumeMounts,
},
},
RestartPolicy: corev1.RestartPolicyNever,
Volumes: volumes,
},
}

Expand Down

0 comments on commit 9cf1dbb

Please sign in to comment.