
This change aims to add the airship-in-a-pod test to the gates. This is accomplished by creating new scripts to run which install a minimal k8s environment, and then apply the airship-in-a-pod.yaml. Brief description of scripts 01_dns_settings: Running k8s pods in zuul has a lot of issues with DNS resolution which this resolves. 10_install_minikube: grabs latest minikube and other dependencies. 11_build_images: builds the images under tools/airship-in-a-pod and then adds patches to the kustomize configuration to use and configure them. 12_start_minikube: starts minikube and makes sure kubectl will work 13_apply_dns.sh: This takes some of the effort from 01_dns_settings and incorporates it into the minikube cluster by modifying coredns 20_apply_aiap: Applies the airship-in-a-pod.yaml to the cluster. Has a few loops to check that the cluster is fully running before applying, and to check on the pod to see if it is ready before finishing. Closes: #478 Change-Id: I4c02d04b0eda9395642032bf56b56a0f823c1969
65 lines
2.2 KiB
Bash
Executable File
65 lines
2.2 KiB
Bash
Executable File
#!/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 -ex
|
|
|
|
# This script first loops to check if the K8s cluster is ready before applying
|
|
# airship-in-a-pod to it. Once all of the kube-system pods are ready, it applies
|
|
# the yaml and then checks every so often to determine if all of the containers
|
|
# are ready.
|
|
|
|
|
|
INTERVAL=15
|
|
READY=false
|
|
KUBE_READY=false
|
|
|
|
|
|
# Wait for the Kubernetes environment to become completely ready
|
|
while [[ $KUBE_READY == "false" ]];
|
|
do
|
|
# Grab the readiness from the kubectl output
|
|
kube_pods=$(kubectl get pods -n kube-system | tail -n +2 | awk '{print $2}')
|
|
for POD in $kube_pods; do
|
|
# Compare the two values to determine if each pod is completely ready
|
|
kube_ready_pod=$(echo "$POD" | cut -f1 -d/)
|
|
kube_ready_total=$(echo "$POD" | cut -f2 -d/)
|
|
if [[ "$kube_ready_pod" != "$kube_ready_total" ]]; then
|
|
# If a pod is not ready yet, break out and try again next time
|
|
KUBE_READY=false
|
|
break
|
|
fi
|
|
# This will only stay "true" as long as the previous 'if' is never reached
|
|
KUBE_READY=true
|
|
done
|
|
sleep "$INTERVAL"
|
|
done
|
|
|
|
kustomize build tools/airship-in-a-pod/examples/airshipctl | kubectl apply -f -
|
|
|
|
while [[ $READY == "false" ]];
|
|
do
|
|
# Grab the number of ready containers from the kubectl output
|
|
kubectl get pod airship-in-a-pod -o wide
|
|
readiness=$(kubectl get pods | grep airship-in-a-pod | awk '{print $2}')
|
|
ready_pod=$(echo "$readiness" | cut -f1 -d/)
|
|
ready_total=$(echo "$readiness" | cut -f2 -d/)
|
|
# if it is 7/7 ready (example with 7 containers), then mark ready
|
|
if [[ "$ready_pod" == "$ready_total" ]]; then
|
|
READY=true
|
|
fi
|
|
|
|
sleep "$INTERVAL"
|
|
done
|
|
|