Skip to content

Commit

Permalink
Fix issue about setting customized cluster name when using kubespray
Browse files Browse the repository at this point in the history
openstack

When using `kubespray openstack` to initialize environment and deploy
kubernetes cluster, if you want to setup a cluster name with
`--cluster-name`, you will always receive errors like 

```
TASK [Create nodes network ports]
**********************************************
failed: [localhost] (item=k8s-phenomenal-ootp8f) => {"failed": true,
"item": "k8s-phenomenal-ootp8f", "msg": "Security group:
k8s-phenomenal-69k17f, was not found"}
failed: [localhost] (item=k8s-phenomenal-ystmto) => {"failed": true,
"item": "k8s-phenomenal-ystmto", "msg": "Security group:
k8s-phenomenal-69k17f, was not found"}
failed: [localhost] (item=k8s-phenomenal-k2f8sf) => {"failed": true,
"item": "k8s-phenomenal-k2f8sf", "msg": "Security group:
k8s-phenomenal-69k17f, was not found"}
```

That is because security group name is redefined and security group is
not created with these names. 

These is one issue existing,
kubespray#64

I did some code changes, which cluster_name will be changed at the first
place when customer set a new one.

Please help to review and let me know if anything that I could update or
improve.
  • Loading branch information
jianzj committed Aug 31, 2017
1 parent 673d3a1 commit e8a4dcf
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/kubespray/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ def gen_openstack_playbook(self):

# Define instance names
cluster_name = 'k8s-' + get_cluster_name()
if 'cluster_name' in self.options.keys():
cluster_name = 'k8s-' + self.options['cluster_name']
os_security_group_name = cluster_name + '-%s' % id_generator()

self.pbook_content[0]['tasks'].append(
Expand Down Expand Up @@ -348,11 +350,6 @@ def gen_openstack_playbook(self):
os_instance_names.append(
cluster_name + '-%s' % id_generator()
)
elif 'cluster_name' in self.options.keys():
os_instance_names.append(
self.options['cluster_name'] + '-%s' % id_generator()
)
os_security_group_name = self.options['cluster_name'] + '-%s' % id_generator()
else:
os_instance_names.append(
cluster_name + '-%s' % id_generator()
Expand Down

0 comments on commit e8a4dcf

Please sign in to comment.