Skip to content

Commit a024d0f

Browse files
authored
Ensure istioNativeSidecars for all buildless git functions (#1770)
1 parent 9451773 commit a024d0f

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

components/buildless-serverless/internal/controller/resources/deployment.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const (
2121
istioConfigLabelKey = "proxy.istio.io/config"
2222
istioEnableHoldUntilProxyStartLabelValue = "{ \"holdApplicationUntilProxyStarts\": true }"
2323
istioNativeSidecarLabelKey = "sidecar.istio.io/nativeSidecar"
24-
istioInjectSidecarLabelKey = "sidecar.istio.io/inject"
2524
)
2625

2726
type Deployment struct {
@@ -110,13 +109,11 @@ func (d *Deployment) currentAnnotationsWithoutPreviousFunctionAnnotations() map[
110109
return result
111110
}
112111

112+
// allow istio to inject native sidecar (istio-proxy as init container)
113+
// this is required for init container of git sourced functions to fetch source from git repository
113114
func (d *Deployment) annotationsRequiredByIstio() map[string]string {
114115
result := make(map[string]string)
115-
116-
if d.function.HasGitSources() && d.function.HasLabel(istioInjectSidecarLabelKey, "true") {
117-
result[istioNativeSidecarLabelKey] = "true"
118-
}
119-
116+
result[istioNativeSidecarLabelKey] = "true"
120117
return result
121118
}
122119

components/buildless-serverless/internal/controller/resources/deployment_test.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,16 @@ func TestDeployment_construct(t *testing.T) {
137137

138138
require.NotNil(t, r)
139139
require.Equal(t, map[string]string{
140-
"proxy.istio.io/config": "{ \"holdApplicationUntilProxyStarts\": true }",
141-
"leavitt": "hopeful",
142-
"pike": "tender",
143-
"thompson": "exciting",
140+
"proxy.istio.io/config": "{ \"holdApplicationUntilProxyStarts\": true }",
141+
"leavitt": "hopeful",
142+
"pike": "tender",
143+
"thompson": "exciting",
144+
"sidecar.istio.io/nativeSidecar": "true",
144145
}, r.Spec.Template.ObjectMeta.Annotations)
145146
})
146-
t.Run("enable native sidecar when istio is enabled and function has git repo", func(t *testing.T) {
147+
t.Run("enable native sidecar", func(t *testing.T) {
147148
d := minimalDeployment()
148149

149-
d.function.Spec.Source = serverlessv1alpha2.Source{
150-
GitRepository: &serverlessv1alpha2.GitRepositorySource{
151-
URL: "wonderful-germain",
152-
Repository: serverlessv1alpha2.Repository{
153-
BaseDir: "recursing-mcnulty",
154-
Reference: "epic-mendel"}}}
155-
156-
d.function.Spec.Labels = map[string]string{
157-
"sidecar.istio.io/inject": "true",
158-
}
159-
160150
r := d.construct()
161151

162152
require.NotNil(t, r)

0 commit comments

Comments
 (0)