@@ -199,29 +199,9 @@ func (t *dnsTestCommon) deleteConfigMap() {
199
199
func (t * dnsTestCommon ) createUtilPodLabel (baseName string ) {
200
200
// Actual port # doesn't matter, just needs to exist.
201
201
const servicePort = 10101
202
-
203
- t .utilPod = & v1.Pod {
204
- TypeMeta : metav1.TypeMeta {
205
- Kind : "Pod" ,
206
- },
207
- ObjectMeta : metav1.ObjectMeta {
208
- Namespace : t .f .Namespace .Name ,
209
- Labels : map [string ]string {"app" : baseName },
210
- GenerateName : baseName + "-" ,
211
- },
212
- Spec : v1.PodSpec {
213
- Containers : []v1.Container {
214
- {
215
- Name : "util" ,
216
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
217
- Command : []string {"sleep" , "10000" },
218
- Ports : []v1.ContainerPort {
219
- {ContainerPort : servicePort , Protocol : v1 .ProtocolTCP },
220
- },
221
- },
222
- },
223
- },
224
- }
202
+ podName := fmt .Sprintf ("%s-%s" , baseName , string (uuid .NewUUID ()))
203
+ ports := []v1.ContainerPort {{ContainerPort : servicePort , Protocol : v1 .ProtocolTCP }}
204
+ t .utilPod = e2epod .NewAgnhostPod (t .f .Namespace .Name , podName , nil , nil , ports )
225
205
226
206
var err error
227
207
t .utilPod , err = t .c .CoreV1 ().Pods (t .f .Namespace .Name ).Create (context .TODO (), t .utilPod , metav1.CreateOptions {})
@@ -280,46 +260,31 @@ func (t *dnsTestCommon) deleteCoreDNSPods() {
280
260
}
281
261
282
262
func generateCoreDNSServerPod (corednsConfig * v1.ConfigMap ) * v1.Pod {
283
- return & v1.Pod {
284
- TypeMeta : metav1.TypeMeta {
285
- Kind : "Pod" ,
286
- },
287
- ObjectMeta : metav1.ObjectMeta {
288
- GenerateName : "e2e-dns-configmap-dns-server-" ,
289
- },
290
- Spec : v1.PodSpec {
291
- Volumes : []v1.Volume {
292
- {
293
- Name : "coredns-config" ,
294
- VolumeSource : v1.VolumeSource {
295
- ConfigMap : & v1.ConfigMapVolumeSource {
296
- LocalObjectReference : v1.LocalObjectReference {
297
- Name : corednsConfig .Name ,
298
- },
299
- },
300
- },
301
- },
302
- },
303
- Containers : []v1.Container {
304
- {
305
- Name : "dns" ,
306
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
307
- Command : []string {
308
- "/coredns" ,
309
- "-conf" , "/etc/coredns/Corefile" ,
310
- },
311
- VolumeMounts : []v1.VolumeMount {
312
- {
313
- Name : "coredns-config" ,
314
- MountPath : "/etc/coredns" ,
315
- ReadOnly : true ,
316
- },
263
+ podName := fmt .Sprintf ("e2e-configmap-dns-server-%s" , string (uuid .NewUUID ()))
264
+ volumes := []v1.Volume {
265
+ {
266
+ Name : "coredns-config" ,
267
+ VolumeSource : v1.VolumeSource {
268
+ ConfigMap : & v1.ConfigMapVolumeSource {
269
+ LocalObjectReference : v1.LocalObjectReference {
270
+ Name : corednsConfig .Name ,
317
271
},
318
272
},
319
273
},
320
- DNSPolicy : "Default" ,
321
274
},
322
275
}
276
+ mounts := []v1.VolumeMount {
277
+ {
278
+ Name : "coredns-config" ,
279
+ MountPath : "/etc/coredns" ,
280
+ ReadOnly : true ,
281
+ },
282
+ }
283
+
284
+ pod := e2epod .NewAgnhostPod ("" , podName , volumes , mounts , nil , "-conf" , "/etc/coredns/Corefile" )
285
+ pod .Spec .Containers [0 ].Command = []string {"/coredns" }
286
+ pod .Spec .DNSPolicy = "Default"
287
+ return pod
323
288
}
324
289
325
290
func generateCoreDNSConfigmap (namespaceName string , aRecords map [string ]string ) * v1.ConfigMap {
@@ -390,69 +355,37 @@ func (t *dnsTestCommon) deleteDNSServerPod() {
390
355
}
391
356
392
357
func createDNSPod (namespace , wheezyProbeCmd , jessieProbeCmd , podHostName , serviceName string ) * v1.Pod {
393
- dnsPod := & v1.Pod {
394
- TypeMeta : metav1.TypeMeta {
395
- Kind : "Pod" ,
396
- APIVersion : "v1" ,
397
- },
398
- ObjectMeta : metav1.ObjectMeta {
399
- Name : "dns-test-" + string (uuid .NewUUID ()),
400
- Namespace : namespace ,
401
- },
402
- Spec : v1.PodSpec {
403
- Volumes : []v1.Volume {
404
- {
405
- Name : "results" ,
406
- VolumeSource : v1.VolumeSource {
407
- EmptyDir : & v1.EmptyDirVolumeSource {},
408
- },
409
- },
410
- },
411
- Containers : []v1.Container {
412
- // TODO: Consider scraping logs instead of running a webserver.
413
- {
414
- Name : "webserver" ,
415
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
416
- Args : []string {"test-webserver" },
417
- Ports : []v1.ContainerPort {
418
- {
419
- Name : "http" ,
420
- ContainerPort : 80 ,
421
- },
422
- },
423
- VolumeMounts : []v1.VolumeMount {
424
- {
425
- Name : "results" ,
426
- MountPath : "/results" ,
427
- },
428
- },
429
- },
430
- {
431
- Name : "querier" ,
432
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
433
- Command : []string {"sh" , "-c" , wheezyProbeCmd },
434
- VolumeMounts : []v1.VolumeMount {
435
- {
436
- Name : "results" ,
437
- MountPath : "/results" ,
438
- },
439
- },
440
- },
441
- {
442
- Name : "jessie-querier" ,
443
- Image : imageutils .GetE2EImage (imageutils .JessieDnsutils ),
444
- Command : []string {"sh" , "-c" , jessieProbeCmd },
445
- VolumeMounts : []v1.VolumeMount {
446
- {
447
- Name : "results" ,
448
- MountPath : "/results" ,
449
- },
450
- },
451
- },
358
+ podName := "dns-test-" + string (uuid .NewUUID ())
359
+ volumes := []v1.Volume {
360
+ {
361
+ Name : "results" ,
362
+ VolumeSource : v1.VolumeSource {
363
+ EmptyDir : & v1.EmptyDirVolumeSource {},
452
364
},
453
365
},
454
366
}
367
+ mounts := []v1.VolumeMount {
368
+ {
369
+ Name : "results" ,
370
+ MountPath : "/results" ,
371
+ },
372
+ }
373
+
374
+ // TODO: Consider scraping logs instead of running a webserver.
375
+ dnsPod := e2epod .NewAgnhostPod (namespace , podName , volumes , mounts , nil , "test-webserver" )
376
+ dnsPod .Spec .Containers [0 ].Name = "webserver"
455
377
378
+ querier := e2epod .NewAgnhostContainer ("querier" , mounts , nil , wheezyProbeCmd )
379
+ querier .Command = []string {"sh" , "-c" }
380
+
381
+ jessieQuerier := v1.Container {
382
+ Name : "jessie-querier" ,
383
+ Image : imageutils .GetE2EImage (imageutils .JessieDnsutils ),
384
+ Command : []string {"sh" , "-c" , jessieProbeCmd },
385
+ VolumeMounts : mounts ,
386
+ }
387
+
388
+ dnsPod .Spec .Containers = append (dnsPod .Spec .Containers , querier , jessieQuerier )
456
389
dnsPod .Spec .Hostname = podHostName
457
390
dnsPod .Spec .Subdomain = serviceName
458
391
@@ -625,23 +558,3 @@ func validateTargetedProbeOutput(f *framework.Framework, pod *v1.Pod, fileNames
625
558
626
559
framework .Logf ("DNS probes using %s succeeded\n " , pod .Name )
627
560
}
628
-
629
- func generateDNSUtilsPod () * v1.Pod {
630
- return & v1.Pod {
631
- TypeMeta : metav1.TypeMeta {
632
- Kind : "Pod" ,
633
- },
634
- ObjectMeta : metav1.ObjectMeta {
635
- GenerateName : "e2e-dns-utils-" ,
636
- },
637
- Spec : v1.PodSpec {
638
- Containers : []v1.Container {
639
- {
640
- Name : "util" ,
641
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
642
- Command : []string {"sleep" , "10000" },
643
- },
644
- },
645
- },
646
- }
647
- }
0 commit comments