var node_labels as string (#4764)

This commit is contained in:
Mateus Caruccio 2019-05-19 16:31:10 -03:00 committed by Kubernetes Prow Robot
parent ff1bc739f1
commit 8485136f9a
2 changed files with 13 additions and 6 deletions

View file

@ -117,11 +117,13 @@ Stack](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/dns-stack.m
from the kube-apiserver when the certificate expiration approaches. from the kube-apiserver when the certificate expiration approaches.
* *node_labels* - Labels applied to nodes via kubelet --node-labels parameter. * *node_labels* - Labels applied to nodes via kubelet --node-labels parameter.
For example, labels can be set in the inventory as variables or more widely in group_vars. For example, labels can be set in the inventory as variables or more widely in group_vars.
*node_labels* must be defined as a dict: *node_labels* can be defined either as a dict or a comma-separaded labels string:
``` ```
node_labels: node_labels:
label1_name: label1_value label1_name: label1_value
label2_name: label2_value label2_name: label2_value
node_labels: "label1_name=label1_value,label2_name=label2_value"
``` ```
* *node_taints* - Taints applied to nodes via kubelet --register-with-taints parameter. * *node_taints* - Taints applied to nodes via kubelet --register-with-taints parameter.
For example, taints can be set in the inventory as variables or more widely in group_vars. For example, taints can be set in the inventory as variables or more widely in group_vars.

View file

@ -91,11 +91,16 @@ KUBELET_HOSTNAME="--hostname-override={{ kube_override_hostname }}"
{% endif %} {% endif %}
{% set inventory_node_labels = [] %} {% set inventory_node_labels = [] %}
{% if node_labels is defined and node_labels is mapping %} {% if node_labels is defined %}
{% for labelname, labelvalue in node_labels.items() %} {% if node_labels is mapping %}
{% set dummy = inventory_node_labels.append('%s=%s'|format(labelname, labelvalue)) %} {% for labelname, labelvalue in node_labels.items() %}
{% endfor %} {% set dummy = inventory_node_labels.append('%s=%s'|format(labelname, labelvalue)) %}
{% endif %} {% endfor %}
{% else %}
{% for label in node_labels.split(",") %}
{% set dummy = inventory_node_labels.append(label) %}
{% endfor %}
{% endif %}
{% set all_node_labels = role_node_labels + inventory_node_labels %} {% set all_node_labels = role_node_labels + inventory_node_labels %}
{# Kubelet node taints for gpu #} {# Kubelet node taints for gpu #}