-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement workaround for kubernetes/kubeadm#857
- Loading branch information
Daniel Lipovetsky
committed
Jul 27, 2018
1 parent
9d07e8a
commit ed15829
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package workarounds | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
|
||
"github.com/platform9/nodeadm/constants" | ||
"github.com/platform9/nodeadm/utils" | ||
) | ||
|
||
// PatchKubeProxyDaemonSet patches the kube-proxy daemonset to ensure that | ||
// kube-proxy functions when Node names are not hostnames, but some other value, | ||
// e.g., the host IPs. | ||
// Upstream issue: https://github.com/kubernetes/kubeadm/issues/857 | ||
// Workaround: https://kubernetes.io/docs/setup/independent/troubleshooting-kubeadm/#services-with-externaltrafficpolicy-local-are-not-reachable | ||
func PatchKubeProxyDaemonSet() error { | ||
patch := `[ | ||
{ | ||
"op": "add", | ||
"path": "/spec/template/spec/containers/0/env", | ||
"value": [ | ||
{ | ||
"name": "NODE_NAME", | ||
"valueFrom": { | ||
"fieldRef": { | ||
"apiVersion": "v1", | ||
"fieldPath": "spec.nodeName" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/spec/template/spec/containers/0/command/-", | ||
"value": "--hostname-override=${NODE_NAME}" | ||
} | ||
]` | ||
patchFile, err := ioutil.TempFile("", "nodeadm") | ||
if err != nil { | ||
return fmt.Errorf("unable to create temporary file: %v", err) | ||
} | ||
defer patchFile.Close() | ||
patchFile.WriteString(patch) | ||
utils.Run(constants.BASE_INSTALL_DIR, "kubectl", fmt.Sprintf("--kubeconfig=%s", constants.AdminKubeconfigFile), "--namepspace=kube-system", "patch", "--type=json", "daemonset", "kube-proxy", "-f", patchFile.Name()) | ||
return nil | ||
} |