Merge pull request #678 from adidenko/update-calico-unit

Update calico-node systemd unit
This commit is contained in:
Bogdan Dobrelya 2016-12-06 13:51:37 +01:00 committed by GitHub
commit 2c1db56213
4 changed files with 69 additions and 20 deletions

View file

@ -159,9 +159,19 @@
template: src=network-environment.j2 dest=/etc/network-environment template: src=network-environment.j2 dest=/etc/network-environment
when: ansible_service_mgr in ["sysvinit","upstart"] when: ansible_service_mgr in ["sysvinit","upstart"]
- name: Calico (old) | Write calico-node systemd init file
template: src=calico-node.service.legacy.j2 dest=/etc/systemd/system/calico-node.service
when: ansible_service_mgr == "systemd" and legacy_calicoctl
notify: restart calico-node
- name: Calico | Write calico.env for systemd init file
template: src=calico.env.j2 dest=/etc/calico/calico.env
when: ansible_service_mgr == "systemd" and not legacy_calicoctl
notify: restart calico-node
- name: Calico | Write calico-node systemd init file - name: Calico | Write calico-node systemd init file
template: src=calico-node.service.j2 dest=/etc/systemd/system/calico-node.service template: src=calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd" and not legacy_calicoctl
notify: restart calico-node notify: restart calico-node
- name: Calico | Write calico-node initd script - name: Calico | Write calico-node initd script

View file

@ -1,28 +1,34 @@
[Unit] [Unit]
Description=Calico per-node agent Description=calico-node
Documentation=https://github.com/projectcalico/calico-docker After=docker.service
After=docker.service docker.socket Requires=docker.service
Wants=docker.socket
[Service] [Service]
User=root EnvironmentFile=/etc/calico/calico.env
PermissionsStartOnly=true ExecStartPre=-/usr/bin/docker rm -f calico-node
{% if legacy_calicoctl %} ExecStart=/usr/bin/docker run --net=host --privileged \
{% if inventory_hostname in groups['kube-node'] and peer_with_router|default(false)%} --name=calico-node \
ExecStart={{ bin_dir }}/calicoctl node --ip={{ip | default(ansible_default_ipv4.address) }} --as={{ local_as }} --detach=false --node-image={{ calico_node_image_repo }}:{{ calico_node_image_tag }} -e IP=${CALICO_IP} \
{% else %} -e IP6=${CALICO_IP6} \
ExecStart={{ bin_dir }}/calicoctl node --ip={{ip | default(ansible_default_ipv4.address) }} --detach=false --node-image={{ calico_node_image_repo }}:{{ calico_node_image_tag }} -e CALICO_NETWORKING_BACKEND=${CALICO_NETWORKING_BACKEND} \
{% endif %} -e AS=${CALICO_AS} \
{% else %} -e NO_DEFAULT_POOLS=${CALICO_NO_DEFAULT_POOLS} \
{% if inventory_hostname in groups['kube-node'] and peer_with_router|default(false)%} -e CALICO_LIBNETWORK_ENABLED=${CALICO_LIBNETWORK_ENABLED} \
ExecStart={{ bin_dir }}/calicoctl node run --ip={{ip | default(ansible_default_ipv4.address) }} --as={{ local_as }} --node-image={{ calico_node_image_repo }}:{{ calico_node_image_tag }} {% if calico_network_backend is defined %}--backend={{calico_network_backend }}{% endif %} -e ETCD_ENDPOINTS=${ETCD_ENDPOINTS} \
{% else %} -e ETCD_CA_CERT_FILE=${ETCD_CA_CERT_FILE} \
ExecStart={{ bin_dir }}/calicoctl node run --ip={{ip | default(ansible_default_ipv4.address) }} --node-image={{ calico_node_image_repo }}:{{ calico_node_image_tag }} {% if calico_network_backend is defined %}--backend={{calico_network_backend }}{% endif %} -e ETCD_CERT_FILE=${ETCD_CERT_FILE} \
{% endif %} -e ETCD_KEY_FILE=${ETCD_KEY_FILE} \
{% endif %} -v /var/log/calico:/var/log/calico \
-v /run/docker/plugins:/run/docker/plugins \
-v /lib/modules:/lib/modules \
-v /var/run/calico:/var/run/calico \
-v {{ calico_cert_dir }}:{{ calico_cert_dir }}:ro \
{{ calico_node_image_repo }}:{{ calico_node_image_tag }}
Restart=always Restart=always
RestartSec=10s RestartSec=10s
ExecStop=-/usr/bin/docker stop calico-node
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -0,0 +1,19 @@
[Unit]
Description=Calico per-node agent
Documentation=https://github.com/projectcalico/calico-docker
After=docker.service docker.socket
Wants=docker.socket
[Service]
User=root
PermissionsStartOnly=true
{% if inventory_hostname in groups['kube-node'] and peer_with_router|default(false)%}
ExecStart={{ bin_dir }}/calicoctl node --ip={{ip | default(ansible_default_ipv4.address) }} --as={{ local_as }} --detach=false --node-image={{ calico_node_image_repo }}:{{ calico_node_image_tag }}
{% else %}
ExecStart={{ bin_dir }}/calicoctl node --ip={{ip | default(ansible_default_ipv4.address) }} --detach=false --node-image={{ calico_node_image_repo }}:{{ calico_node_image_tag }}
{% endif %}
Restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,14 @@
ETCD_ENDPOINTS="{{ etcd_access_endpoint }}"
ETCD_CA_CERT_FILE="{{ calico_cert_dir }}/ca_cert.crt"
ETCD_CERT_FILE="{{ calico_cert_dir }}/cert.crt"
ETCD_KEY_FILE="{{ calico_cert_dir }}/key.pem"
CALICO_IP="{{ip | default(ansible_default_ipv4.address) }}"
CALICO_IP6=""
{% if calico_network_backend is defined %}
CALICO_NETWORKING_BACKEND="{{calico_network_backend }}"
{% endif %}
{% if inventory_hostname in groups['kube-node'] and peer_with_router|default(false)%}
CALICO_AS="{{ local_as }}"
{% endif %}
CALICO_NO_DEFAULT_POOLS="true"
CALICO_LIBNETWORK_ENABLED="true"