keep kubeproxy hostname consistent with kubelet

This commit is contained in:
jiangyaoguo 2015-11-05 11:41:07 +08:00
parent 70d2a02959
commit a739fc44c4
8 changed files with 71 additions and 56 deletions

View File

@ -93,7 +93,8 @@ coreos:
--master=https://${MASTER_IP} \
--kubeconfig=/var/lib/kube-proxy/kubeconfig \
--v=2 \
--logtostderr=true
--logtostderr=true \
--hostname-override=${HOSTNAME_OVERRIDE}
Restart=always
RestartSec=10

View File

@ -48,9 +48,9 @@ EOF
KUBE_PROXY_OPTS=" \${KUBE_LOGTOSTDERR} \\
\${KUBE_LOG_LEVEL} \\
\${NODE_ADDRESS} \\
\${NODE_PORT} \\
\${NODE_HOSTNAME} \\
\${NODE_ADDRESS} \\
\${NODE_PORT} \\
\${NODE_HOSTNAME} \\
\${KUBELET_API_SERVER} \\
\${KUBE_ALLOW_PRIV} \\
\${KUBELET_ARGS}"

View File

@ -16,6 +16,7 @@
MASTER_ADDRESS=${1:-"8.8.8.18"}
NODE_ADDRESS=${2:-"8.8.8.20"}
cat <<EOF >/opt/kubernetes/cfg/kube-proxy
# --logtostderr=true: log to standard error instead of files
@ -24,12 +25,16 @@ KUBE_LOGTOSTDERR="--logtostderr=true"
# --v=0: log level for V logs
KUBE_LOG_LEVEL="--v=4"
# --hostname-override="": If non-empty, will use this string as identification instead of the actual hostname.
NODE_HOSTNAME="--hostname-override=${NODE_ADDRESS}"
# --master="": The address of the Kubernetes API server (overrides any value in kubeconfig)
KUBE_MASTER="--master=http://${MASTER_ADDRESS}:8080"
EOF
KUBE_PROXY_OPTS=" \${KUBE_LOGTOSTDERR} \\
\${KUBE_LOG_LEVEL} \\
\${NODE_HOSTNAME} \\
\${KUBE_MASTER}"
cat <<EOF >/usr/lib/systemd/system/kube-proxy.service

View File

@ -9,4 +9,5 @@ kill timeout 60 # wait 60s between SIGTERM and SIGKILL.
exec /usr/local/bin/proxy \
--master=%(kubeapi_server)s \
--logtostderr=true
--logtostderr=true \
--hostname-override=%(kubelet_bind_addr)s

View File

@ -37,7 +37,8 @@ coreos:
[Service]
ExecStart=/opt/kubernetes/bin/kube-proxy \
--master=http://${MASTER_IP}:8080
--master=http://${MASTER_IP}:8080 \
--hostname-override=${NODE_IPS[$i]}
Restart=always
RestartSec=2

View File

@ -179,6 +179,7 @@ coreos:
--bind-address=$private_ipv4 \
--kubeconfig=/var/lib/kube-proxy/kubeconfig \
--logtostderr=true \
--hostname-override=$private_ipv4 \
--master=${FIRST_APISERVER_URL}
Restart=always
RestartSec=5

View File

@ -246,7 +246,8 @@ EOF
function create-kube-proxy-opts() {
cat <<EOF > ~/kube/default/kube-proxy
KUBE_PROXY_OPTS="\
--master=http://${1}:8080 \
--hostname-override=${1} \
--master=http://${2}:8080 \
--logtostderr=true"
EOF
@ -429,7 +430,9 @@ function provision-node() {
'${MASTER_IP}' \
'${DNS_SERVER_IP}' \
'${DNS_DOMAIN}'
create-kube-proxy-opts '${MASTER_IP}'
create-kube-proxy-opts \
'${1#*@}' \
'${MASTER_IP}'
create-flanneld-opts '${MASTER_IP}'
sudo -E -p '[sudo] password to start node: ' -- /bin/bash -c '
@ -493,7 +496,9 @@ function provision-masterandnode() {
'${MASTER_IP}' \
'${DNS_SERVER_IP}' \
'${DNS_DOMAIN}'
create-kube-proxy-opts '${MASTER_IP}'
create-kube-proxy-opts \
'${MASTER_IP}' \
'${MASTER_IP}'
create-flanneld-opts '127.0.0.1'
sudo -E -p '[sudo] password to start master: ' -- /bin/bash -c '

View File

@ -306,6 +306,7 @@ function start_kubeproxy {
PROXY_LOG=/tmp/kube-proxy.log
sudo -E "${GO_OUT}/kube-proxy" \
--v=${LOG_LEVEL} \
--hostname-override="127.0.0.1" \
--master="http://${API_HOST}:${API_PORT}" >"${PROXY_LOG}" 2>&1 &
PROXY_PID=$!