Add kubeProxyNamespace argument
@@ -47,15 +47,15 @@ func WaitForKuberhealthy(ctx context.Context) error {
// WaitForKubeProxy waits for kube proxy to be ready and running on the node before running the check. Assumes that the
// kube-proxy pod follows the naming convention: "kube-proxy-{nodeName}"
-func WaitForKubeProxy(ctx context.Context, client *kubernetes.Clientset, namespace string) error {
+func WaitForKubeProxy(ctx context.Context, client *kubernetes.Clientset, KHNamespace string, kubeProxyNamespace string) error {
- khPod, err := getKHPod(client, namespace)
+ khPod, err := getKHPod(client, KHNamespace)
if err != nil {
return errors.New("error getting kuberhealthy pod: " + err.Error())
}
log.Debugln("Checking if kube-proxy is running and ready on this node:", khPod.Spec.NodeName)
select {
- case err := <- waitForKubeProxyReady(client, khPod.Spec.NodeName, ctx):
+ case err := <- waitForKubeProxyReady(ctx, client, khPod.Spec.NodeName, kubeProxyNamespace):
if err != nil {
return err
}
@@ -142,7 +142,7 @@ func waitForKuberhealthyEndpointReady(kuberhealthyEndpoint string, ctx context.C
}
// waitForKubeProxyReady fetches the kube proxy pod every 5 seconds until it's ready and running.
-func waitForKubeProxyReady(client *kubernetes.Clientset, nodeName string, ctx context.Context) chan error {
+func waitForKubeProxyReady(ctx context.Context, client *kubernetes.Clientset, nodeName string, kubeProxyNamespace string) chan error {
kubeProxyName := "kube-proxy-" + nodeName
doneChan := make(chan error, 1)
@@ -154,7 +154,7 @@ func waitForKubeProxyReady(client *kubernetes.Clientset, nodeName string, ctx co
return doneChan
default:
}
- kubeProxyReady, err := checkKubeProxyPod(client, kubeProxyName)
+ kubeProxyReady, err := checkKubeProxyPod(client, kubeProxyName, kubeProxyNamespace)
if err != nil {
doneChan <- err
return doneChan
@@ -170,11 +170,11 @@ func waitForKubeProxyReady(client *kubernetes.Clientset, nodeName string, ctx co
}
// checkKubeProxyPod gets the kube proxy pod and checks if its ready and running.
-func checkKubeProxyPod(client *kubernetes.Clientset, podName string) (bool, error) {
+func checkKubeProxyPod(client *kubernetes.Clientset, podName string, kubeProxyNamespace string) (bool, error) {
var kubeProxyReady bool
- kubeProxyPod, err := client.CoreV1().Pods("").Get(podName, v1.GetOptions{})
+ kubeProxyPod, err := client.CoreV1().Pods(kubeProxyNamespace).Get(podName, v1.GetOptions{})
if err != nil {
return kubeProxyReady, errors.New("Failed to get kube-proxy pod: " + podName + ". Error: " + err.Error())
}
