@@ -27,6 +27,7 @@ import (
27
27
"k8s.io/apimachinery/pkg/util/intstr"
28
28
"k8s.io/client-go/dynamic"
29
29
"k8s.io/client-go/kubernetes/scheme"
30
+ "k8s.io/utils/pointer"
30
31
"sigs.k8s.io/controller-runtime/pkg/client/config"
31
32
"sigs.k8s.io/controller-runtime/pkg/log"
32
33
"sigs.k8s.io/e2e-framework/klient/k8s"
@@ -116,11 +117,11 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
116
117
Name : "test" ,
117
118
Image : "quay.io/jitesoft/nginx:mainline" ,
118
119
SecurityContext : & v1.SecurityContext {
119
- AllowPrivilegeEscalation : boolPtr (false ),
120
+ AllowPrivilegeEscalation : pointer . BoolPtr (false ),
120
121
Capabilities : & v1.Capabilities {
121
122
Drop : []v1.Capability {"ALL" },
122
123
},
123
- RunAsNonRoot : boolPtr (true ),
124
+ RunAsNonRoot : pointer . BoolPtr (true ),
124
125
SeccompProfile : & v1.SeccompProfile {
125
126
Type : v1 .SeccompProfileTypeRuntimeDefault ,
126
127
},
@@ -130,7 +131,6 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
130
131
},
131
132
}
132
133
133
- // Create the pod
134
134
err := client .Create (context .TODO (), pod )
135
135
Expect (err ).NotTo (HaveOccurred ())
136
136
})
@@ -155,20 +155,46 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
155
155
Spec : v1.PodSpec {
156
156
Containers : []v1.Container {
157
157
{
158
- Name : "test" ,
158
+ Name : "test-ubi" ,
159
+ Image : "registry.access.redhat.com/ubi8/ubi-minimal" ,
160
+ SecurityContext : & v1.SecurityContext {
161
+ AllowPrivilegeEscalation : pointer .BoolPtr (false ),
162
+ Capabilities : & v1.Capabilities {
163
+ Drop : []v1.Capability {"ALL" },
164
+ },
165
+ RunAsNonRoot : pointer .BoolPtr (true ),
166
+ SeccompProfile : & v1.SeccompProfile {
167
+ Type : v1 .SeccompProfileTypeRuntimeDefault ,
168
+ },
169
+ },
170
+ },
171
+ {
172
+ Name : "test-nginx" ,
159
173
Image : "quay.io/jitesoft/nginx:mainline" ,
160
174
SecurityContext : & v1.SecurityContext {
161
- AllowPrivilegeEscalation : boolPtr (false ),
175
+ AllowPrivilegeEscalation : pointer . BoolPtr (false ),
162
176
Capabilities : & v1.Capabilities {
163
177
Drop : []v1.Capability {"ALL" },
164
178
},
165
- RunAsNonRoot : boolPtr (true ),
179
+ RunAsNonRoot : pointer . BoolPtr (true ),
166
180
SeccompProfile : & v1.SeccompProfile {
167
181
Type : v1 .SeccompProfileTypeRuntimeDefault ,
168
182
},
169
183
},
170
184
},
171
185
},
186
+ Tolerations : []v1.Toleration {
187
+ {
188
+ Key : "node-role.kubernetes.io/master" ,
189
+ Value : "toleration-key-value" ,
190
+ Effect : v1 .TaintEffectNoSchedule ,
191
+ },
192
+ {
193
+ Key : "node-role.kubernetes.io/infra" ,
194
+ Value : "toleration-key-value2" ,
195
+ Effect : v1 .TaintEffectNoSchedule ,
196
+ },
197
+ },
172
198
},
173
199
}
174
200
})
@@ -194,7 +220,7 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
194
220
195
221
err := client .Get (ctx , saName , namespaceName , sa )
196
222
197
- if ( err == nil ) {
223
+ if err == nil {
198
224
err = client .Delete (ctx , sa )
199
225
Expect (err ).ToNot (HaveOccurred (), "Failed to delete existing Service Account" )
200
226
}
@@ -632,8 +658,3 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
632
658
})
633
659
})
634
660
})
635
-
636
- // Helper function to create a pointer to a bool
637
- func boolPtr (b bool ) * bool {
638
- return & b
639
- }
0 commit comments