Skip to content

Commit

Permalink
Implement workaround for kubernetes/kubeadm#857
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lipovetsky committed Jul 27, 2018
1 parent 9d07e8a commit ed15829
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions workarounds/kubeadm_issue_857.go
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
}

0 comments on commit ed15829

Please sign in to comment.