Skip to content

Commit

Permalink
Make sure rke_cluster_id is specified and used
Browse files Browse the repository at this point in the history
  • Loading branch information
nuwang committed Dec 14, 2020
1 parent 8ad1237 commit 9e472cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 0 additions & 1 deletion cloudman/clusterman/cluster_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def rke_registration_token(self):
def rke_cluster_id(self):
return self._rke_cluster_id


def _find_matching_vm_type(self, zone_model=None, default_vm_type=None,
min_vcpus=0, min_ram=0, vm_family=""):
"""
Expand Down
15 changes: 14 additions & 1 deletion cloudman/clusterman/plugins/rke_kubernetes_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def validate_app_config(provider, name, cloud_config, app_config):
app_config, "config_kube_rke", "RKE configuration data"
" must be provided. config_kube_rke entry not found in"
" app_config.")
assert 'rke_cluster_id' in rke_config
assert 'rke_registration_server' in rke_config
assert 'rke_registration_token' in rke_config
return app_config
Expand Down Expand Up @@ -96,9 +97,21 @@ def _provision_host(self, name, task, app_config, provider_config):
class RKEKubernetesAnsibleAppConfigurer(AnsibleAppConfigurer):
"""Add CloudMan2 specific vars to playbook."""

def _cb_provider_id_to_kube_provider_id(self, provider_id):
CB_CLOUD_TO_KUBE_CLOUD_MAP = {
'aws': 'aws',
'openstack': 'openstack',
'azure': 'azure',
'gcp': 'gce'
}
return CB_CLOUD_TO_KUBE_CLOUD_MAP.get(provider_id)

def configure(self, app_config, provider_config):
playbook_vars = {
'kube_cloud_provider': provider_config.get('cloud_provider'),
'kube_cloud_provider': self._cb_provider_id_to_kube_provider_id(
provider_config.get('cloud_provider').PROVIDER_ID),
'cluster_hostname': app_config.get('config_kube_rke', {}).get(
'rke_cluster_id'),
'rke_registration_server': app_config.get('config_kube_rke', {}).get(
'rke_registration_server'),
'rke_registration_token': app_config.get('config_kube_rke', {}).get(
Expand Down

0 comments on commit 9e472cd

Please sign in to comment.