summaryrefslogtreecommitdiffstats
path: root/xci
diff options
context:
space:
mode:
authorFatih Degirmenci <fdegir@gmail.com>2019-08-31 18:50:05 +0200
committerFatih Degirmenci <fdegir@gmail.com>2019-09-01 02:45:10 +0200
commit5ed2d835de246e3cfb0878d78b382115ec8f0987 (patch)
treef0c515ce1da4444eae0334cf73fcd99d8f9708d8 /xci
parent0326442e753be727c2342b7caf9606393f84d744 (diff)
Refactor k8s scenario implementation
This change updates the scenario logic for basic k8s scenarios that enables the use of various network plugins. The change simply stops copying k8s-cluster.yml over but instead operates on the existing/original k8s-cluster.yml and updates kube_network_plugin in place. This makes it easier to maintain the scenarios and more importantly unblocks us from bumping kubespray and kubernetes versions. Please note that opnfv-scenario-requirements.yml contains version and the refspec of the corresponding change in releng-xci-scenarios repo so this change must be verified properly and if it passes CI, it needs to be amended, updating k8-calico-nofeature scenario's version to master and submitted. And then the change in releng-xci-scenarios can properly be verified. https://gerrit.opnfv.org/gerrit/#/c/releng-xci-scenarios/+/68418/ installer-type:kubespray deploy-scenario:k8-calico-nofeature JIRA: XCI-20 Change-Id: I1f851d20f5f7bc256199303581b05659091fddf9 Signed-off-by: Fatih Degirmenci <fdegir@gmail.com>
Diffstat (limited to 'xci')
-rwxr-xr-xxci/config/env-vars2
-rwxr-xr-xxci/config/pinned-versions3
-rwxr-xr-xxci/installer/kubespray/deploy.sh26
-rw-r--r--xci/installer/kubespray/playbooks/configure-installer.yml46
-rw-r--r--xci/installer/kubespray/playbooks/configure-opnfvhost.yml28
-rw-r--r--xci/opnfv-scenario-requirements.yml3
-rw-r--r--xci/var/opnfv.yml1
7 files changed, 81 insertions, 28 deletions
diff --git a/xci/config/env-vars b/xci/config/env-vars
index 2cb3e915..ee3b652b 100755
--- a/xci/config/env-vars
+++ b/xci/config/env-vars
@@ -8,7 +8,7 @@ export OPNFV_RELENG_GIT_URL=${OPNFV_RELENG_GIT_URL:-https://gerrit.opnfv.org/ger
export OPENSTACK_BIFROST_GIT_URL=${OPENSTACK_BIFROST_GIT_URL:-https://git.openstack.org/openstack/bifrost}
export OPENSTACK_OSA_GIT_URL=${OPENSTACK_OSA_GIT_URL:-https://git.openstack.org/openstack/openstack-ansible}
export OPENSTACK_OSA_OPENRC_GIT_URL=${OPENSTACK_OSA_OPENRC_GIT_URL:-https://git.openstack.org/openstack/openstack-ansible-openstack_openrc}
-export KUBESPRAY_GIT_URL=${KUBESPRAY_GIT_URL:-https://github.com/kubernetes-incubator/kubespray.git}
+export KUBESPRAY_GIT_URL=${KUBESPRAY_GIT_URL:-https://github.com/kubernetes-sigs/kubespray.git}
export OSH_GIT_URL=${OSH_GIT_URL:-https://github.com/openstack/openstack-helm.git}
export OSH_INFRA_GIT_URL=${OSH_INFRA_GIT_URL:-https://github.com/openstack/openstack-helm-infra.git}
export OPENSTACK_OSA_HAPROXY_GIT_URL=${OPENSTACK_OSA_HAPROXY_GIT_URL:-https://git.openstack.org/openstack/openstack-ansible-haproxy_server}
diff --git a/xci/config/pinned-versions b/xci/config/pinned-versions
index e40cf442..c5ed768a 100755
--- a/xci/config/pinned-versions
+++ b/xci/config/pinned-versions
@@ -50,3 +50,6 @@ export HAPROXY_VERSION=$(grep -E '.*name: haproxy_server' -A 3 \
| tail -n1 | sed -n 's/\(^.*: \)\([0-9a-z].*$\)/\2/p')
# Kubespray release v2.7.0 dated 02.10.2018
export KUBESPRAY_VERSION=${KUBESPRAY_VERSION:-"v2.7.0"}
+# Kubernetes version supported by the pinned kubespray version
+# this is needed for pulling in kubectl
+export KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.11.3"}
diff --git a/xci/installer/kubespray/deploy.sh b/xci/installer/kubespray/deploy.sh
index 76d503c5..af80b38f 100755
--- a/xci/installer/kubespray/deploy.sh
+++ b/xci/installer/kubespray/deploy.sh
@@ -33,6 +33,20 @@ echo "-----------------------------------------------------------------------"
echo "Info: Configured localhost for kubespray"
#-------------------------------------------------------------------------------
+# Configure installer
+#-------------------------------------------------------------------------------
+# TODO: summarize what this playbook does
+#-------------------------------------------------------------------------------
+
+echo "Info: Configuring kubespray installer"
+echo "-----------------------------------------------------------------------"
+cd $K8_XCI_PLAYBOOKS
+ansible-playbook ${XCI_ANSIBLE_PARAMS} \
+ -i ${XCI_PLAYBOOKS}/dynamic_inventory.py configure-installer.yml
+echo "-----------------------------------------------------------------------"
+echo "Info: Configured kubespray installer"
+
+#-------------------------------------------------------------------------------
# Configure deployment host, opnfv
#-------------------------------------------------------------------------------
# This playbook
@@ -75,7 +89,7 @@ echo "-----------------------------------------------------------------------"
ssh root@$OPNFV_HOST_IP "set -o pipefail; export XCI_FLAVOR=$XCI_FLAVOR; export INSTALLER_TYPE=$INSTALLER_TYPE; \
export IDF=/root/releng-xci/xci/var/idf.yml; export PDF=/root/releng-xci/xci/var/pdf.yml; \
cd releng-xci/.cache/repos/kubespray/; ansible-playbook \
- -i opnfv_inventory/dynamic_inventory.py cluster.yml -b | tee setup-kubernetes.log"
+ -i inventory/opnfv/dynamic_inventory.py cluster.yml -b | tee setup-kubernetes.log"
scp root@$OPNFV_HOST_IP:~/releng-xci/.cache/repos/kubespray/setup-kubernetes.log \
$LOG_PATH/setup-kubernetes.log
@@ -88,19 +102,15 @@ echo "-----------------------------------------------------------------------"
echo "Info: Kubernetes installation is successfully completed!"
echo "-----------------------------------------------------------------------"
-# Configure the kubernetes authentication in opnfv host. In future releases
-# kubectl is no longer an artifact so we should not fail if it's not available.
-# This needs to be removed in the future
-ssh root@$OPNFV_HOST_IP "mkdir -p ~/.kube/;\
- cp -f ~/admin.conf ~/.kube/config; \
- cp -f ~/kubectl /usr/local/bin || true"
-
#-------------------------------------------------------------------------------
# Execute post-installation tasks
#-------------------------------------------------------------------------------
# Playbook post.yml is used in order to execute any post-deployment tasks that
# are required for the scenario under test.
#-------------------------------------------------------------------------------
+# copy admin.conf
+ssh root@$OPNFV_HOST_IP "mkdir -p ~/.kube/; \
+ cp -f ~/admin.conf ~/.kube/config"
echo "-----------------------------------------------------------------------"
echo "Info: Running post-deployment scenario role"
echo "-----------------------------------------------------------------------"
diff --git a/xci/installer/kubespray/playbooks/configure-installer.yml b/xci/installer/kubespray/playbooks/configure-installer.yml
new file mode 100644
index 00000000..1f3b3d6f
--- /dev/null
+++ b/xci/installer/kubespray/playbooks/configure-installer.yml
@@ -0,0 +1,46 @@
+---
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+- hosts: localhost
+ connection: local
+ vars_files:
+ - "{{ xci_path }}/xci/var/opnfv.yml"
+
+ tasks:
+ - name: delete existing kubespray/inventory/opnfv directory
+ file:
+ path: "{{ xci_path }}/.cache/repos/kubespray/inventory/opnfv"
+ state: absent
+
+ - name: copy kubespray/inventory/sample as kubespray/inventory/opnfv
+ copy:
+ src: "{{ xci_path }}/.cache/repos/kubespray/inventory/sample/"
+ dest: "{{ xci_path }}/.cache/repos/kubespray/inventory/opnfv"
+
+ - name: update kubespray k8s-cluster.yml for xci
+ lineinfile:
+ path: "{{ xci_path }}/.cache/repos/kubespray/inventory/opnfv/group_vars/k8s-cluster/k8s-cluster.yml"
+ regexp: "{{ item.regexp }}"
+ line: "{{ item.line }}"
+ with_items:
+ - { regexp: "kube_version:.*", line: "kube_version: {{ kubernetes_version }}" }
+ - { regexp: "kubeconfig_localhost:.*", line: "kubeconfig_localhost: true" }
+ - { regexp: "kube_basic_auth:.*", line: "kube_basic_auth: true" }
+ - { regexp: "dashboard_enabled:.*", line: "dashboard_enabled: true" }
+
+ - name: update kubespray artifacts_dir
+ lineinfile:
+ path: "{{ xci_path }}/.cache/repos/kubespray/inventory/opnfv/group_vars/k8s-cluster/k8s-cluster.yml"
+ regexp: "artifacts_dir:.*"
+ line: "artifacts_dir: '{{ '{{' }} ansible_env.HOME {{ '}}' }}'"
+
+ - name: change dashboard server type to NodePort
+ lineinfile:
+ path: "{{ xci_path }}/.cache/repos/kubespray/roles/kubernetes-apps/ansible/templates/dashboard.yml.j2"
+ insertafter: 'targetPort'
+ line: " type: NodePort"
diff --git a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
index 54e32149..52e42b06 100644
--- a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
+++ b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
@@ -52,22 +52,20 @@
- "--recursive"
- "--files-from={{ xci_cache }}/releng-xci.files"
- - name: delete the opnfv_inventory directory
- file:
- path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory"
- state: absent
-
- - name: make sure kubespray/opnfv_inventory/group_vars/ exist
- file:
- path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars"
- state: directory
-
- - name: copy kubespray inventory directory
+ - name: link xci dynamic inventory to kubespray/inventory/opnfv directory
file:
src: "{{ remote_xci_playbooks }}/dynamic_inventory.py"
- path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/dynamic_inventory.py"
+ path: "{{ remote_xci_path }}/.cache/repos/kubespray/inventory/opnfv/dynamic_inventory.py"
state: link
+ - name: Download kubectl and place it to /usr/local/bin
+ get_url:
+ url: "https://storage.googleapis.com/kubernetes-release/release/{{ kubernetes_version }}/bin/linux/amd64/kubectl"
+ dest: /usr/local/bin/kubectl
+ owner: root
+ group: root
+ mode: 0755
+
- name: Reload XCI deployment host facts
setup:
filter: ansible_local
@@ -85,12 +83,6 @@
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
when: xci_flavor == 'aio'
- - name: change dashboard server type to NodePort
- lineinfile:
- path: "{{ remote_xci_path }}/.cache/repos/kubespray/roles/kubernetes-apps/ansible/templates/dashboard.yml.j2"
- insertafter: 'targetPort'
- line: " type: NodePort"
-
- name: pip install required packages
pip:
name: "{{ item.name }}"
diff --git a/xci/opnfv-scenario-requirements.yml b/xci/opnfv-scenario-requirements.yml
index 98abf528..8a4f9842 100644
--- a/xci/opnfv-scenario-requirements.yml
+++ b/xci/opnfv-scenario-requirements.yml
@@ -145,7 +145,8 @@
- scenario: k8-calico-nofeature
scm: git
src: https://gerrit.opnfv.org/gerrit/releng-xci-scenarios
- version: master
+ version: 94625920bd45180934815d8ce33197805dfff921
+ refspec: refs/changes/18/68418/6
role: scenarios/k8-calico-nofeature/role/k8-calico-nofeature
installers:
- installer: kubespray
diff --git a/xci/var/opnfv.yml b/xci/var/opnfv.yml
index 8e4f9b8d..91b9ee38 100644
--- a/xci/var/opnfv.yml
+++ b/xci/var/opnfv.yml
@@ -28,6 +28,7 @@ openstack_osa_haproxy_git_url: "{{ lookup('env','OPENSTACK_OSA_HAPROXY_GIT_URL')
# kubespray variables
kubespray_git_url: "{{ lookup('env','KUBESPRAY_GIT_URL') }}"
kubespray_version: "{{ lookup('env','KUBESPRAY_VERSION') }}"
+kubernetes_version: "{{ lookup('env','KUBERNETES_VERSION') }}"
xci_kube_ansible_pip_version: "{{ lookup('env','XCI_KUBE_ANSIBLE_PIP_VERSION') }}"
# openstack-helm variables