Merge "Add kubectl-wait-cluster-ephemeral phase"

This commit is contained in:
Zuul 2021-07-20 21:19:38 +00:00 committed by Gerrit Code Review
commit f2833dc4eb
4 changed files with 50 additions and 4 deletions

View File

@ -15,28 +15,29 @@
set -xe
export TIMEOUT=${TIMEOUT:-3600}
export CONDITION=${CONDITION:-"controlPlaneReady"}
end=$(($(date +%s) + $TIMEOUT))
echo "Waiting $TIMEOUT seconds for cluster to reach controlPlaneReady condition" 1>&2
echo "Waiting $TIMEOUT seconds for cluster to reach $CONDITION condition" 1>&2
while true; do
# TODO(vkuzmin): Add ability to wait for multiple clusters
if [ "$(kubectl \
--request-timeout 20s \
--context $KCTL_CONTEXT \
get -f $RENDERED_BUNDLE_PATH \
-o jsonpath='{.status.controlPlaneReady}')" == "true" ]
-o jsonpath={.status.$CONDITION})" == "true" ]
then
echo "Getting information about cluster" 1>&2
kubectl \
--request-timeout 20s \
--context $KCTL_CONTEXT \
get -f $RENDERED_BUNDLE_PATH 1>&2
echo "Cluster successfully reach controlPlaneReady condition" 1>&2
echo "Cluster successfully reach $CONDITION condition" 1>&2
break
else
now=$(date +%s)
if [ $now -gt $end ]; then
echo "Cluster didn't reach controlPlaneReady condition before TIMEOUT=$TIMEOUT, exiting" 1>&2
echo "Cluster didn't reach $CONDITION condition before TIMEOUT=$TIMEOUT, exiting" 1>&2
exit 1
fi
sleep 15

View File

@ -433,6 +433,23 @@ configRef:
---
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
metadata:
name: kubectl-wait-cluster-init
spec:
image: localhost/toolbox
hostNetwork: true
envVars:
- RESOURCE_GROUP_FILTER=cluster.x-k8s.io
- RESOURCE_VERSION_FILTER=v1alpha3
- RESOURCE_KIND_FILTER=Cluster
- CONDITION=controlPlaneInitialized
configRef:
kind: ConfigMap
name: kubectl-wait-cluster
apiVersion: v1
---
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
metadata:
name: virsh-eject-cdrom-images
labels:

View File

@ -291,6 +291,17 @@ config:
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: kubectl-wait-node-target
clusterName: target-cluster
config:
executorRef:
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
name: kubectl-wait-node
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: kubectl-get-node-target
clusterName: target-cluster
@ -391,6 +402,18 @@ config:
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: kubectl-wait-cluster-ephemeral
clusterName: ephemeral-cluster
config:
executorRef:
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
name: kubectl-wait-cluster-init
documentEntryPoint: ephemeral/controlplane
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: kubectl-wait-cluster-target
clusterName: target-cluster

View File

@ -49,6 +49,11 @@ phases:
- name: virsh-eject-cdrom-images
# Create target k8s cluster resources
- name: controlplane-ephemeral
# Wait till the cluster is created
# Scripts for this phase placed in manifests/function/phase-helpers/wait_cluster/
# To get ConfigMap for this phase, execute `airshipctl phase render --source config -k ConfigMap`
# and find ConfigMap with name kubectl-wait-cluster
- name: kubectl-wait-cluster-ephemeral
# List all nodes in target cluster
# Scripts for this phase placed in manifests/function/phase-helpers/get_node/
# To get ConfigMap for this phase, execute `airshipctl phase render --source config -k ConfigMap`