Skip to content

Commit

Permalink
Add Istio inject label
Browse files Browse the repository at this point in the history
Signed-off-by: Pierangelo Di Pilato <[email protected]>
  • Loading branch information
pierDipi committed Sep 26, 2024
1 parent 641cbb7 commit c7680af
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions config/post-install/storage-version-migrator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spec:
app.kubernetes.io/name: knative-eventing
app.kubernetes.io/component: storage-version-migration-job
app.kubernetes.io/version: devel
sidecar.istio.io/inject: "false"
annotations:
sidecar.istio.io/inject: "false"
spec:
Expand Down
15 changes: 13 additions & 2 deletions pkg/reconciler/apiserversource/resources/receive_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/intstr"
"knative.dev/eventing/pkg/adapter/v2"
"knative.dev/pkg/kmeta"
"knative.dev/pkg/ptr"
"knative.dev/pkg/system"

"knative.dev/eventing/pkg/adapter/v2"

"knative.dev/eventing/pkg/adapter/apiserver"
v1 "knative.dev/eventing/pkg/apis/sources/v1"
reconcilersource "knative.dev/eventing/pkg/reconciler/source"
Expand Down Expand Up @@ -80,7 +81,7 @@ func MakeReceiveAdapter(args *ReceiveAdapterArgs) (*appsv1.Deployment, error) {
Annotations: map[string]string{
"sidecar.istio.io/inject": "true",
},
Labels: args.Labels,
Labels: maybeAddKeyValue(args.Labels, "sidecar.istio.io/inject", "true"),
},
Spec: corev1.PodSpec{
NodeSelector: args.NodeSelector,
Expand Down Expand Up @@ -210,3 +211,13 @@ func makeEnv(args *ReceiveAdapterArgs) ([]corev1.EnvVar, error) {
}
return envs, nil
}

func maybeAddKeyValue(labels map[string]string, key string, value string) map[string]string {
if labels == nil {
return map[string]string{key: value}
}
if _, ok := labels[key]; !ok {
labels[key] = value
}
return labels
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ O2dgzikq8iSy1BlRsVw=
"sidecar.istio.io/inject": "true",
},
Labels: map[string]string{
"test-key1": "test-value1",
"test-key2": "test-value2",
"sidecar.istio.io/inject": "true",
"test-key1": "test-value1",
"test-key2": "test-value2",
},
},
Spec: corev1.PodSpec{
Expand Down
1 change: 1 addition & 0 deletions test/config/monitoring/monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ spec:
metadata:
labels:
app: zipkin
sidecar.istio.io/inject: "false"
annotations:
sidecar.istio.io/inject: "false"
spec:
Expand Down
4 changes: 4 additions & 0 deletions test/upgrade/prober/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

testlib "knative.dev/eventing/test/lib"
"knative.dev/eventing/test/lib/duck"
"knative.dev/eventing/test/lib/resources"
Expand Down Expand Up @@ -69,6 +70,9 @@ func (p *prober) forwarderKService(name, namespace string) *unstructured.Unstruc
"spec": map[string]interface{}{
"template": map[string]interface{}{
"metadata": map[string]interface{}{
"labels": map[string]interface{}{
"sidecar.istio.io/inject": "true",
},
"annotations": map[string]interface{}{
"sidecar.istio.io/inject": "true",
"sidecar.istio.io/rewriteAppHTTPProbers": "true",
Expand Down
3 changes: 2 additions & 1 deletion test/upgrade/prober/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ func (p *prober) createReceiverDeployment() *appsv1.Deployment {
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": receiver.Name,
"app": receiver.Name,
"sidecar.istio.io/inject": "true",
},
Annotations: map[string]string{
"sidecar.istio.io/inject": "true",
Expand Down
3 changes: 2 additions & 1 deletion test/upgrade/prober/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (p *prober) deploySender() {
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": sender.Name,
"app": sender.Name,
"sidecar.istio.io/inject": "true",
},
Annotations: map[string]string{
"sidecar.istio.io/inject": "true",
Expand Down
3 changes: 2 additions & 1 deletion test/upgrade/prober/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ func (p *prober) deployFetcher() *batchv1.Job {
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": fetcherName,
"app": fetcherName,
"sidecar.istio.io/inject": "true",
},
Annotations: map[string]string{
"sidecar.istio.io/inject": "true",
Expand Down

0 comments on commit c7680af

Please sign in to comment.