proxy.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # Copyright 2014 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. MASTER_ADDRESS=${1:-"8.8.8.18"}
  16. NODE_ADDRESS=${2:-"8.8.8.20"}
  17. cat <<EOF >/opt/kubernetes/cfg/kube-proxy
  18. # --logtostderr=true: log to standard error instead of files
  19. KUBE_LOGTOSTDERR="--logtostderr=true"
  20. # --v=0: log level for V logs
  21. KUBE_LOG_LEVEL="--v=4"
  22. # --hostname-override="": If non-empty, will use this string as identification instead of the actual hostname.
  23. NODE_HOSTNAME="--hostname-override=${NODE_ADDRESS}"
  24. # --master="": The address of the Kubernetes API server (overrides any value in kubeconfig)
  25. KUBE_MASTER="--master=http://${MASTER_ADDRESS}:8080"
  26. EOF
  27. KUBE_PROXY_OPTS=" \${KUBE_LOGTOSTDERR} \\
  28. \${KUBE_LOG_LEVEL} \\
  29. \${NODE_HOSTNAME} \\
  30. \${KUBE_MASTER}"
  31. cat <<EOF >/usr/lib/systemd/system/kube-proxy.service
  32. [Unit]
  33. Description=Kubernetes Proxy
  34. After=network.target
  35. [Service]
  36. EnvironmentFile=-/opt/kubernetes/cfg/kube-proxy
  37. ExecStart=/opt/kubernetes/bin/kube-proxy ${KUBE_PROXY_OPTS}
  38. Restart=on-failure
  39. [Install]
  40. WantedBy=multi-user.target
  41. EOF
  42. systemctl daemon-reload
  43. systemctl enable kube-proxy
  44. systemctl start kube-proxy