Skip to content

Commit

Permalink
Use istio.sidecar.inject label instead of annotation (knative#15522)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0ebef64)
  • Loading branch information
ReToCode committed Sep 26, 2024
1 parent 34e65a6 commit d7619a7
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 25 deletions.
3 changes: 1 addition & 2 deletions config/post-install/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ spec:
backoffLimit: 10
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
labels:
app: cleanup-migration-serving
app.kubernetes.io/name: knative-serving
app.kubernetes.io/component: cleanup-job
app.kubernetes.io/version: devel
sidecar.istio.io/inject: "false"
spec:
serviceAccountName: controller
restartPolicy: OnFailure
Expand Down
3 changes: 1 addition & 2 deletions config/post-install/default-domain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ metadata:
spec:
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
labels:
app: "default-domain"
app.kubernetes.io/component: default-domain-job
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: devel
sidecar.istio.io/inject: "false"
spec:
serviceAccountName: controller
containers:
Expand Down
3 changes: 1 addition & 2 deletions config/post-install/storage-version-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ spec:
backoffLimit: 10
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
labels:
app: storage-version-migration-serving
app.kubernetes.io/name: knative-serving
app.kubernetes.io/component: storage-version-migration-job
app.kubernetes.io/version: devel
sidecar.istio.io/inject: "false"
spec:
serviceAccountName: controller
restartPolicy: OnFailure
Expand Down
25 changes: 13 additions & 12 deletions pkg/reconciler/revision/resources/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"github.com/google/go-cmp/cmp"
"knative.dev/pkg/kmap"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -48,11 +49,11 @@ import (
)

var (
servingContainerName = "serving-container"
sidecarContainerName = "sidecar-container-1"
sidecarContainerName2 = "sidecar-container-2"
sidecarIstioInjectAnnotation = "sidecar.istio.io/inject"
defaultServingContainer = &corev1.Container{
servingContainerName = "serving-container"
sidecarContainerName = "sidecar-container-1"
sidecarContainerName2 = "sidecar-container-2"
sidecarIstioInjectLabel = "sidecar.istio.io/inject"
defaultServingContainer = &corev1.Container{
Name: servingContainerName,
Image: "busybox",
Ports: buildContainerPorts(v1.DefaultUserPort),
Expand Down Expand Up @@ -1786,16 +1787,16 @@ func TestMakeDeployment(t *testing.T) {
WithContainerStatuses([]v1.ContainerStatus{{
ImageDigest: "busybox@sha256:deadbeef",
}}),
withoutLabels, func(revision *v1.Revision) {
revision.Annotations = map[string]string{
sidecarIstioInjectAnnotation: "false",
func(revision *v1.Revision) {
revision.Labels = map[string]string{
sidecarIstioInjectLabel: "false",
}
}),
want: appsv1deployment(func(deploy *appsv1.Deployment) {
deploy.Annotations = kmeta.UnionMaps(deploy.Annotations,
map[string]string{sidecarIstioInjectAnnotation: "false"})
deploy.Spec.Template.Annotations = kmeta.UnionMaps(deploy.Spec.Template.Annotations,
map[string]string{sidecarIstioInjectAnnotation: "false"})
deploy.Labels = kmap.Union(deploy.Labels,
map[string]string{sidecarIstioInjectLabel: "false"})
deploy.Spec.Template.Labels = kmap.Union(deploy.Spec.Template.Labels,
map[string]string{sidecarIstioInjectLabel: "false"})
}),
}, {
name: "with progress-deadline override",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ spec:
ingress:
podTemplate:
metadata:
annotations:
sidecar.istio.io/inject: "true"
labels:
sidecar.istio.io/inject: "true"
# Istio adds the Challenge name for the value of this label.
# And the challenge name is sometimes more than 63 characters.
# So we override this label with empty value.
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ func TestProxyToHelloworld(t *testing.T, clients *test.Clients, helloworldURL *u

serviceOptions := []rtesting.ServiceOption{
rtesting.WithEnv(envVars...),
rtesting.WithConfigAnnotations(map[string]string{
"sidecar.istio.io/inject": strconv.FormatBool(inject),
}),
rtesting.WithServiceLabel("sidecar.istio.io/inject", strconv.FormatBool(inject)),
}

resources, err := v1test.CreateServiceReady(t, clients, &names, serviceOptions...)
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/service_to_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ func testSvcToSvcCallViaActivator(t *testing.T, clients *test.Clients, injectA b
withInternalVisibility := rtesting.WithServiceLabel(
netapi.VisibilityLabelKey, serving.VisibilityClusterLocal)

withIstioSidecarInject := rtesting.WithServiceLabel("sidecar.istio.io/inject", strconv.FormatBool(injectB))

test.EnsureTearDown(t, clients, &testNames)

resources, err := v1test.CreateServiceReady(t, clients, &testNames,
rtesting.WithConfigAnnotations(map[string]string{
autoscaling.TargetBurstCapacityKey: "-1",
"sidecar.istio.io/inject": strconv.FormatBool(injectB),
}), withInternalVisibility)
}), withInternalVisibility, withIstioSidecarInject)
if err != nil {
t.Fatal("Failed to create a service:", err)
}
Expand Down

0 comments on commit d7619a7

Please sign in to comment.