@@ -78,7 +78,7 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
78
78
}
79
79
80
80
for i := 0 ; i < connum ; i ++ {
81
- config , hostConfig , networkConfig , containerName , err := c .makeContainerOptions (nil , specs , opts , "cpuperiod" )
81
+ config , hostConfig , networkConfig , containerName , err := c .makeContainerOptions (nil , specs , opts , "cpuperiod" , node . GetIP () )
82
82
if err != nil {
83
83
log .Errorf ("error when creating CreateContainerOptions, %v" , err )
84
84
ms [i ].Error = err .Error ()
@@ -334,7 +334,7 @@ func (c *calcium) doCreateContainerWithScheduler(nodename string, cpumap []types
334
334
335
335
for i , quota := range cpumap {
336
336
// create options
337
- config , hostConfig , networkConfig , containerName , err := c .makeContainerOptions (quota , specs , opts , "scheduler" )
337
+ config , hostConfig , networkConfig , containerName , err := c .makeContainerOptions (quota , specs , opts , "scheduler" , node . GetIP () )
338
338
if err != nil {
339
339
log .Errorf ("error when creating CreateContainerOptions, %v" , err )
340
340
ms [i ].Error = err .Error ()
@@ -435,7 +435,7 @@ func (c *calcium) releaseQuota(node *types.Node, quota types.CPUMap) {
435
435
c .store .UpdateNodeCPU (node .Podname , node .Name , quota , "+" )
436
436
}
437
437
438
- func (c * calcium ) makeContainerOptions (quota map [string ]int , specs types.Specs , opts * types.DeployOptions , optionMode string ) (
438
+ func (c * calcium ) makeContainerOptions (quota map [string ]int , specs types.Specs , opts * types.DeployOptions , optionMode , nodeIP string ) (
439
439
* enginecontainer.Config ,
440
440
* enginecontainer.HostConfig ,
441
441
* enginenetwork.NetworkingConfig ,
@@ -573,6 +573,15 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
573
573
networkMode = c .config .Docker .NetworkMode
574
574
}
575
575
576
+ // dns
577
+ // 如果有给dns就优先用给定的dns.
578
+ // 没有给出dns的时候, 如果设定是用宿主机IP作为dns, 就会把宿主机IP设置过去.
579
+ // 其他情况就是默认值.
580
+ dns := specs .DNS
581
+ if len (dns ) == 0 && c .config .Docker .UseLocalDNS && nodeIP != "" {
582
+ dns = []string {nodeIP }
583
+ }
584
+
576
585
config := & enginecontainer.Config {
577
586
Env : env ,
578
587
Cmd : cmd ,
@@ -602,6 +611,7 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
602
611
603
612
hostConfig := & enginecontainer.HostConfig {
604
613
Binds : binds ,
614
+ DNS : dns ,
605
615
LogConfig : enginecontainer.LogConfig {Type : logConfig },
606
616
NetworkMode : enginecontainer .NetworkMode (networkMode ),
607
617
RestartPolicy : enginecontainer.RestartPolicy {Name : entry .RestartPolicy , MaximumRetryCount : 3 },
0 commit comments