2019-03-09 21:54:44 +01:00
|
|
|
[Unit]
|
|
|
|
Description=Lightweight Kubernetes
|
|
|
|
Documentation=https://k3s.io
|
2020-09-21 20:38:51 +02:00
|
|
|
Wants=network-online.target
|
|
|
|
After=network-online.target
|
2019-03-09 21:54:44 +01:00
|
|
|
|
|
|
|
[Service]
|
2019-10-01 22:31:35 +02:00
|
|
|
Type={{ 'notify' if k3s_control_node else 'exec' }}
|
2019-03-09 21:54:44 +01:00
|
|
|
ExecStartPre=-/sbin/modprobe br_netfilter
|
|
|
|
ExecStartPre=-/sbin/modprobe overlay
|
2019-11-03 16:35:32 +01:00
|
|
|
{% filter regex_replace('\s+', ' ') %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% filter replace('\n', ' ') %}
|
|
|
|
ExecStart={{ k3s_install_dir }}/k3s
|
2020-09-21 19:44:11 +02:00
|
|
|
{% if k3s_debug is defined and k3s_debug %}
|
|
|
|
--debug
|
|
|
|
{% endif %}
|
2019-03-09 21:54:44 +01:00
|
|
|
{% if k3s_control_node %}
|
2020-09-15 19:10:25 +02:00
|
|
|
server
|
2020-08-01 15:17:20 +02:00
|
|
|
{% if k3s_bind_address is defined %}
|
|
|
|
--bind-address {{ k3s_bind_address }}
|
|
|
|
{% endif %}
|
2019-12-21 18:11:30 +01:00
|
|
|
{% if k3s_non_root is defined and k3s_non_root %}
|
|
|
|
--rootless
|
|
|
|
{% endif %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% if k3s_https_port != 6443 %}
|
|
|
|
--https-listen-port {{ k3s_https_port }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_disable_scheduler %}
|
|
|
|
--disable-scheduler
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_disable_cloud_controller %}
|
|
|
|
--disable-cloud-controller
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_disable_network_policy %}
|
|
|
|
--disable-network-policy
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_no_flannel %}
|
2020-03-07 15:23:09 +01:00
|
|
|
{% if (k3s_release_version | replace('v', '')) is version_compare('1.0.0', '>=') %}
|
2019-12-04 19:44:37 +01:00
|
|
|
--flannel-backend none
|
2020-03-07 15:23:09 +01:00
|
|
|
{% else %}
|
|
|
|
--no-flannel
|
2019-12-04 19:44:37 +01:00
|
|
|
{% endif %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% endif %}
|
2019-12-21 18:11:30 +01:00
|
|
|
{% if k3s_cluster_cidr is defined %}
|
|
|
|
--cluster-cidr {{ k3s_cluster_cidr }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_service_cidr is defined %}
|
|
|
|
--service-cidr {{ k3s_service_cidr }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_flannel_backend is defined and not k3s_no_flannel %}
|
2019-10-26 23:49:48 +02:00
|
|
|
--flannel-backend {{ k3s_flannel_backend }}
|
|
|
|
{% endif %}
|
2020-07-04 14:24:10 +02:00
|
|
|
{% if k3s_private_registry is defined and k3s_private_registry %}
|
|
|
|
--private-registry {{ k3s_private_registry }}
|
|
|
|
{% endif %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% if k3s_no_coredns is defined or k3s_no_traefik is defined or k3s_no_servicelb is defined %}
|
|
|
|
{% if k3s_no_coredns or k3s_no_traefik or k3s_no_servicelb %}
|
2020-07-16 13:49:31 +02:00
|
|
|
{{ ' --disable coredns' if k3s_no_coredns else '' }}{{ ' --disable servicelb' if k3s_no_servicelb else '' }}{{ ' --disable traefik' if k3s_no_traefik else '' }}{{ ' --disable local-storage' if k3s_no_local_storage else '' }}{{ ' --disable metrics-server' if k3s_no_metrics_server else '' }}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2020-02-25 09:48:09 +01:00
|
|
|
{% if not k3s_no_local_storage and k3s_default_local_storage_path is defined and k3s_default_local_storage_path %}
|
|
|
|
--default-local-storage-path {{ k3s_default_local_storage_path }}
|
|
|
|
{% endif %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% if k3s_cluster_dns is defined and k3s_cluster_dns %}
|
|
|
|
--cluster-dns {{ k3s_cluster_dns }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_cluster_domain is defined and k3s_cluster_domain != "cluster.local" %}
|
|
|
|
--cluster-domain {{ k3s_cluster_domain }}
|
|
|
|
{% endif %}
|
2020-01-11 20:20:52 +01:00
|
|
|
{% if k3s_datastore_endpoint is defined and k3s_datastore_endpoint %}
|
|
|
|
--datastore-endpoint "{{ k3s_datastore_endpoint }}"
|
2020-01-12 17:16:40 +01:00
|
|
|
{% if k3s_datastore_cafile is defined and k3s_datastore_cafile %}
|
|
|
|
--datastore-cafile {{ k3s_datastore_cafile }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_datastore_certfile is defined and k3s_datastore_certfile %}
|
|
|
|
--datastore-certfile {{ k3s_datastore_certfile }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_datastore_keyfile is defined and k3s_datastore_keyfile %}
|
|
|
|
--datastore-keyfile {{ k3s_datastore_keyfile }}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2020-09-17 22:01:20 +02:00
|
|
|
{% if (k3s_dqlite_datastore is defined and k3s_dqlite_datastore) or (k3s_etcd_datastore is defined and k3s_etcd_datastore) %}
|
2020-01-12 17:16:40 +01:00
|
|
|
{% if k3s_primary_control_node is defined and k3s_primary_control_node %}
|
|
|
|
--cluster-init
|
|
|
|
{% else %}
|
|
|
|
--server https://{{ k3s_control_node_address }}:{{ k3s_https_port }}
|
2020-09-21 20:38:51 +02:00
|
|
|
--token-file {{ k3s_token_location }}/cluster-token
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_etcd_disable_snapshots %}
|
|
|
|
--etcd-disable-snapshots
|
|
|
|
{% else %}
|
|
|
|
{% if k3s_etcd_snapshot_schedule_cron is defined %}
|
|
|
|
--etcd-snapshot-schedule-cron "{{ k3s_etcd_snapshot_schedule_cron }}"
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_etcd_snapshot_retention is defined %}
|
|
|
|
--etcd-snapshot-retention {{ k3s_etcd_snapshot_retention }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_etcd_snapshot_directory is defined %}
|
|
|
|
--etcd-snapshot-dir {{ k3s_etcd_snapshot_directory }}
|
|
|
|
{% endif %}
|
2020-01-12 17:16:40 +01:00
|
|
|
{% endif %}
|
2020-01-11 20:20:52 +01:00
|
|
|
{% endif %}
|
2020-03-28 13:58:58 +01:00
|
|
|
{% if k3s_secrets_encryption is defined and k3s_secrets_encryption %}
|
|
|
|
--secrets-encryption
|
|
|
|
{% endif %}
|
2020-07-04 14:24:10 +02:00
|
|
|
{% if k3s_kube_apiserver_args is defined and k3s_kube_apiserver_args is iterable %}
|
|
|
|
{% for arg in k3s_kube_apiserver_args %}
|
|
|
|
{% for key, value in arg.items() %}
|
|
|
|
--kube-apiserver-arg {{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_kube_scheduler_args is defined and k3s_kube_scheduler_args is iterable %}
|
|
|
|
{% for arg in k3s_kube_scheduler_args %}
|
|
|
|
{% for key, value in arg.items() %}
|
|
|
|
--kube-scheduler-arg {{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_kube_controller_manager_args is defined and k3s_kube_controller_manager_args is iterable %}
|
|
|
|
{% for arg in k3s_kube_controller_manager_args %}
|
|
|
|
{% for key, value in arg.items() %}
|
|
|
|
--kube-controller-manager-arg {{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_kube_cloud_controller_manager_args is defined and k3s_kube_cloud_controller_manager_args is iterable %}
|
|
|
|
{% for arg in k3s_kube_cloud_controller_manager_args %}
|
|
|
|
{% for key, value in arg.items() %}
|
|
|
|
--kube-cloud-controller-manager-arg {{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2019-03-09 21:54:44 +01:00
|
|
|
{% else %}
|
2019-10-26 23:49:48 +02:00
|
|
|
agent
|
|
|
|
--server https://{{ k3s_control_node_address }}:{{ k3s_https_port }}
|
2020-09-21 20:38:51 +02:00
|
|
|
--token-file {{ k3s_token_location }}/cluster-token
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_enable_selinux %}
|
|
|
|
--selinux
|
2019-03-09 21:54:44 +01:00
|
|
|
{% endif %}
|
2019-12-21 18:11:30 +01:00
|
|
|
{% if k3s_resolv_conf is defined and k3s_resolv_conf %}
|
|
|
|
--resolv-conf {{ k3s_resolv_conf }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_tls_san is defined and k3s_tls_san %}
|
|
|
|
--tls-san {{ k3s_tls_san }}
|
|
|
|
{% endif %}
|
2019-12-04 19:44:37 +01:00
|
|
|
{% if k3s_node_data_dir is defined %}
|
|
|
|
--data-dir {{ k3s_node_data_dir }}
|
|
|
|
{% endif %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% if k3s_use_docker %}
|
|
|
|
--docker
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_flannel_interface is defined and not k3s_no_flannel %}
|
|
|
|
--flannel-iface {{ k3s_flannel_interface }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_node_name is defined %}
|
|
|
|
--node-name {{ k3s_node_name }}
|
|
|
|
{% endif %}
|
2019-12-04 19:44:37 +01:00
|
|
|
{% if k3s_node_id is defined %}
|
|
|
|
--with-node-id {{ k3s_node_id }}
|
|
|
|
{% endif %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% if k3s_node_ip_address is defined %}
|
|
|
|
--node-ip {{ k3s_node_ip_address }}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_node_external_address is defined %}
|
|
|
|
--node-external-ip {{ k3s_node_external_address }}
|
|
|
|
{% endif %}
|
2019-12-04 18:17:15 +01:00
|
|
|
{% if k3s_write_kubeconfig_mode is defined %}
|
|
|
|
--write-kubeconfig-mode {{ k3s_write_kubeconfig_mode }}
|
|
|
|
{% endif %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% if k3s_node_labels is defined and k3s_node_labels is iterable %}
|
|
|
|
{% for label in k3s_node_labels %}
|
|
|
|
{% for key, value in label.items() %}
|
|
|
|
--node-label {{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% if k3s_node_taints is defined and k3s_node_taints is iterable %}
|
|
|
|
{% for taint in k3s_node_taints %}
|
|
|
|
{% for key, value in taint.items() %}
|
|
|
|
--node-taint {{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2020-02-27 00:03:08 +01:00
|
|
|
{% if k3s_kubelet_args is defined and k3s_kubelet_args is iterable %}
|
|
|
|
{% for arg in k3s_kubelet_args %}
|
|
|
|
{% for key, value in arg.items() %}
|
|
|
|
--kubelet-arg {{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2020-07-04 14:24:10 +02:00
|
|
|
{% if k3s_kube_proxy_args is defined and k3s_kube_proxy_args is iterable %}
|
|
|
|
{% for arg in k3s_kube_proxy_args %}
|
|
|
|
{% for key, value in arg.items() %}
|
|
|
|
--kube-proxy-arg {{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2019-10-26 23:49:48 +02:00
|
|
|
{% endfilter %}
|
2019-11-03 16:35:32 +01:00
|
|
|
{% endfilter %}
|
2019-10-26 23:49:48 +02:00
|
|
|
|
2019-03-09 21:54:44 +01:00
|
|
|
KillMode=process
|
|
|
|
Delegate=yes
|
2020-09-21 14:39:55 +02:00
|
|
|
LimitNOFILE=1048576
|
2019-03-09 21:54:44 +01:00
|
|
|
LimitNPROC=infinity
|
|
|
|
LimitCORE=infinity
|
|
|
|
TasksMax=infinity
|
2019-10-01 22:31:35 +02:00
|
|
|
TimeoutStartSec=0
|
|
|
|
Restart=always
|
|
|
|
RestartSec=5s
|
2019-03-09 21:54:44 +01:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|