@@ -21,9 +21,6 @@ var _ = OSMDescribe("Ignore Namespaces",
21
21
func () {
22
22
Context ("Ignore Label" , func () {
23
23
const ignoreNs = "ignore"
24
- const monitorIgnoreNs = "mesh-ignore"
25
- const sidecarMonitorIgnoreNs = "sidecar-monitor-ignore"
26
- var ns []string = []string {ignoreNs , monitorIgnoreNs , sidecarMonitorIgnoreNs }
27
24
28
25
It ("Tests the ignore label on a namespace disables sidecar injection" , func () {
29
26
// Install OSM
@@ -32,17 +29,14 @@ var _ = OSMDescribe("Ignore Namespaces",
32
29
Expect (Td .InstallOSM (installOpts )).To (Succeed ())
33
30
34
31
// Create test NS in mesh with ignore label
35
- for _ , n := range ns {
36
- Expect (Td .CreateNs (n , map [string ]string {constants .IgnoreLabel : "true" })).To (Succeed ())
37
- }
32
+ Expect (Td .CreateNs (ignoreNs , map [string ]string {constants .IgnoreLabel : "true" })).To (Succeed ())
38
33
39
- // Add monitor-ignore to mesh with sidecar injection disabled
40
- Expect (Td .AddNsToMesh (false , monitorIgnoreNs )).To (Succeed ())
41
- // Add sidecar-monitor-ignore to mesh with sidecar injection enabled
42
- Expect (Td .AddNsToMesh (true , sidecarMonitorIgnoreNs )).To (Succeed ())
34
+ // Add test NS to mesh with sidecar injection enabled
35
+ Expect (Td .AddNsToMesh (true , ignoreNs )).To (Succeed ())
43
36
44
- By ("Ensuring pod is not injected with a sidecar when added a namespace with the ignore label " )
37
+ By ("Ensuring a pod is not injected with a sidecar when added to namespace the ignore, and sidecar injection labels set " )
45
38
39
+ // Get simple Pod definitions
46
40
svcAccDef , podDef , svcDef , err := Td .SimplePodApp (
47
41
SimplePodAppDef {
48
42
Name : "pod1" ,
@@ -68,121 +62,6 @@ var _ = OSMDescribe("Ignore Namespaces",
68
62
Expect (err ).NotTo (HaveOccurred ())
69
63
70
64
Expect (hasSidecar (pod .Spec .Containers )).To (BeFalse ())
71
-
72
- By ("Ensuring pod with a sidecar injection label is not injected with a sidecar when added to a namespace with the ignore label" )
73
-
74
- svcAccDef , podDef , svcDef , err = Td .SimplePodApp (
75
- SimplePodAppDef {
76
- Name : "pod2" ,
77
- Namespace : ignoreNs ,
78
- Command : []string {"/bin/bash" , "-c" , "--" },
79
- Args : []string {"while true; do sleep 30; done;" },
80
- Image : "songrgg/alpine-debug" ,
81
- Ports : []int {80 },
82
- OS : Td .ClusterOS ,
83
- })
84
- Expect (err ).NotTo (HaveOccurred ())
85
- podDef .Annotations = map [string ]string {constants .SidecarInjectionAnnotation : "enabled" }
86
-
87
- _ , err = Td .CreateServiceAccount (ignoreNs , & svcAccDef )
88
- Expect (err ).NotTo (HaveOccurred ())
89
- pod , err = Td .CreatePod (ignoreNs , podDef )
90
- Expect (err ).NotTo (HaveOccurred ())
91
- _ , err = Td .CreateService (ignoreNs , svcDef )
92
- Expect (err ).NotTo (HaveOccurred ())
93
-
94
- Expect (Td .WaitForPodsRunningReady (ignoreNs , 90 * time .Second , 1 , nil )).To (Succeed ())
95
-
96
- pod , err = Td .Client .CoreV1 ().Pods (ignoreNs ).Get (context .Background (), pod .Name , v1.GetOptions {})
97
- Expect (err ).NotTo (HaveOccurred ())
98
-
99
- Expect (hasSidecar (pod .Spec .Containers )).To (BeFalse ())
100
-
101
- By ("Ensuring a pod is not injected with a sidecar when added to namespace with the monitored-by and ignore labels" )
102
-
103
- svcAccDef , podDef , svcDef , err = Td .SimplePodApp (
104
- SimplePodAppDef {
105
- Name : "pod1" ,
106
- Namespace : monitorIgnoreNs ,
107
- Command : []string {"/bin/bash" , "-c" , "--" },
108
- Args : []string {"while true; do sleep 30; done;" },
109
- Image : "songrgg/alpine-debug" ,
110
- Ports : []int {80 },
111
- OS : Td .ClusterOS ,
112
- })
113
- Expect (err ).NotTo (HaveOccurred ())
114
-
115
- _ , err = Td .CreateServiceAccount (monitorIgnoreNs , & svcAccDef )
116
- Expect (err ).NotTo (HaveOccurred ())
117
- pod , err = Td .CreatePod (monitorIgnoreNs , podDef )
118
- Expect (err ).NotTo (HaveOccurred ())
119
- _ , err = Td .CreateService (monitorIgnoreNs , svcDef )
120
- Expect (err ).NotTo (HaveOccurred ())
121
-
122
- Expect (Td .WaitForPodsRunningReady (monitorIgnoreNs , 90 * time .Second , 1 , nil )).To (Succeed ())
123
-
124
- pod , err = Td .Client .CoreV1 ().Pods (monitorIgnoreNs ).Get (context .Background (), pod .Name , v1.GetOptions {})
125
- Expect (err ).NotTo (HaveOccurred ())
126
-
127
- Expect (hasSidecar (pod .Spec .Containers )).To (BeFalse ())
128
-
129
- By ("Ensuring pod with a sidecar injection label is not injected with a sidecar when added to a namespace with the monitored-by and ignore labels" )
130
-
131
- svcAccDef , podDef , svcDef , err = Td .SimplePodApp (
132
- SimplePodAppDef {
133
- Name : "pod2" ,
134
- Namespace : monitorIgnoreNs ,
135
- Command : []string {"/bin/bash" , "-c" , "--" },
136
- Args : []string {"while true; do sleep 30; done;" },
137
- Image : "songrgg/alpine-debug" ,
138
- Ports : []int {80 },
139
- OS : Td .ClusterOS ,
140
- })
141
- Expect (err ).NotTo (HaveOccurred ())
142
- podDef .Annotations = map [string ]string {constants .SidecarInjectionAnnotation : "enabled" }
143
-
144
- _ , err = Td .CreateServiceAccount (monitorIgnoreNs , & svcAccDef )
145
- Expect (err ).NotTo (HaveOccurred ())
146
- pod , err = Td .CreatePod (monitorIgnoreNs , podDef )
147
- Expect (err ).NotTo (HaveOccurred ())
148
- _ , err = Td .CreateService (monitorIgnoreNs , svcDef )
149
- Expect (err ).NotTo (HaveOccurred ())
150
-
151
- Expect (Td .WaitForPodsRunningReady (monitorIgnoreNs , 90 * time .Second , 1 , nil )).To (Succeed ())
152
-
153
- pod , err = Td .Client .CoreV1 ().Pods (monitorIgnoreNs ).Get (context .Background (), pod .Name , v1.GetOptions {})
154
- Expect (err ).NotTo (HaveOccurred ())
155
-
156
- Expect (hasSidecar (pod .Spec .Containers )).To (BeFalse ())
157
-
158
- By ("Ensuring a pod is not injected with a sidecar when added to namespace with the monitored-by, ignore, and sidecar injection labels set" )
159
-
160
- // Get simple Pod definitions
161
- svcAccDef , podDef , svcDef , err = Td .SimplePodApp (
162
- SimplePodAppDef {
163
- Name : "pod1" ,
164
- Namespace : sidecarMonitorIgnoreNs ,
165
- Command : []string {"/bin/bash" , "-c" , "--" },
166
- Args : []string {"while true; do sleep 30; done;" },
167
- Image : "songrgg/alpine-debug" ,
168
- Ports : []int {80 },
169
- OS : Td .ClusterOS ,
170
- })
171
- Expect (err ).NotTo (HaveOccurred ())
172
-
173
- _ , err = Td .CreateServiceAccount (sidecarMonitorIgnoreNs , & svcAccDef )
174
- Expect (err ).NotTo (HaveOccurred ())
175
- pod , err = Td .CreatePod (sidecarMonitorIgnoreNs , podDef )
176
- Expect (err ).NotTo (HaveOccurred ())
177
- _ , err = Td .CreateService (sidecarMonitorIgnoreNs , svcDef )
178
- Expect (err ).NotTo (HaveOccurred ())
179
-
180
- Expect (Td .WaitForPodsRunningReady (sidecarMonitorIgnoreNs , 90 * time .Second , 1 , nil )).To (Succeed ())
181
-
182
- pod , err = Td .Client .CoreV1 ().Pods (sidecarMonitorIgnoreNs ).Get (context .Background (), pod .Name , v1.GetOptions {})
183
- Expect (err ).NotTo (HaveOccurred ())
184
-
185
- Expect (hasSidecar (pod .Spec .Containers )).To (BeFalse ())
186
65
})
187
66
})
188
67
})
0 commit comments