From 512c5b8440a8fe89f8284f69d465411d399c0764 Mon Sep 17 00:00:00 2001 From: Aleksandr Didenko Date: Mon, 14 Nov 2016 08:48:28 +0100 Subject: [PATCH] Move CNI config and add MTU support for calico-cni - Move CNI configuration creation for Calico to appropriate network_plugin role from kubernetes/node. - Add support for MTU configuration in Calico. --- roles/kubernetes/node/tasks/main.yml | 7 ------- roles/network_plugin/calico/defaults/main.yml | 5 +++++ roles/network_plugin/calico/tasks/main.yml | 6 ++++++ .../calico}/templates/cni-calico.conf.j2 | 3 +++ 4 files changed, 14 insertions(+), 7 deletions(-) rename roles/{kubernetes/node => network_plugin/calico}/templates/cni-calico.conf.j2 (85%) diff --git a/roles/kubernetes/node/tasks/main.yml b/roles/kubernetes/node/tasks/main.yml index a8cb6ce5a..0680798d3 100644 --- a/roles/kubernetes/node/tasks/main.yml +++ b/roles/kubernetes/node/tasks/main.yml @@ -4,13 +4,6 @@ - include: nginx-proxy.yml when: is_kube_master == false and loadbalancer_apiserver_localhost|default(false) -- name: Write Calico cni config - template: - src: "cni-calico.conf.j2" - dest: "/etc/cni/net.d/10-calico.conf" - owner: kube - when: kube_network_plugin == "calico" - - name: Write kubelet config file template: src=kubelet.j2 dest={{ kube_config_dir }}/kubelet.env backup=yes notify: diff --git a/roles/network_plugin/calico/defaults/main.yml b/roles/network_plugin/calico/defaults/main.yml index 7b608ab7e..f0f91d39e 100644 --- a/roles/network_plugin/calico/defaults/main.yml +++ b/roles/network_plugin/calico/defaults/main.yml @@ -11,3 +11,8 @@ overwrite_hyperkube_cni: true calico_cert_dir: /etc/calico/certs etcd_cert_dir: /etc/ssl/etcd/ssl + +# You can set MTU value here. If left undefined or empty, it will +# not be specified in calico CNI config, so Calico will use built-in +# defaults. The value should be a number, not a string. +# calico_mtu: 1500 diff --git a/roles/network_plugin/calico/tasks/main.yml b/roles/network_plugin/calico/tasks/main.yml index 8c4fea86c..7f84fdb24 100644 --- a/roles/network_plugin/calico/tasks/main.yml +++ b/roles/network_plugin/calico/tasks/main.yml @@ -1,4 +1,10 @@ --- +- name: Calico | Write Calico cni config + template: + src: "cni-calico.conf.j2" + dest: "/etc/cni/net.d/10-calico.conf" + owner: kube + - name: Calico | Set docker daemon options template: src: docker diff --git a/roles/kubernetes/node/templates/cni-calico.conf.j2 b/roles/network_plugin/calico/templates/cni-calico.conf.j2 similarity index 85% rename from roles/kubernetes/node/templates/cni-calico.conf.j2 rename to roles/network_plugin/calico/templates/cni-calico.conf.j2 index 4e9752ef4..af2d28da6 100644 --- a/roles/kubernetes/node/templates/cni-calico.conf.j2 +++ b/roles/network_plugin/calico/templates/cni-calico.conf.j2 @@ -13,6 +13,9 @@ "policy": { "type": "k8s" }, +{% endif %} +{% if calico_mtu is defined and calico_mtu is number %} + "mtu": {{ calico_mtu }}, {% endif %} "kubernetes": { "kubeconfig": "{{ kube_config_dir }}/node-kubeconfig.yaml"