From 7a31d776d4bdf122d4c4c8f732304cc83621bdd6 Mon Sep 17 00:00:00 2001 From: Alexandru Avadanii Date: Mon, 11 Feb 2019 11:04:59 +0000 Subject: [akraino] Add IEC K8-calico scenarios - bump Pharos git submodule to allow PODs with fewer nodes; - add `k8-calico-iec-noha` scenario definition for Akraino IEC basic configuration; - add `k8-calico-iec-vcp-noha` scenario definition for Akraino IEC nested (virtualized control plane) configuration; - add `akraino_iec` state, which will leverage the Akraino IEC bootstrap scripts from [1]; - replace system.reboot salt call with cmd.run 'reboot' as it's more reliable; - use kernel 4.15 for AArch64 K8 IEC scenarios; NOTE: These scenarios will not be released in OPNFV since don't rely on Salt formulas but instead of Akraino IEC scripts to install K8s. [1] https://gerrit.akraino.org/r/#/q/project:iec Change-Id: I4e538e0563d724cd3fd5c4d462ddc22d0c739402 Signed-off-by: Alexandru Avadanii --- mcp/config/scenario/defaults.yaml.j2 | 3 ++ mcp/config/scenario/k8-calico-iec-noha.yaml | 27 ++++++++++++++ mcp/config/scenario/k8-calico-iec-vcp-noha.yaml | 28 ++++++++++++++ mcp/config/states/akraino_iec | 49 +++++++++++++++++++++++++ mcp/config/states/baremetal_init | 7 ++-- mcp/config/states/virtual_control_plane | 8 +--- mcp/config/states/virtual_init | 2 +- 7 files changed, 113 insertions(+), 11 deletions(-) create mode 100644 mcp/config/scenario/k8-calico-iec-noha.yaml create mode 100644 mcp/config/scenario/k8-calico-iec-vcp-noha.yaml create mode 100755 mcp/config/states/akraino_iec (limited to 'mcp/config') diff --git a/mcp/config/scenario/defaults.yaml.j2 b/mcp/config/scenario/defaults.yaml.j2 index 4d1215f55..ddcd0a039 100644 --- a/mcp/config/scenario/defaults.yaml.j2 +++ b/mcp/config/scenario/defaults.yaml.j2 @@ -55,6 +55,9 @@ aarch64: - armband_3 1201 deb [arch=arm64] http://linux.enea.com/mcp-repos/rocky/xenial rocky-armband main pkg: install: +{%- if '-iec-' in conf.MCP_DEPLOY_SCENARIO %} + - linux-generic-hwe-16.04 +{%- endif %} - python-futures - salt-minion control: diff --git a/mcp/config/scenario/k8-calico-iec-noha.yaml b/mcp/config/scenario/k8-calico-iec-noha.yaml new file mode 100644 index 000000000..93f007ba9 --- /dev/null +++ b/mcp/config/scenario/k8-calico-iec-noha.yaml @@ -0,0 +1,27 @@ +############################################################################## +# Copyright (c) 2019 Mirantis Inc., Enea AB and others. +# 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 +############################################################################## +--- +cluster: + domain: mcp-iec-noha.local + states: + - akraino_iec +virtual: + nodes: + control: + - iec01 + - iec02 + - iec03 + iec01: + vcpus: 8 + ram: 10240 + iec02: + vcpus: 8 + ram: 10240 + iec03: + vcpus: 8 + ram: 10240 diff --git a/mcp/config/scenario/k8-calico-iec-vcp-noha.yaml b/mcp/config/scenario/k8-calico-iec-vcp-noha.yaml new file mode 100644 index 000000000..dc0c00bf6 --- /dev/null +++ b/mcp/config/scenario/k8-calico-iec-vcp-noha.yaml @@ -0,0 +1,28 @@ +############################################################################## +# Copyright (c) 2019 Mirantis Inc., Enea AB and others. +# 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 +############################################################################## +--- +cluster: + domain: mcp-iec-noha.local + states: + - virtual_control_plane + - akraino_iec +virtual: + nodes: + control: + - kvm01 + - kvm02 + - kvm03 + kvm01: + vcpus: 8 + ram: 10240 + kvm02: + vcpus: 8 + ram: 10240 + kvm03: + vcpus: 8 + ram: 10240 diff --git a/mcp/config/states/akraino_iec b/mcp/config/states/akraino_iec new file mode 100755 index 000000000..6cc010b05 --- /dev/null +++ b/mcp/config/states/akraino_iec @@ -0,0 +1,49 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2019 Mirantis Inc., Enea AB and others. +# 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 +############################################################################## + +CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x + +# shellcheck disable=SC1090 +source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh" + +IEC_REPO_URI='https://gerrit.akraino.org/r/iec' +IEC_USER='ubuntu' +# shellcheck disable=SC2016 +IEC_REPO_PATH=$(su - "${IEC_USER}" -c 'echo ${HOME}/iec') +IEC_SCRIPTS_PATH="${IEC_REPO_PATH}/src/foundation/scripts" + +POD_NETWORK_CIDR='100.100.0.0/16' # Avoid overlapping Fuel's PXE/admin net + +[ -e "${IEC_REPO_PATH}" ] || su - "${IEC_USER}" -c \ + "git clone '${IEC_REPO_URI}' '${IEC_REPO_PATH}'" +# shellcheck disable=SC2086 +wait_for 3.0 "! salt-cp 'iec*' -C '${IEC_SCRIPTS_PATH}/' \ + '$(dirname ${IEC_SCRIPTS_PATH})' | grep -e False" +salt -C 'iec*' cmd.run "chown -R ${IEC_USER}:${IEC_USER} ${IEC_REPO_PATH}" + +salt -C 'iec*' cmd.run runas="${IEC_USER}" "${IEC_SCRIPTS_PATH}/k8s_common.sh" + +IEC_MASTER_IP=$(salt --out txt -C 'iec* and *01*' pillar.get \ + _param:single_address | cut -d ' ' -f2) +salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" \ + "${IEC_SCRIPTS_PATH}/k8s_master.sh ${IEC_MASTER_IP} ${POD_NETWORK_CIDR}" + +KUBE_NODE_CNT=$(salt --out txt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" \ + 'kubectl get nodes | grep -c -e "^iec"' | cut -d ' ' -f2) +if [ "${KUBE_NODE_CNT}" != "$(salt-key | grep -c -e '^iec')" ]; then + KUBE_JOIN_CMD=$(salt --out txt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" \ + 'kubeadm token create --print-join-command' | cut -d ' ' -f2-) + salt -C 'iec* and not *01*' cmd.run "${KUBE_JOIN_CMD}" +fi +salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" 'kubectl get nodes' + +salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" \ + "${IEC_SCRIPTS_PATH}/setup-cni.sh '' ${POD_NETWORK_CIDR}" +salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" "${IEC_SCRIPTS_PATH}/nginx.sh" +salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" "${IEC_SCRIPTS_PATH}/helm.sh" diff --git a/mcp/config/states/baremetal_init b/mcp/config/states/baremetal_init index ba7ae30e5..992821571 100755 --- a/mcp/config/states/baremetal_init +++ b/mcp/config/states/baremetal_init @@ -14,7 +14,6 @@ source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh" source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/xdf_data.sh" cluster_nodes_query="${control_nodes_query} or cmp*" -compute_nodes_query='cmp*' # KVM, compute node prereqs # patch the networking module for Debian based distros @@ -27,12 +26,12 @@ salt -C "${cluster_nodes_query}" file.replace $debian_ip_source \ repl="\n if not __salt__['pkg.version']('vlan'):\n __salt__['pkg.install']('vlan')" salt -C "${cluster_nodes_query}" pkg.install bridge-utils -salt -C "${control_nodes_query}" state.apply linux.system.repo,linux.network,linux.system.kernel +salt -C "${cluster_nodes_query}" state.apply linux.system.repo wait_for 5.0 "salt -C '${cluster_nodes_query}' state.apply salt.minion" -wait_for 5.0 "salt -C '${compute_nodes_query}' state.apply linux.system,linux.network" +wait_for 5.0 "salt -C '${cluster_nodes_query}' state.apply linux,ntp" wait_for 30.0 "salt -C '${cluster_nodes_query}' test.ping" -salt -C "${cluster_nodes_query}" system.reboot +salt -C "${cluster_nodes_query}" cmd.run 'reboot' wait_for 90.0 "salt -C '${cluster_nodes_query}' test.ping" salt -C "${cluster_nodes_query}" state.apply linux,ntp diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane index ffb2c594e..183360b96 100755 --- a/mcp/config/states/virtual_control_plane +++ b/mcp/config/states/virtual_control_plane @@ -27,11 +27,7 @@ if [ "${ERASE_ENV}" -eq 1 ]; then fi # KVM libvirt first, VCP deployment -if salt -C 'kvm*' match.grain 'cpuarch:aarch64' \ - --out yaml --static | grep -q -e 'true' ; then - wait_for 5.0 "salt -C 'G@cpuarch:aarch64 and kvm*' state.sls armband" -fi -wait_for 5.0 "salt -C 'kvm*' state.sls libvirt" +wait_for 5.0 "salt -C 'kvm*' state.sls armband,libvirt" salt -C 'kvm* or cmp*' state.apply salt wait_for 10.0 "salt -C 'kvm*' state.sls salt.control,linux.system.kernel" @@ -58,7 +54,7 @@ wait_for 10.0 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply linux,ntp" wait_for 10.0 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_USER} \ $(awk 'NR==1{print $2}' "$(eval echo "~${SUDO_USER}/.ssh/authorized_keys")")" -salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' system.reboot +salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' cmd.run 'reboot' wait_for 30.0 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' test.ping" salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' pkg.upgrade refresh=False dist_upgrade=True diff --git a/mcp/config/states/virtual_init b/mcp/config/states/virtual_init index e8837571b..38a141a3e 100755 --- a/mcp/config/states/virtual_init +++ b/mcp/config/states/virtual_init @@ -33,7 +33,7 @@ wait_for 3.0 "salt -C 'E@^(${NODE_MASK}).*' saltutil.sync_all" wait_for 3.0 "salt -C 'E@^(${NODE_MASK}).*' state.sls linux" -salt -C "E@^(${NODE_MASK}).*" system.reboot +salt -C "E@^(${NODE_MASK}).*" cmd.run 'reboot' wait_for 90.0 "salt -C 'E@^(${NODE_MASK}).*' test.ping" wait_for 3.0 "salt -C 'E@^(${NODE_MASK}).*' pkg.upgrade refresh=False dist_upgrade=True" wait_for 3.0 "salt -C 'E@^(${NODE_MASK}).*' state.apply salt,ntp" -- cgit 1.2.3-korg