From 57d0a3db94041a13e3176ce919a68f7845454099 Mon Sep 17 00:00:00 2001 From: Michal Zegan Date: Mon, 16 Sep 2019 17:23:04 +0200 Subject: Add external_ip variable Adds the external_ip variable that can be used to set ip different from cluster_ip, like public/floating/elastic ip, that can be used to externally communicate with kubernetes nodes. Mainly useful for the control plane and communication with api server. Change-Id: Ie840bff4b8479081b7397a42935c9db53db1bf4f Issue-ID: OOM-2112 Signed-off-by: Michal Zegan --- ansible/inventory/hosts.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ansible') diff --git a/ansible/inventory/hosts.yml b/ansible/inventory/hosts.yml index 4a6b68cf..825ee3b2 100644 --- a/ansible/inventory/hosts.yml +++ b/ansible/inventory/hosts.yml @@ -33,6 +33,10 @@ all: ansible_host: 10.8.8.19 #ip of the node that it uses for communication with k8s cluster. cluster_ip: 10.8.8.19 + # External ip of the node, used for access from outside of the cluster. + # Can be set to some kind of floating or public ip. + # If not set, cluster_ip is used for this purpose. + # external_ip: x.x.x.x # Group of hosts containing etcd cluster nodes. # Defaults to infra. @@ -44,7 +48,7 @@ all: # This means they host kubernetes api server, controller manager and scheduler. # This example uses infra for this purpose, however note that any # other host could be used including kubernetes nodes. - # cluster_ip needs to be set for hosts used as control planes. + # cluster_ip needs to be set for hosts used as control planes, external_ip can also be used. kubernetes-control-plane: hosts: infrastructure-server -- cgit 1.2.3-korg From 1bb11f154f93fa9ddb6d2fa8281e104a2157ded5 Mon Sep 17 00:00:00 2001 From: Michal Zegan Date: Mon, 16 Sep 2019 17:28:38 +0200 Subject: Use external_ip to populate the node address Use the new external_ip inventory variable to populate node address. Note that cluster_ip is still used if external_ip has not been set. This makes it possible to connect to kubernetes apiserver using the external_ip without disabling ssl cert verification. As an added bonus, the inventory hostname is now used as the node name to make node names more predictable. Change-Id: I3cc25c488d68f2f858a5eb3438d96285fa7517ca Issue-ID: OOM-2112 Signed-off-by: Michal Zegan --- ansible/roles/rke/templates/cluster.yml.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ansible') diff --git a/ansible/roles/rke/templates/cluster.yml.j2 b/ansible/roles/rke/templates/cluster.yml.j2 index 737d306f..51f4e28b 100644 --- a/ansible/roles/rke/templates/cluster.yml.j2 +++ b/ansible/roles/rke/templates/cluster.yml.j2 @@ -1,6 +1,6 @@ nodes: {% for node in groups['kubernetes'] %} -- address: "{{ hostvars[node].cluster_ip }}" +- address: "{{ hostvars[node].external_ip | default(hostvars[node].cluster_ip) }}" port: "22" internal_address: "{{ hostvars[node].cluster_ip }}" role: @@ -13,7 +13,7 @@ nodes: {% if node in groups['kubernetes-etcd'] %} - etcd {% endif %} - hostname_override: "" + hostname_override: "{{ node }}" user: "{{ rke_username }}" docker_socket: /var/run/docker.sock ssh_key: "" -- cgit 1.2.3-korg