You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
5.5 KiB

  1. [Unit]
  2. Description=Kubernetes Kubelet Server
  3. Documentation=https://github.com/GoogleCloudPlatform/kubernetes
  4. Wants=network.target
  5. [Service]
  6. User=root
  7. Restart=on-failure
  8. RestartSec=10s
  9. TimeoutStartSec=0
  10. LimitNOFILE=40000
  11. ExecStartPre=-/usr/bin/rkt rm --uuid-file=/var/run/kubelet.uuid
  12. ExecStartPre=-/bin/mkdir -p /var/lib/kubelet
  13. ExecStartPre=-/bin/mkdir -p {{ kubelet_flexvolumes_plugins_dir }}
  14. EnvironmentFile={{kube_config_dir}}/kubelet.env
  15. # stage1-fly mounts /proc /sys /dev so no need to duplicate the mounts
  16. ExecStart=/usr/bin/rkt run \
  17. {% if kubelet_load_modules == true %}
  18. --volume modprobe,kind=host,source=/usr/sbin/modprobe \
  19. --volume lib-modules,kind=host,source=/lib/modules \
  20. {% endif %}
  21. --volume os-release,kind=host,source=/etc/os-release,readOnly=true \
  22. --volume hosts,kind=host,source=/etc/hosts,readOnly=true \
  23. --volume dns,kind=host,source=/etc/resolv.conf \
  24. --volume etc-kubernetes,kind=host,source={{ kube_config_dir }},readOnly=false \
  25. --volume etc-ssl-certs,kind=host,source=/etc/ssl/certs,readOnly=true \
  26. --volume etcd-ssl,kind=host,source={{ etcd_config_dir }},readOnly=true \
  27. --volume run,kind=host,source=/run,readOnly=false \
  28. {% for dir in ssl_ca_dirs -%}
  29. --volume {{ dir | regex_replace('^/(.*)$', '\\1' ) | regex_replace('/', '-') }},kind=host,source={{ dir }},readOnly=true \
  30. {% endfor -%}
  31. --volume var-lib-docker,kind=host,source={{ docker_daemon_graph }},readOnly=false \
  32. --volume var-lib-kubelet,kind=host,source=/var/lib/kubelet,readOnly=false,recursive=true \
  33. --volume var-log,kind=host,source=/var/log \
  34. {% if kube_network_plugin in ["calico", "weave", "canal", "flannel", "contiv", "cilium"] %}
  35. --volume etc-cni,kind=host,source=/etc/cni,readOnly=true \
  36. --volume opt-cni,kind=host,source=/opt/cni,readOnly=true \
  37. --volume var-lib-cni,kind=host,source=/var/lib/cni,readOnly=false \
  38. {# we can run into issues with double mounting /var/lib/kubelet #}
  39. {# surely there's a better way to do this #}
  40. {% if '/var/lib/kubelet' not in kubelet_flexvolumes_plugins_dir %}
  41. --volume flexvolumes,kind=host,source={{ kubelet_flexvolumes_plugins_dir }},readOnly=false \
  42. {% endif -%}
  43. {% if local_volume_provisioner_enabled %}
  44. --volume local-volume-provisioner-base-dir,kind=host,source={{ local_volume_provisioner_base_dir }},readOnly=false \
  45. {# Not pretty, but needed to avoid double mount #}
  46. {% if local_volume_provisioner_base_dir not in local_volume_provisioner_mount_dir and local_volume_provisioner_mount_dir not in local_volume_provisioner_base_dir %}
  47. --volume local-volume-provisioner-mount-dir,kind=host,source={{ local_volume_provisioner_mount_dir }},readOnly=false \
  48. {% endif %}
  49. {% endif %}
  50. {% if kubelet_load_modules == true %}
  51. --mount volume=modprobe,target=/usr/sbin/modprobe \
  52. --mount volume=lib-modules,target=/lib/modules \
  53. {% endif %}
  54. --mount volume=etc-cni,target=/etc/cni \
  55. --mount volume=opt-cni,target=/opt/cni \
  56. --mount volume=var-lib-cni,target=/var/lib/cni \
  57. {% endif %}
  58. --mount volume=os-release,target=/etc/os-release \
  59. --mount volume=dns,target=/etc/resolv.conf \
  60. --mount volume=etc-kubernetes,target={{ kube_config_dir }} \
  61. --mount volume=etc-ssl-certs,target=/etc/ssl/certs \
  62. --mount volume=etcd-ssl,target={{ etcd_config_dir }} \
  63. --mount volume=run,target=/run \
  64. {% for dir in ssl_ca_dirs -%}
  65. --mount volume={{ dir | regex_replace('^/(.*)$', '\\1' ) | regex_replace('/', '-') }},target={{ dir }} \
  66. {% endfor -%}
  67. --mount volume=var-lib-docker,target=/var/lib/docker \
  68. --mount volume=var-lib-kubelet,target=/var/lib/kubelet \
  69. --mount volume=var-log,target=/var/log \
  70. --mount volume=hosts,target=/etc/hosts \
  71. {# we can run into issues with double mounting /var/lib/kubelet #}
  72. {# surely there's a better way to do this #}
  73. {% if '/var/lib/kubelet' not in kubelet_flexvolumes_plugins_dir %}
  74. --mount volume=flexvolumes,target={{ kubelet_flexvolumes_plugins_dir }} \
  75. {% endif -%}
  76. {% if local_volume_provisioner_enabled %}
  77. --mount volume=local-volume-provisioner-base-dir,target={{ local_volume_provisioner_base_dir }} \
  78. {# Not pretty, but needed to avoid double mount #}
  79. {% if local_volume_provisioner_base_dir not in local_volume_provisioner_mount_dir and local_volume_provisioner_mount_dir not in local_volume_provisioner_base_dir %}
  80. --mount volume=local-volume-provisioner-mount-dir,target={{ local_volume_provisioner_mount_dir }} \
  81. {% endif %}
  82. {% endif %}
  83. --stage1-from-dir=stage1-fly.aci \
  84. {% if kube_hyperkube_image_repo == "docker" %}
  85. --insecure-options=image \
  86. docker://{{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} \
  87. {% else %}
  88. {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} \
  89. {% endif %}
  90. --uuid-file-save=/var/run/kubelet.uuid \
  91. --debug --exec=/kubelet -- \
  92. $KUBE_LOGTOSTDERR \
  93. $KUBE_LOG_LEVEL \
  94. $KUBELET_API_SERVER \
  95. $KUBELET_ADDRESS \
  96. $KUBELET_PORT \
  97. $KUBELET_HOSTNAME \
  98. $KUBE_ALLOW_PRIV \
  99. $KUBELET_ARGS \
  100. $DOCKER_SOCKET \
  101. $KUBELET_REGISTER_NODE \
  102. $KUBELET_NETWORK_PLUGIN \
  103. $KUBELET_VOLUME_PLUGIN \
  104. $KUBELET_CLOUDPROVIDER
  105. ExecStop=-/usr/bin/rkt stop --uuid-file=/var/run/kubelet.uuid
  106. [Install]
  107. WantedBy=multi-user.target