Skip to content

Commit 9122e48

Browse files
committed
Set openshift_master_cluster_hostname for external LB
This patch sets openshift_master_cluster_hostname and openshift_master_cluster_public_hostname to point to an external LB hostname. Because the external LB can not be pre-set with list of master nodes before openshift-ansible runs, external LB's IP is overriden temporarily to point to the first master node during first openshift-ansible run. External loadbalancer hostname now can (and should) be fully quilified domain name.
1 parent ecee320 commit 9122e48

14 files changed

Lines changed: 150 additions & 46 deletions

README.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ openshift-on-openstack provides multiple options for setting up loadbalancing:
297297
for master nodes and OpenShift routers.
298298
This is suggested type for production.
299299
To select this type include `-e openshift-on-openstack/env_loadbalancer_external.yaml`
300-
when creating the stack.
300+
when creating the stack and also set `lb_hostname` parameter to point to the
301+
loadbalancer's fully qualified domain name. Once stack creation is finished
302+
you can set your external loadbalancer with the list of created master nodes.
301303

302304
* Dedicated loadbalancer node - a dedicated node is created during stack
303305
creation and HAProxy loadbalancer is configured on it. Both console/API and

fragments/bastion-ansible.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ function create_metadata_json() {
4141
"openshift_use_openshift_sdn": $([ "$openshift_sdn" == "openshift-sdn" ] && echo true || echo false),
4242
"openshift_use_flannel": $([ "$openshift_sdn" == "flannel" ] && echo true || echo false),
4343
"master_ha": $([ "$lb_type" != "none" -a $master_count -gt 1 ] && echo true || echo false),
44+
"master_ip": "$master_ip",
4445
"openstack_cloud_provider": $openstack_cloud_provider,
4546
"os_username":"$os_username",
4647
"os_password":"$os_password",
4748
"os_auth_url":"$os_auth_url",
4849
"os_tenant_name":"$os_tenant_name",
4950
"os_region_name":"$os_region_name",
5051
"dedicated_lb": $([ "$lb_type" == "dedicated" ] && echo true || echo false),
51-
"no_lb": $([ "$lb_type" == "none" -o "$lb_type" == "external" ] && echo true || echo false),
52+
"no_lb": $([ "$lb_type" == "none" ] && echo true || echo false),
53+
"external_lb": $([ "$lb_type" == "external" ] && echo true || echo false),
5254
"masters": ["$(echo "$all_master_nodes" | sed 's/ /","/g')"],
5355
"infra_nodes": ["$(echo "$all_infra_nodes" | sed 's/ /","/g')"],
5456
"infra_count": $infra_count,
@@ -57,6 +59,7 @@ function create_metadata_json() {
5759
"deploy_router_or_registry": $deploy_router_or_registry,
5860
"domainname": "$domainname",
5961
"lb_hostname": "$lb_hostname",
62+
"short_lb_hostname": "${lb_hostname%%.$domainname}",
6063
"deploy_router": $([ "$deploy_router" == "True" ] && echo true || echo false),
6164
"deploy_registry": $([ "$deploy_registry" == "True" ] && echo true || echo false),
6265
"registry_volume_fs": "$registry_volume_fs",
@@ -101,7 +104,7 @@ function create_master_node_vars() {
101104
if [ "$lb_type" == "none" ]; then
102105
public_name="$1.$domainname"
103106
else
104-
public_name="$lb_hostname.$domainname"
107+
public_name="$lb_hostname"
105108
fi
106109

107110
cat << EOF > /var/lib/ansible/host_vars/$1.$domainname.yml
@@ -138,7 +141,15 @@ function update_etc_hosts() {
138141
grep -q "$2" /etc/hosts || echo "$1 $2" >> /etc/hosts
139142
}
140143

141-
update_etc_hosts "$lb_ip" "$lb_hostname.$domainname"
144+
if [ "$lb_type" == "external" ]; then
145+
# for external loadbalancer override LB's IP to point to the first master
146+
# node (because the LB can not be pre-set and working). This is done
147+
# only for the initial run, for next scale up/down it's expected
148+
# that the LB is already set.
149+
[ -e ${ANSDIR}.deployed ] || update_etc_hosts "$master_ip" "$lb_hostname"
150+
else
151+
update_etc_hosts "$lb_ip" "$lb_hostname"
152+
fi
142153

143154
[ "$skip_ansible" == "True" ] && exit 0
144155

infra.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ parameters:
9494
type: string
9595
constraints:
9696
- allowed_pattern: '[a-z0-9\-]*'
97-
description: Hostname must contain only characters [a-z0-9\-].
97+
description: Hostname must contain only characters [a-z0-9\-\.].
9898

9999
domain_name:
100100
description: >

loadbalancer_dedicated.yaml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ parameters:
3838
The load balancer hostname portion of the FQDN
3939
type: string
4040
constraints:
41-
- allowed_pattern: '[a-z0-9\-]*'
42-
description: Hostname must contain only characters [a-z0-9\-].
41+
- allowed_pattern: '[a-z0-9\-\.]*'
42+
description: Hostname must contain only characters [a-z0-9\-\.].
4343

4444
domain_name:
4545
description: >
@@ -161,6 +161,10 @@ parameters:
161161
skip_dns:
162162
type: boolean
163163

164+
stack_name:
165+
description: Top level stack name.
166+
type: string
167+
164168
resources:
165169
floating_ip_assoc:
166170
type: OS::Neutron::FloatingIPAssociation
@@ -204,8 +208,9 @@ resources:
204208
properties:
205209
name:
206210
str_replace:
207-
template: "%hostname%.%domainname%"
211+
template: "%stack_name%-%hostname%.%domainname%"
208212
params:
213+
'%stack_name%': {get_param: stack_name}
209214
'%hostname%': {get_param: hostname}
210215
'%domainname%': {get_param: domain_name}
211216
admin_user: {get_param: ssh_user}
@@ -235,13 +240,19 @@ resources:
235240
type: OS::Heat::CloudConfig
236241
properties:
237242
cloud_config:
238-
hostname: {get_param: hostname}
243+
hostname:
244+
str_replace:
245+
template: "%stack_name%-%hostname%"
246+
params:
247+
'%stack_name%': {get_param: stack_name}
248+
'%hostname%': {get_param: hostname}
239249
fqdn:
240250
str_replace:
241-
template: "HOST.DOMAIN"
251+
template: "%stack_name%-%hostname%.%domainname%"
242252
params:
243-
HOST: {get_param: hostname}
244-
DOMAIN: {get_param: domain_name}
253+
'%stack_name%': {get_param: stack_name}
254+
'%hostname%': {get_param: hostname}
255+
'%domainname%': {get_param: domain_name}
245256

246257
# Compile a set of standard configuration files to provide identity and access
247258
included_files:
@@ -352,10 +363,11 @@ resources:
352363
node_type: loadbalancer
353364
node_name:
354365
str_replace:
355-
template: "HOST.DOMAIN"
366+
template: "%stack_name%-%hostname%.%domainname%"
356367
params:
357-
HOST: {get_param: hostname}
358-
DOMAIN: {get_param: domain_name}
368+
'%stack_name%': {get_param: stack_name}
369+
'%hostname%': {get_param: hostname}
370+
'%domainname%': {get_param: domain_name}
359371
config:
360372
get_resource: node_cleanup
361373
server:
@@ -377,16 +389,28 @@ outputs:
377389
description: URL of the OpenShift web console
378390
value:
379391
str_replace:
380-
template: "https://%hostname%.%domainname%:8443/console/"
392+
template: "https://%stack_name%-%hostname%.%domainname%:8443/console/"
381393
params:
394+
'%stack_name%': {get_param: stack_name}
382395
'%hostname%': {get_param: hostname}
383396
'%domainname%': {get_param: domain_name}
384397

385398
api_url:
386399
description: URL entrypoint to the OpenShift API
387400
value:
388401
str_replace:
389-
template: "https://%hostname%.%domainname%:8443/"
402+
template: "https://%stack_name%-%hostname%.%domainname%:8443/"
403+
params:
404+
'%stack_name%': {get_param: stack_name}
405+
'%hostname%': {get_param: hostname}
406+
'%domainname%': {get_param: domain_name}
407+
408+
hostname:
409+
description: Loadbalancer hostname
410+
value:
411+
str_replace:
412+
template: "%stack_name%-%hostname%.%domainname%"
390413
params:
414+
'%stack_name%': {get_param: stack_name}
391415
'%hostname%': {get_param: hostname}
392416
'%domainname%': {get_param: domain_name}

loadbalancer_external.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ parameters:
3636
The load balancer hostname portion of the FQDN
3737
type: string
3838
constraints:
39-
- allowed_pattern: '[a-z0-9\-]*'
40-
description: Hostname must contain only characters [a-z0-9\-].
39+
- allowed_pattern: '[a-z0-9\-\.]*'
40+
description: Hostname must contain only characters [a-z0-9\-\.].
41+
42+
stack_name:
43+
description: Top level stack name.
44+
type: string
4145

4246
domain_name:
4347
description: >
@@ -164,16 +168,18 @@ outputs:
164168
description: URL of the OpenShift web console
165169
value:
166170
str_replace:
167-
template: "https://%hostname%.%domainname%:8443/console/"
171+
template: "https://%hostname%:8443/console/"
168172
params:
169-
'%hostname%': {get_param: master_hostname}
170-
'%domainname%': {get_param: domain_name}
173+
'%hostname%': {get_param: hostname}
171174

172175
api_url:
173176
description: URL entrypoint to the OpenShift API
174177
value:
175178
str_replace:
176-
template: "https://%hostname%.%domainname%:8443/"
179+
template: "https://%hostname%:8443/"
177180
params:
178-
'%hostname%': {get_param: master_hostname}
179-
'%domainname%': {get_param: domain_name}
181+
'%hostname%': {get_param: hostname}
182+
183+
hostname:
184+
description: Loadbalancer hostname
185+
value: {get_param: hostname}

loadbalancer_neutron.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ parameters:
3535
The load balancer hostname portion of the FQDN
3636
type: string
3737
constraints:
38-
- allowed_pattern: '[a-z0-9\-]*'
39-
description: Hostname must contain only characters [a-z0-9\-].
38+
- allowed_pattern: '[a-z0-9\-\.]*'
39+
description: Hostname must contain only characters [a-z0-9\-\.].
40+
41+
stack_name:
42+
description: Top level stack name.
43+
type: string
4044

4145
domain_name:
4246
description: >
@@ -193,16 +197,28 @@ outputs:
193197
description: URL of the OpenShift web console
194198
value:
195199
str_replace:
196-
template: "https://%hostname%.%domainname%:8443/console/"
200+
template: "https://%stack_name%-%hostname%.%domainname%:8443/console/"
197201
params:
202+
'%stack_name%': {get_param: stack_name}
198203
'%hostname%': {get_param: hostname}
199204
'%domainname%': {get_param: domain_name}
200205

201206
api_url:
202207
description: URL entrypoint to the OpenShift API
203208
value:
204209
str_replace:
205-
template: "https://%hostname%.%domainname%:8443/"
210+
template: "https://%stack_name%-%hostname%.%domainname%:8443/"
211+
params:
212+
'%stack_name%': {get_param: stack_name}
213+
'%hostname%': {get_param: hostname}
214+
'%domainname%': {get_param: domain_name}
215+
216+
hostname:
217+
description: Loadbalancer hostname
218+
value:
219+
str_replace:
220+
template: "%stack_name%-%hostname%.%domainname%"
206221
params:
222+
'%stack_name%': {get_param: stack_name}
207223
'%hostname%': {get_param: hostname}
208224
'%domainname%': {get_param: domain_name}

loadbalancer_none.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ parameters:
3535
The load balancer hostname portion of the FQDN
3636
type: string
3737

38+
stack_name:
39+
description: Top level stack name.
40+
type: string
41+
3842
domain_name:
3943
description: >
4044
All VMs will be placed in this domain
@@ -142,6 +146,14 @@ parameters:
142146
type: number
143147
default: 4000
144148

149+
hostname:
150+
description: >
151+
The load balancer hostname portion of the FQDN
152+
type: string
153+
constraints:
154+
- allowed_pattern: '[a-z0-9\-\.]*'
155+
description: Hostname must contain only characters [a-z0-9\-\.].
156+
145157
stack_name:
146158
type: string
147159
default: ''
@@ -173,3 +185,13 @@ outputs:
173185
params:
174186
'%hostname%': {get_param: master_hostname}
175187
'%domainname%': {get_param: domain_name}
188+
189+
hostname:
190+
description: Loadbalancer hostname
191+
value:
192+
str_replace:
193+
template: "%stack_name%-%hostname%.%domainname%"
194+
params:
195+
'%stack_name%': {get_param: stack_name}
196+
'%hostname%': {get_param: hostname}
197+
'%domainname%': {get_param: domain_name}

master.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ parameters:
9494
type: string
9595
constraints:
9696
- allowed_pattern: '[a-z0-9\-]*'
97-
description: Hostname must contain only characters [a-z0-9\-].
97+
description: Hostname must contain only characters [a-z0-9\-\.].
9898

9999
domain_name:
100100
description: >

node.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ parameters:
128128
type: string
129129
constraints:
130130
- allowed_pattern: '[a-z0-9\-]*'
131-
description: Hostname must contain only characters [a-z0-9\-].
131+
description: Hostname must contain only characters [a-z0-9\-\.].
132132

133133
domain_name:
134134
description: >
@@ -207,6 +207,12 @@ parameters:
207207
type: string
208208
default: ''
209209

210+
master_ip:
211+
description: >
212+
The IP address of the first master node (used instead of external LB during setup)
213+
type: string
214+
default: ''
215+
210216
lb_hostname:
211217
description: >
212218
The hostname of the load balancer feeding the OpenShift master traffic
@@ -633,6 +639,8 @@ resources:
633639
default: {get_param: skip_dns}
634640
- name: lb_ip
635641
default: {get_param: lb_ip}
642+
- name: master_ip
643+
default: {get_param: master_ip}
636644
- name: lb_hostname
637645
default: {get_param: lb_hostname}
638646
- name: ldap_url

openshift.yaml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,8 @@ resources:
699699
loadbalancer_type: {get_param: loadbalancer_type}
700700
dns_forwarders: {get_param: dns_nameserver}
701701
lb_ip: {get_attr: [lb_floating_ip, floating_ip_address]}
702-
lb_hostname:
703-
str_replace:
704-
template: "%stackname%-%hostname%"
705-
params:
706-
'%stackname%': {get_param: 'OS::stack_name'}
707-
'%hostname%': {get_param: lb_hostname}
702+
master_ip: {get_attr: [openshift_masters, resource.0.ip_address]}
703+
lb_hostname: {get_attr: [loadbalancer, hostname]}
708704
router_vip: {get_attr: [ipfailover, router_vip]}
709705
skip_ansible: {get_param: skip_ansible}
710706
extra_openshift_ansible_params: {get_param: extra_openshift_ansible_params}
@@ -940,13 +936,9 @@ resources:
940936
sat6_activationkey: {get_param: sat6_activationkey}
941937
rhn_pool: {get_param: rhn_pool}
942938
extra_rhn_pools: {get_param: extra_rhn_pools}
943-
hostname:
944-
str_replace:
945-
template: "%stackname%-%hostname%"
946-
params:
947-
'%stackname%': {get_param: 'OS::stack_name'}
948-
'%hostname%': {get_param: lb_hostname}
939+
hostname: {get_param: lb_hostname}
949940
domain_name: {get_param: domain_name}
941+
stack_name: {get_param: 'OS::stack_name'}
950942
ansible_public_key: {get_attr: [ansible_keys, public_key]}
951943
dns_ip: {get_attr: [bastion_floating_ip, floating_ip_address]}
952944
fixed_subnet: {get_resource: fixed_subnet}

0 commit comments

Comments
 (0)