■ ■ ■ ■ ■ ■
pkg/service/cluster_tool.go
| skipped 226 lines |
227 | 227 | | port := cluster.SpecConf.KubeApiServerPort |
228 | 228 | | for _, node := range cluster.Nodes { |
229 | 229 | | if node.Role == constant.NodeRoleNameMaster { |
230 | | - | hosts = append(hosts, fmt.Sprintf("%s:%d", node.Host.Ip, port)) |
| 230 | + | if len(node.Host.Ip) != 0 { |
| 231 | + | hosts = append(hosts, fmt.Sprintf("%s:%d", node.Host.Ip, port)) |
| 232 | + | } |
231 | 233 | | } |
232 | 234 | | } |
233 | 235 | | availableHost, err := clusterUtil.SelectAliveHost(hosts) |
| skipped 30 lines |
264 | 266 | | if err != nil { |
265 | 267 | | return tool, err |
266 | 268 | | } |
267 | | - | var hosts []string |
268 | | - | port := cluster.SpecConf.KubeApiServerPort |
269 | | - | for _, node := range cluster.Nodes { |
270 | | - | if node.Role == constant.NodeRoleNameMaster { |
271 | | - | hosts = append(hosts, fmt.Sprintf("%s:%d", node.Host.Ip, port)) |
| 269 | + | availableHost := cluster.SpecConf.KubeRouter |
| 270 | + | if cluster.Source != constant.ClusterSourceExternal { |
| 271 | + | var hosts []string |
| 272 | + | port := cluster.SpecConf.KubeApiServerPort |
| 273 | + | for _, node := range cluster.Nodes { |
| 274 | + | if node.Role == constant.NodeRoleNameMaster { |
| 275 | + | if len(node.Host.Ip) != 0 { |
| 276 | + | hosts = append(hosts, fmt.Sprintf("%s:%d", node.Host.Ip, port)) |
| 277 | + | } |
| 278 | + | } |
272 | 279 | | } |
273 | | - | } |
274 | | - | availableHost, err := clusterUtil.SelectAliveHost(hosts) |
275 | | - | if err != nil { |
276 | | - | return tool, err |
| 280 | + | availableHost, err = clusterUtil.SelectAliveHost(hosts) |
| 281 | + | if err != nil { |
| 282 | + | return tool, err |
| 283 | + | } |
277 | 284 | | } |
278 | 285 | | |
279 | 286 | | var toolDetail model.ClusterToolDetail |
| skipped 23 lines |
303 | 310 | | if err != nil { |
304 | 311 | | return tool, err |
305 | 312 | | } |
306 | | - | var hosts []string |
307 | | - | port := cluster.SpecConf.KubeApiServerPort |
308 | | - | for _, node := range cluster.Nodes { |
309 | | - | if node.Role == constant.NodeRoleNameMaster { |
310 | | - | hosts = append(hosts, fmt.Sprintf("%s:%d", node.Host.Ip, port)) |
| 313 | + | availableHost := cluster.SpecConf.KubeRouter |
| 314 | + | if cluster.Source != constant.ClusterSourceExternal { |
| 315 | + | var hosts []string |
| 316 | + | port := cluster.SpecConf.KubeApiServerPort |
| 317 | + | for _, node := range cluster.Nodes { |
| 318 | + | if node.Role == constant.NodeRoleNameMaster { |
| 319 | + | if len(node.Host.Ip) != 0 { |
| 320 | + | hosts = append(hosts, fmt.Sprintf("%s:%d", node.Host.Ip, port)) |
| 321 | + | } |
| 322 | + | } |
| 323 | + | } |
| 324 | + | availableHost, err = clusterUtil.SelectAliveHost(hosts) |
| 325 | + | if err != nil { |
| 326 | + | return tool, err |
311 | 327 | | } |
312 | | - | } |
313 | | - | availableHost, err := clusterUtil.SelectAliveHost(hosts) |
314 | | - | if err != nil { |
315 | | - | return tool, err |
316 | 328 | | } |
317 | 329 | | |
318 | 330 | | var toolDetail model.ClusterToolDetail |
| skipped 135 lines |