Browse Source

Add possibility to insert more ip adresses in certificates (#1678)

* Add possibility to insert more ip adresses in certificates

* Add newline at end of files

* Move supp ip parameters to k8s-cluster group file

* Add supplementary addresses in kubeadm master role

* Improve openssl indexes
pull/1818/merge
Rémi de Passmoilesel 7 years ago
committed by Matthew Mosesohn
parent
commit
356515222a
3 changed files with 16 additions and 2 deletions
  1. 4
      inventory/group_vars/k8s-cluster.yml
  2. 8
      roles/kubernetes/master/tasks/kubeadm-setup.yml
  3. 6
      roles/kubernetes/secrets/templates/openssl.conf.j2

4
inventory/group_vars/k8s-cluster.yml

@ -170,3 +170,7 @@ istio_enabled: false
# A comma separated list of levels of node allocatable enforcement to be enforced by kubelet. # A comma separated list of levels of node allocatable enforcement to be enforced by kubelet.
# Acceptible options are 'pods', 'system-reserved', 'kube-reserved' and ''. Default is "". # Acceptible options are 'pods', 'system-reserved', 'kube-reserved' and ''. Default is "".
# kubelet_enforce_node_allocatable: pods # kubelet_enforce_node_allocatable: pods
## Supplementary addresses that can be added in kubernetes ssl keys.
## That can be usefull for example to setup a keepalived virtual IP
# supplementary_addresses_in_ssl_keys: [10.0.0.1, 10.0.0.2, 10.0.0.3]

8
roles/kubernetes/master/tasks/kubeadm-setup.yml

@ -54,8 +54,12 @@
{%- if hostvars[host]['access_ip'] is defined %}{{ hostvars[host]['access_ip'] }}{% endif %} {%- if hostvars[host]['access_ip'] is defined %}{{ hostvars[host]['access_ip'] }}{% endif %}
{{ hostvars[host]['ip'] | default(hostvars[host]['ansible_default_ipv4']['address']) }} {{ hostvars[host]['ip'] | default(hostvars[host]['ansible_default_ipv4']['address']) }}
{%- endfor %} {%- endfor %}
tags:
- facts
{% if supplementary_addresses_in_ssl_keys is defined %}
{% for addr in supplementary_addresses_in_ssl_keys %}
{{ addr }}
{% endfor %}
{% endif %}
tags: facts
- name: kubeadm | Copy etcd cert dir under k8s cert dir - name: kubeadm | Copy etcd cert dir under k8s cert dir
command: "cp -TR {{ etcd_cert_dir }} {{ kube_config_dir }}/ssl/etcd" command: "cp -TR {{ etcd_cert_dir }} {{ kube_config_dir }}/ssl/etcd"

6
roles/kubernetes/secrets/templates/openssl.conf.j2

@ -26,3 +26,9 @@ IP.{{ 2 * loop.index }} = {{ hostvars[host]['ip'] | default(hostvars[host]['ansi
{% set idx = groups['kube-master'] | length | int * 2 + 1 %} {% set idx = groups['kube-master'] | length | int * 2 + 1 %}
IP.{{ idx }} = {{ kube_apiserver_ip }} IP.{{ idx }} = {{ kube_apiserver_ip }}
IP.{{ idx + 1 }} = 127.0.0.1 IP.{{ idx + 1 }} = 127.0.0.1
{% if supplementary_addresses_in_ssl_keys is defined %}
{% set is = idx + 1 %}
{% for addr in supplementary_addresses_in_ssl_keys %}
IP.{{ is + loop.index }} = {{ addr }}
{% endfor %}
{% endif %}
Loading…
Cancel
Save