Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

salt: Fix apiserver-proxy upstreams #2555

Merged
merged 2 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions salt/_modules/metalk8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ def minions_by_role(role, nodes=None):
Defaults to `pillar.metalk8s.nodes`.
'''
nodes = nodes or __pillar__['metalk8s']['nodes']
pillar_errors = nodes.pop('_errors', None)
if pillar_errors:
raise CommandExecutionError(
"Can't retrieve minions by role because of errors in pillar "
"'metalk8s:nodes': {}".format(', '.join(pillar_errors))
)

return [
node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,26 @@ events {
}

{%- if pillar.get('apiserver_ip') %}
{%- set masters_request = {'ip': pillar.apiserver_ip} %}
{%- set apiservers = [pillar.apiserver_ip] %}
{%- else %}
{%- set masters_request = salt['mine.get'](
tgt='I@metalk8s:nodes:*:roles:master',
fun='control_plane_ip',
tgt_type='compound',
)
{%- set masters = salt['metalk8s.minions_by_role']('master') %}
{%- if not masters %}
{{ raise("No master nodes in pillar 'metalk8s:nodes', "
~ "can't deploy apiserver-proxy") }}
{%- else %}
{%- set master_ips = salt['mine.get'](
tgt=masters | join(','),
fun='control_plane_ip',
tgt_type='list',
)
%}
{%- endif %}
{%- if not masters_request %}
{# In this case, we're (likely) bootstrapping #}
{%- set apiservers = ['127.0.0.1'] %}
{%- else %}
{%- set apiservers = masters_request.values() | sort %}
{%- if not master_ips and grains.id in masters %}
{# In case we're bootstrapping, the Mine wouldn't be available #}
{%- set apiservers = ["127.0.0.1"] %}
{%- else %}
{%- set apiservers = master_ips.values() | sort %}
{%- endif %}
{%- endif %}
{%- endif %}

stream {
Expand Down
1 change: 1 addition & 0 deletions salt/metalk8s/orchestrate/bootstrap/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'is_bootstrap': True,
'metalk8s': {
'nodes': {
'_errors': None,
pillar.bootstrap_id: {
'roles': ['bootstrap', 'master', 'etcd', 'ca', 'infra'],
'version': version,
Expand Down