Skip to content

Commit

Permalink
[release-3.9] Set credentials and proper hostname when updating loopb…
Browse files Browse the repository at this point in the history
…ack kubeconfig

Make sure that the user we expect has proper credentials set.

When a cluster is installed the username in the loopback kubeconfig
is equal to hostname of that local master. This changes the variable
to equal a value of what would originally be set.

Backports openshift#11169
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1675133
  • Loading branch information
rjhowe committed Feb 11, 2019
1 parent 21cd6fe commit bc4f107
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion roles/openshift_facts/library/openshift_facts.py
Expand Up @@ -451,7 +451,7 @@ def set_url_facts_if_unset(facts):
ports[prefix]))

r_lhn = "{0}:{1}".format(hostname, ports['api']).replace('.', '-')
r_lhu = "system:openshift-master/{0}:{1}".format(api_hostname, ports['api']).replace('.', '-')
r_lhu = "system:openshift-master/{0}:{1}".format(hostname, ports['api']).replace('.', '-')
facts['master'].setdefault('loopback_cluster_name', r_lhn)
facts['master'].setdefault('loopback_context_name', "default/{0}/system:openshift-master".format(r_lhn))
facts['master'].setdefault('loopback_user', r_lhu)
Expand Down
11 changes: 11 additions & 0 deletions roles/openshift_master/tasks/set_loopback_context.yml
Expand Up @@ -16,6 +16,17 @@
- loopback_context_string not in l_loopback_config.stdout
register: set_loopback_cluster

- command: >
{{ openshift_client_binary }} config set-credentials
--client-certificate=/etc/origin/master/openshift-master.crt
--client-key=/etc/origin/master/openshift-master.key
--embed-certs=true
{{ openshift.master.loopback_user }}
--config={{ openshift_master_loopback_config }}
when:
- set_loopback_cluster is changed
register: l_set_loopback_credentials

- command: >
{{ openshift_client_binary }} config set-context
--cluster={{ openshift.master.loopback_cluster_name }}
Expand Down

0 comments on commit bc4f107

Please sign in to comment.