mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
[Federation] Wait for control plane pods in kubefed init
This commit is contained in:
@@ -230,6 +230,23 @@ func initFederation(cmdOut io.Writer, config util.AdminConfig, cmd *cobra.Comman
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !dryRun {
|
if !dryRun {
|
||||||
|
fmt.Fprintf(cmdOut, "Waiting for control plane to come up")
|
||||||
|
for !podRunning(hostClientset, serverName, initFlags.FederationSystemNamespace) {
|
||||||
|
_, err := fmt.Fprintf(cmdOut, ".")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//wait indefinite if the pod doesn't show up with correct status
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
}
|
||||||
|
for !podRunning(hostClientset, cmName, initFlags.FederationSystemNamespace) {
|
||||||
|
_, err := fmt.Fprintf(cmdOut, ".")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//wait indefinite if the pod doesn't show up with correct status
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
}
|
||||||
return printSuccess(cmdOut, ips, hostnames)
|
return printSuccess(cmdOut, ips, hostnames)
|
||||||
}
|
}
|
||||||
_, err = fmt.Fprintf(cmdOut, "Federation control plane runs (dry run)\n")
|
_, err = fmt.Fprintf(cmdOut, "Federation control plane runs (dry run)\n")
|
||||||
@@ -576,6 +593,21 @@ func createControllerManager(clientset *client.Clientset, namespace, name, svcNa
|
|||||||
return clientset.Extensions().Deployments(namespace).Create(dep)
|
return clientset.Extensions().Deployments(namespace).Create(dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func podRunning(clientset *client.Clientset, name, nameSpace string) bool {
|
||||||
|
podList, err := clientset.Core().Pods(nameSpace).List(api.ListOptions{})
|
||||||
|
if err != nil {
|
||||||
|
//Problem in getting pods at this time
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pod := range podList.Items {
|
||||||
|
if strings.Contains(pod.Name, name) && pod.Status.Phase == "Running" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func printSuccess(cmdOut io.Writer, ips, hostnames []string) error {
|
func printSuccess(cmdOut io.Writer, ips, hostnames []string) error {
|
||||||
svcEndpoints := append(ips, hostnames...)
|
svcEndpoints := append(ips, hostnames...)
|
||||||
_, err := fmt.Fprintf(cmdOut, "Federation API server is running at: %s\n", strings.Join(svcEndpoints, ", "))
|
_, err := fmt.Fprintf(cmdOut, "Federation API server is running at: %s\n", strings.Join(svcEndpoints, ", "))
|
||||||
|
Reference in New Issue
Block a user