Skip to content

Commit

Permalink
Make k8s images for os-kubespray configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekaterina Chernova committed Jul 13, 2018
1 parent ea022e3 commit a598950
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
13 changes: 13 additions & 0 deletions kqueen/config/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ class Config(BaseConfig):
# Creds for Kqueen Read-only user
LDAP_DN = 'cn=admin,dc=example,dc=org'
LDAP_PASSWORD = 'heslo123'

# Images for Kubespray (available images that can be provided are listed in the link below)
# https://github.com/kubernetes-incubator/kubespray/blob/master/roles/download/defaults/main.yml
HYPERKUBE_IMAGE_REPO = 'docker-prod-local.docker.mirantis.net/mirantis/kubernetes/hyperkube-amd64'
HYPERKUBE_IMAGE_TAG = 'v1.9.8-4'
CALICO_CNI_IMAGE_REPO = 'docker-prod-local.docker.mirantis.net/mirantis/projectcalico/calico/cni'
CALICO_CNI_IMAGE_TAG = 'v1.11.6'
CALICO_CTL_IMAGE_REPO = 'docker-prod-local.docker.mirantis.net/mirantis/projectcalico/calico/ctl'
CALICO_CTL_IMAGE_TAG = 'v1.6.4'
CALICO_NODE_IMAGE_REPO = 'docker-prod-local.docker.mirantis.net/mirantis/projectcalico/calico/node'
CALICO_NODE_IMAGE_TAG = 'v2.6.10'
POD_INFRA_IMAGE_REPO = 'docker-prod-local.docker.mirantis.net/mirantis/kubernetes/pause-amd64'
POD_INFRA_IMAGE_TAG = 'v1.10.4-4'
14 changes: 10 additions & 4 deletions kqueen/engines/openstack_kubespray.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,14 @@ def _create_group_vars(self):
src = os.path.join(self.kubespray_path, "inventory/sample/group_vars")
dst = self._get_cluster_path("group_vars")
shutil.copytree(src, dst)

with open(os.path.join(dst, "all.yml"), "a") as all_yaml:
all_yaml.write("\ncloud_provider: openstack\n")
data_to_add = {'cloud_provider': 'openstack'}
image_var_names = [var_name for var_name in dir(config) if var_name.endswith(('_IMAGE_REPO', '_IMAGE_TAG'))]
image_variables = {k.lower(): getattr(config, k) for k in image_var_names}
data_to_add.update(image_variables)

yaml.dump(data_to_add, all_yaml, default_flow_style=False)

def _make_files_dir(self):
os.makedirs(self._get_cluster_path(), exist_ok=True)
Expand Down Expand Up @@ -612,7 +618,7 @@ def validate_ip(address):

mc = self.cluster.metadata["master_count"]
if mc % 2 == 0:
raise ValueError("Master node count must be an odd number at least 3 or greater")
raise ValueError("Master node count must be an odd number")
self.meta["master_count"] = mc
self.meta["slave_count"] = self.cluster.metadata["slave_count"]

Expand Down Expand Up @@ -701,8 +707,8 @@ def deprovision(self, volume_names):
self.c.delete_router(router.id)
self.c.delete_network(self.stack_name)
for sid in server_ids:
while self.c.get_server(sid):
time.sleep(5)
while self.c.get_server(sid):
time.sleep(5)
for fip in self.c.list_floating_ips():
if fip.floating_ip_address in floating_ips:
logger.info("Deleting floating ip %s" % fip.floating_ip_address)
Expand Down

0 comments on commit a598950

Please sign in to comment.