summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWesley Hearn <wesley.s.hearn@gmail.com>2015-10-21 15:23:30 -0400
committerWesley Hearn <wesley.s.hearn@gmail.com>2015-10-21 15:23:30 -0400
commit9f3d3e9d0e697ce85620ac0a7a7c5eeba892f1d6 (patch)
tree315c8752e2527fb71dc389b254393977d44a7074
parentedfd8dc450854d6f2efa6c3d67e856b66b3743fd (diff)
parent8691cd2947146a24237fadc443eb02acf805a606 (diff)
downloadopenshift-9f3d3e9d0e697ce85620ac0a7a7c5eeba892f1d6.tar.gz
openshift-9f3d3e9d0e697ce85620ac0a7a7c5eeba892f1d6.tar.bz2
openshift-9f3d3e9d0e697ce85620ac0a7a7c5eeba892f1d6.tar.xz
openshift-9f3d3e9d0e697ce85620ac0a7a7c5eeba892f1d6.zip
Merge pull request #571 from dak1n1/router
Support HA or single router. Deploy after service accounts are created
-rw-r--r--inventory/byo/hosts.example4
-rw-r--r--playbooks/adhoc/s3_registry/s3_registry.yml16
-rw-r--r--playbooks/aws/openshift-cluster/launch.yml5
-rw-r--r--playbooks/common/openshift-cluster/create_services.yml8
-rw-r--r--playbooks/common/openshift-master/config.yml7
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py29
-rw-r--r--roles/openshift_master/tasks/main.yml3
-rw-r--r--roles/openshift_registry/tasks/main.yml11
-rw-r--r--roles/openshift_router/tasks/main.yml11
9 files changed, 69 insertions, 25 deletions
diff --git a/inventory/byo/hosts.example b/inventory/byo/hosts.example
index f554cc660..6b366cf87 100644
--- a/inventory/byo/hosts.example
+++ b/inventory/byo/hosts.example
@@ -75,6 +75,10 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
# default project node selector
#osm_default_node_selector='region=primary'
+# default selectors for router and registry services
+# openshift_router_selector='region=infra'
+# openshift_registry_selector='region=infra'
+
# set RPM version for debugging purposes
#openshift_pkg_version=-3.0.0.0
diff --git a/playbooks/adhoc/s3_registry/s3_registry.yml b/playbooks/adhoc/s3_registry/s3_registry.yml
index 5dc1abf17..4dcef1a42 100644
--- a/playbooks/adhoc/s3_registry/s3_registry.yml
+++ b/playbooks/adhoc/s3_registry/s3_registry.yml
@@ -6,13 +6,14 @@
# The AWS access/secret keys should be the keys of a separate user (not your main user), containing only the necessary S3 access role.
# The 'clusterid' is the short name of your cluster.
-- hosts: security_group_{{ clusterid }}_master
+- hosts: tag_env-host-type_{{ clusterid }}-openshift-master
remote_user: root
gather_facts: False
vars:
- aws_access_key: "{{ lookup('env', 'AWS_ACCESS_KEY_ID') }}"
- aws_secret_key: "{{ lookup('env', 'AWS_SECRET_ACCESS_KEY') }}"
+ aws_access_key: "{{ lookup('env', 'S3_ACCESS_KEY_ID') }}"
+ aws_secret_key: "{{ lookup('env', 'S3_SECRET_ACCESS_KEY') }}"
+
tasks:
- name: Check for AWS creds
@@ -23,10 +24,16 @@
- aws_access_key
- aws_secret_key
+ - name: Scale down registry
+ command: oc scale --replicas=0 dc/docker-registry
+
- name: Create S3 bucket
local_action:
module: s3 bucket="{{ clusterid }}-docker" mode=create
+ - name: Set up registry environment variable
+ command: oc env dc/docker-registry REGISTRY_CONFIGURATION_PATH=/etc/registryconfig/config.yml
+
- name: Generate docker registry config
template: src="s3_registry.j2" dest="/root/config.yml" owner=root mode=0600
@@ -54,6 +61,9 @@
command: oc volume dc/docker-registry --add --name=dockersecrets -m /etc/registryconfig --type=secret --secret-name=dockerregistry
when: "'dockersecrets' not in dc.stdout"
+ - name: Wait for deployment config to take effect before scaling up
+ pause: seconds=30
+
- name: Scale up registry
command: oc scale --replicas=1 dc/docker-registry
diff --git a/playbooks/aws/openshift-cluster/launch.yml b/playbooks/aws/openshift-cluster/launch.yml
index a89275597..786918929 100644
--- a/playbooks/aws/openshift-cluster/launch.yml
+++ b/playbooks/aws/openshift-cluster/launch.yml
@@ -55,9 +55,4 @@
when: master_names is defined and master_names.0 is defined
- include: update.yml
-
-- include: ../../common/openshift-cluster/create_services.yml
- vars:
- g_svc_master: "{{ service_master }}"
-
- include: list.yml
diff --git a/playbooks/common/openshift-cluster/create_services.yml b/playbooks/common/openshift-cluster/create_services.yml
deleted file mode 100644
index e70709d19..000000000
--- a/playbooks/common/openshift-cluster/create_services.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-- name: Deploy OpenShift Services
- hosts: "{{ g_svc_master }}"
- connection: ssh
- gather_facts: yes
- roles:
- - openshift_registry
- - openshift_router
diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml
index 14ec82e85..678e1c2d5 100644
--- a/playbooks/common/openshift-master/config.yml
+++ b/playbooks/common/openshift-master/config.yml
@@ -254,3 +254,10 @@
roles:
- openshift_serviceaccounts
+
+- name: Create services
+ hosts: oo_first_master
+
+ roles:
+ - openshift_router
+# - openshift_registry
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 69bb49c9b..6a32b24aa 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -1,6 +1,9 @@
-#!/usr/bin/python
+#!/usr/bin/python # pylint: disable=too-many-lines
# -*- coding: utf-8 -*-
# vim: expandtab:tabstop=4:shiftwidth=4
+# Reason: Disable pylint too-many-lines because we don't want to split up this file.
+# Status: Permanently disabled to keep this module as self-contained as possible.
+
"""Ansible module for retrieving and setting openshift related facts"""
DOCUMENTATION = '''
@@ -318,6 +321,29 @@ def set_node_schedulability(facts):
facts['node']['schedulable'] = True
return facts
+def set_master_selectors(facts):
+ """ Set selectors facts if not already present in facts dict
+ Args:
+ facts (dict): existing facts
+ Returns:
+ dict: the facts dict updated with the generated selectors
+ facts if they were not already present
+
+ """
+ if 'master' in facts:
+ if 'infra_nodes' in facts['master']:
+ deployment_type = facts['common']['deployment_type']
+ if deployment_type == 'online':
+ selector = "type=infra"
+ else:
+ selector = "region=infra"
+
+ if 'router_selector' not in facts['master']:
+ facts['master']['router_selector'] = selector
+ if 'registry_selector' not in facts['master']:
+ facts['master']['registry_selector'] = selector
+ return facts
+
def set_metrics_facts_if_unset(facts):
""" Set cluster metrics facts if not already present in facts dict
dict: the facts dict updated with the generated cluster metrics facts if
@@ -782,6 +808,7 @@ class OpenShiftFacts(object):
facts = set_url_facts_if_unset(facts)
facts = set_fluentd_facts_if_unset(facts)
facts = set_node_schedulability(facts)
+ facts = set_master_selectors(facts)
facts = set_metrics_facts_if_unset(facts)
facts = set_identity_providers_if_unset(facts)
facts = set_sdn_facts_if_unset(facts)
diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml
index 73c04cb08..4dcab31d1 100644
--- a/roles/openshift_master/tasks/main.yml
+++ b/roles/openshift_master/tasks/main.yml
@@ -52,8 +52,11 @@
default_subdomain: "{{ osm_default_subdomain | default(None) }}"
custom_cors_origins: "{{ osm_custom_cors_origins | default(None) }}"
default_node_selector: "{{ osm_default_node_selector | default(None) }}"
+ router_selector: "{{ openshift_router_selector | default(None) }}"
+ registry_selector: "{{ openshift_registry_selector | default(None) }}"
api_server_args: "{{ osm_api_server_args | default(None) }}"
controller_args: "{{ osm_controller_args | default(None) }}"
+ infra_nodes: "{{ num_infra | default(None) }}"
- name: Install Master package
yum: pkg={{ openshift.common.service_type }}-master{{ openshift_version }} state=present
diff --git a/roles/openshift_registry/tasks/main.yml b/roles/openshift_registry/tasks/main.yml
index 29387d7d5..749eea5c0 100644
--- a/roles/openshift_registry/tasks/main.yml
+++ b/roles/openshift_registry/tasks/main.yml
@@ -1,11 +1,14 @@
---
-- set_fact: _oreg_images="--images={{ oreg_url|quote }}"
- when: oreg_url is defined
+# This role is unused until we add options for configuring the backend storage
+
+- set_fact: _oreg_images="--images='{{ openshift.master.registry_url }}'"
+
+- set_fact: _oreg_selector="--selector='{{ openshift.master.registry_selector }}'"
- name: Deploy OpenShift Registry
command: >
{{ openshift.common.admin_binary }} registry
- --create
- --credentials={{ openshift_master_config_dir }}/openshift-registry.kubeconfig {{ _oreg_images|default() }}
+ --create --service-account=registry {{ _oreg_selector }}
+ --credentials={{ openshift_master_config_dir }}/openshift-registry.kubeconfig {{ _oreg_images }}
register: _oreg_results
changed_when: "'service exists' not in _oreg_results.stdout"
diff --git a/roles/openshift_router/tasks/main.yml b/roles/openshift_router/tasks/main.yml
index 929177262..b88b020fe 100644
--- a/roles/openshift_router/tasks/main.yml
+++ b/roles/openshift_router/tasks/main.yml
@@ -1,11 +1,14 @@
---
-- set_fact: _ortr_images="--images={{ oreg_url|quote }}"
- when: oreg_url is defined
+
+- set_fact: _ortr_images="--images='{{ openshift.master.registry_url }}'"
+
+- set_fact: _ortr_selector="--selector='{{ openshift.master.router_selector }}'"
- name: Deploy OpenShift Router
command: >
{{ openshift.common.admin_binary }} router
- --create
- --credentials={{ openshift_master_config_dir }}/openshift-router.kubeconfig {{ _ortr_images|default() }}
+ --create --replicas={{ num_infra }}
+ --service-account=router {{ _ortr_selector }}
+ --credentials={{ openshift_master_config_dir }}/openshift-router.kubeconfig {{ _ortr_images }}
register: _ortr_results
changed_when: "'service exists' not in _ortr_results.stdout"