Skip to content

Commit

Permalink
tektoncd#7617 support k8s native sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
kgcarr committed Jun 14, 2024
1 parent 03c08e8 commit 013b021
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 46 deletions.
39 changes: 0 additions & 39 deletions examples/v1/taskruns/native-sidecar-ready.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions examples/v1/taskruns/sidecar-ready.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ spec:
- -c
- sleep 5 && touch /shared/ready
timeoutSeconds: 10
# Adding startup probe for k8s native sidecar support
# Readiness Probe is not honored for k8s native sidecar support
startupProbe:
exec:
command:
- sh
- -c
- sleep 5 && touch /shared/ready
timeoutSeconds: 10
volumeMounts:
- name: shared
mountPath: /shared
Expand Down
15 changes: 8 additions & 7 deletions pkg/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,8 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.Ta
// we are only concerned about major version 1 and if the minor is less than 29 then
// we need to do the current logic
svMinorInt, _ := strconv.Atoi(sv.Minor)
if sv.Major == "1" && svMinorInt < SidecarK8sMinorVersionCheck {
// Merge sidecar containers with step containers.
for _, sc := range sidecarContainers {
sc.Name = names.SimpleNameGenerator.RestrictLength(fmt.Sprintf("%v%v", sidecarPrefix, sc.Name))
mergedPodContainers = append(mergedPodContainers, sc)
}
} else {
svMajorInt, _ := strconv.Atoi(sv.Major)
if svMajorInt == 1 && svMinorInt >= SidecarK8sMinorVersionCheck {
// Add RestartPolicy and Merge into initContainer
for i := range sidecarContainers {
sc := &sidecarContainers[i]
Expand All @@ -454,6 +449,12 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.Ta
sc.Name = names.SimpleNameGenerator.RestrictLength(fmt.Sprintf("%v%v", sidecarPrefix, sc.Name))
mergedPodInitContainers = append(mergedPodInitContainers, *sc)
}
} else {
// Merge sidecar containers with step containers.
for _, sc := range sidecarContainers {
sc.Name = names.SimpleNameGenerator.RestrictLength(fmt.Sprintf("%v%v", sidecarPrefix, sc.Name))
mergedPodContainers = append(mergedPodContainers, sc)
}
}

var dnsPolicy corev1.DNSPolicy
Expand Down

0 comments on commit 013b021

Please sign in to comment.