Incorporate HWCC in deployment gate.

Added sample HCC profiles and deployment script to apply profiles.

Change-Id: If8152a0afda142c40a53ddf9a4bd6866b435b0e5
Co-Authored-By: Rajat Sharma <rajatcu143@gmail.com>
Relates-To-Issue: #326
Depends-On: #738410
This commit is contained in:
Rajat Sharma 2020-11-10 16:09:10 +05:30
parent d90453a46b
commit 854e25355b
18 changed files with 158 additions and 28 deletions

View File

@ -19,9 +19,8 @@ HWCC will label matched hosts.
`hardwareclassification.metal3.io/<PROFILE-NAME>=<LABEL>`
HWCC also label hosts which are in error state, e.g.
`hardwareclassification-error=registration-error`
HWCC also label hosts which are in error state if
`hardwareclassification-error=All` label is given in workload profile.
HWCC status shows multiple items w.r.t applied profile :
* Name of the profile

View File

@ -20,7 +20,7 @@ spec:
- /manager
args:
- --enable-leader-election
image: quay.io/hwcc/airship-hcc:v1
image: quay.io/dell_sp/hwcc:v1.3
name: manager
resources:
limits:

View File

@ -73,6 +73,19 @@ config:
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: workers-classification
clusterName: target-cluster
config:
cluster: target-cluster
executorRef:
apiVersion: airshipit.org/v1alpha1
kind: KubernetesApply
name: kubernetes-apply
documentEntryPoint: target/workers/provision
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: clusterctl-init-ephemeral
clusterName: ephemeral-cluster

View File

@ -10,4 +10,5 @@ phaseGroups:
- name: controlplane-ephemeral
- name: initinfra-target
- name: workers-target
- name: workers-classification
- name: workload-target

View File

@ -1,5 +1,6 @@
resources:
- ../../../../function/baremetal-operator
- ../../../../function/hwcc
- ../../../../function/clusterctl
- ../../../../composite/infra
- ../catalogues

View File

@ -1,5 +1,6 @@
resources:
- ../../../../function/baremetal-operator
- ../../../../function/hwcc
- ../../../../function/clusterctl
- ../../../../composite/flux-helm
- ../../../../composite/infra

View File

@ -2,10 +2,3 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- nodes
- kubeadmconfigtemplate.yaml
- metal3machinetemplate.yaml
- machinedeployment.yaml
- ../../../../function/airshipctl-base-catalogues
transformers:
- replacements

View File

@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../../../function/airshipctl-base-catalogues
- ../../../../../type/gating/hwccprofiles
- kubeadmconfigtemplate.yaml
- metal3machinetemplate.yaml
- machinedeployment.yaml
transformers:
- ../replacements

View File

@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- profile1.yaml
- profile2.yaml

View File

@ -0,0 +1,26 @@
apiVersion: metal3.io/v1alpha1
kind: HardwareClassification
metadata:
name: hardwareclassification-profile1
namespace: default
labels:
hardwareclassification-profile1: matches
hardwareclassification-error: All
spec:
hardwareCharacteristics:
cpu:
minimumCount: 1
maximumCount: 72
minimumSpeedMHz: 1000
maximumSpeedMHz: 3600
disk:
minimumCount: 1
maximumCount: 8
minimumIndividualSizeGB: 1
maximumIndividualSizeGB: 3000
ram:
minimumSizeGB: 1
maximumSizeGB: 180
nic:
minimumCount: 1
maximumCount: 7

View File

@ -0,0 +1,26 @@
apiVersion: metal3.io/v1alpha1
kind: HardwareClassification
metadata:
name: hardwareclassification-profile2
namespace: default
labels:
hardwareclassification-profile2: matches
hardwareclassification-error: All
spec:
hardwareCharacteristics:
cpu:
minimumCount: 80
maximumCount: 100
minimumSpeedMHz: 2000
maximumSpeedMHz: 4000
disk:
minimumCount: 20
maximumCount: 80
minimumIndividualSizeGB: 2000
maximumIndividualSizeGB: 3000
ram:
minimumSizeGB: 400
maximumSizeGB: 800
nic:
minimumCount: 50
maximumCount: 70

View File

@ -28,6 +28,7 @@
- ./tools/deployment/33_cluster_move_target_node.sh
- ./tools/deployment/34_deploy_worker_node.sh
- ./tools/deployment/35_deploy_workload.sh
- ./tools/deployment/36_verify_hwcc_profiles.sh
- name: "Run gate scripts"
include_role:

View File

@ -22,24 +22,33 @@ export KUBECONFIG_TARGET_CONTEXT=${KUBECONFIG_TARGET_CONTEXT:-"target-cluster"}
echo "Stop ephemeral node"
sudo virsh destroy air-ephemeral
node_timeout () {
end=$(($(date +%s) + $TIMEOUT))
while true; do
if (kubectl --request-timeout 20s --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT get $1 node03 | grep -qw $2) ; then
echo -e "\nGet $1 status"
kubectl --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT get $1
break
else
now=$(date +%s)
if [ $now -gt $end ]; then
echo -e "\n$1 is not ready before TIMEOUT."
exit 1
fi
echo -n .
sleep 15
fi
done
}
echo "Deploy worker node"
airshipctl phase run workers-target --debug
#Wait till node is created
end=$(($(date +%s) + $TIMEOUT))
echo "Waiting $TIMEOUT seconds for bmh to be in ready state."
node_timeout bmh ready
echo "Classify and provision worker node"
airshipctl phase run workers-classification --debug
echo "Waiting $TIMEOUT seconds for node to be provisioned."
while true; do
if (kubectl --request-timeout 20s --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT get node node03 | grep -qw Ready) ; then
echo -e "\nGet node status"
kubectl --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT get node
break
else
now=$(date +%s)
if [ $now -gt $end ]; then
echo -e "\nWorker node is not ready before TIMEOUT."
exit 1
fi
echo -n .
sleep 15
fi
done
node_timeout node Ready

View File

@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -x
export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"}
export KUBECONFIG_TARGET_CONTEXT=${KUBECONFIG_TARGET_CONTEXT:-"target-cluster"}
declare -A PROFILES
PROFILES[hardwareclassification-profile1]=1
PROFILES[hardwareclassification-profile2]=0
declare -a ERRORS
# HWCC need BMH in Ready state.
for i in "${!PROFILES[@]}"
do
nodes=$(kubectl --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT get bmh --no-headers=true -l hardwareclassification.metal3.io/$i 2>/dev/null | wc -l)
if [ $nodes != ${PROFILES[$i]} ]
then
ERRORS+=($i)
fi
done
if [ ${#ERRORS[@]} != 0 ]
then
echo FAILURE error with ${ERRORS[@]}
exit 1
else
echo "SUCCESS"
fi

View File

@ -141,6 +141,7 @@
- ./tools/deployment/33_cluster_move_target_node.sh
- ./tools/deployment/34_deploy_worker_node.sh
- ./tools/deployment/35_deploy_workload.sh
- ./tools/deployment/36_verify_hwcc_profiles.sh
serve_dir: /srv/iso
serve_port: 8099
log_roles: