Skip to content

Commit 83eb5c4

Browse files
authored
Merge pull request #339 from oracle/issue_293
use predefined yaml files to install and uninstall voyager controller
2 parents b0d151b + 6d5200f commit 83eb5c4

19 files changed

+1516
-100
lines changed

kubernetes/delete-weblogic-domain-resources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function deleteVoyager {
6161
if [ `kubectl get crd $VOYAGER_ING_NAME |grep $VOYAGER_ING_NAME | wc -l` = 1 ]; then
6262
if [ `kubectl get $VOYAGER_ING_NAME -l weblogic.domainName --all-namespaces=true | grep "voyager" | wc -l` -eq 0 ]; then
6363
echo @@ There are no voyager ingress, about to uninstall voyager.
64-
deleteVoyagerController
64+
deleteVoyagerOperator
6565
fi
6666
fi
6767
}

kubernetes/internal/create-weblogic-domain.sh

Lines changed: 35 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,19 @@ function initialize {
371371
validationError "The template file ${apacheInput} for generating the apache-webtier deployment was not found"
372372
fi
373373

374-
voyagerInput="${scriptDir}/voyager-ingress-template.yaml"
375-
if [ ! -f ${voyagerInput} ]; then
376-
validationError "The template file ${voyagerInput} for generating the Voyager Ingress was not found"
374+
voyagerOperatorInput="${scriptDir}/voyager-operator.yaml"
375+
if [ ! -f ${voyagerOperatorInput} ]; then
376+
validationError "The file ${voyagerOperatorInput} for Voyager Operator was not found"
377+
fi
378+
379+
voyagerSecurityInput="${scriptDir}/voyager-operator-security.yaml"
380+
if [ ! -f ${voyagerSecurityInput} ]; then
381+
validationError "The file ${voyagerSecurityInput} for generating the Voyager RBAC was not found"
382+
fi
383+
384+
voyagerIngressInput="${scriptDir}/weblogic-domain-voyager-ingress-template.yaml"
385+
if [ ! -f ${voyagerIngressInput} ]; then
386+
validationError "The template file ${voyagerIngressInput} for generating the Voyager Ingress was not found"
377387
fi
378388

379389
failIfValidationErrors
@@ -449,7 +459,9 @@ function createYamlFiles {
449459
traefikOutput="${domainOutputDir}/weblogic-domain-traefik-${clusterNameLC}.yaml"
450460
apacheOutput="${domainOutputDir}/weblogic-domain-apache.yaml"
451461
apacheSecurityOutput="${domainOutputDir}/weblogic-domain-apache-security.yaml"
452-
voyagerOutput="${domainOutputDir}/voyager-ingress.yaml"
462+
voyagerSecurityOutput="${domainOutputDir}/voyager-operator-security.yaml"
463+
voyagerOperatorOutput="${domainOutputDir}/voyager-operator.yaml"
464+
voyagerIngressOutput="${domainOutputDir}/weblogic-domain-voyager-ingress.yaml"
453465

454466
enabledPrefix="" # uncomment the feature
455467
disabledPrefix="# " # comment out the feature
@@ -620,17 +632,21 @@ function createYamlFiles {
620632
fi
621633

622634
if [ "${loadBalancer}" = "VOYAGER" ]; then
635+
# Voyager Operator Security yaml file
636+
cp ${voyagerSecurityInput} ${voyagerSecurityOutput}
637+
# Voyager Operator yaml file
638+
cp ${voyagerOperatorInput} ${voyagerOperatorOutput}
623639
# Voyager Ingress file
624-
cp ${voyagerInput} ${voyagerOutput}
625-
echo Generating ${voyagerOutput}
626-
sed -i -e "s:%NAMESPACE%:$namespace:g" ${voyagerOutput}
627-
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${voyagerOutput}
628-
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${voyagerOutput}
629-
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${voyagerOutput}
630-
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${voyagerOutput}
631-
sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${voyagerOutput}
632-
sed -i -e "s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort:g" ${voyagerOutput}
633-
sed -i -e "s:%LOAD_BALANCER_DASHBOARD_PORT%:$loadBalancerDashboardPort:g" ${voyagerOutput}
640+
cp ${voyagerIngressInput} ${voyagerIngressOutput}
641+
echo Generating ${voyagerIngressOutput}
642+
sed -i -e "s:%NAMESPACE%:$namespace:g" ${voyagerIngressOutput}
643+
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${voyagerIngressOutput}
644+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${voyagerIngressOutput}
645+
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${voyagerIngressOutput}
646+
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${voyagerIngressOutput}
647+
sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${voyagerIngressOutput}
648+
sed -i -e "s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort:g" ${voyagerIngressOutput}
649+
sed -i -e "s:%LOAD_BALANCER_DASHBOARD_PORT%:$loadBalancerDashboardPort:g" ${voyagerIngressOutput}
634650
fi
635651

636652
# Remove any "...yaml-e" files left over from running sed
@@ -728,79 +744,8 @@ function createDomain {
728744
# Deploy Voyager/HAProxy load balancer
729745
#
730746
function setupVoyagerLoadBalancer {
731-
# only deploy Voyager Ingress Controller the first time
732-
local vpod=`kubectl get pod -n voyager | grep voyager | wc -l`
733-
if [ "$vpod" == "0" ]; then
734-
kubectl create namespace voyager
735-
curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0/hack/deploy/voyager.sh \
736-
| bash -s -- --provider=baremetal --namespace=voyager
737-
fi
738-
739-
echo Checking voyager controller pod is ready
740-
local maxwaitsecs=30
741-
local mstart=`date +%s`
742-
while : ; do
743-
local mnow=`date +%s`
744-
local ready=`kubectl -n voyager get pod | grep voyager-operator | awk ' { print $2; } '`
745-
if [ "${ready}" = "1/1" ] ; then
746-
echo "Voyager Ingress Controller is ready"
747-
break
748-
fi
749-
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
750-
fail "The Voyager Ingress Controller is not ready."
751-
fi
752-
sleep 1
753-
done
754-
755-
kubectl apply -f ${voyagerOutput}
756-
757-
echo Checking Voyager Ingress resource
758-
local maxwaitsecs=100
759-
local mstart=`date +%s`
760-
while : ; do
761-
local mnow=`date +%s`
762-
local vdep=`kubectl get ingresses.voyager.appscode.com -n ${namespace} | grep ${domainUID}-voyager | wc | awk ' { print $1; } '`
763-
if [ "$vdep" = "1" ]; then
764-
echo "The Voyager Ingress resource ${domainUID}-voyager is created successfully."
765-
break
766-
fi
767-
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
768-
fail "The Voyager Ingress resource ${domainUID}-voyager was not created."
769-
fi
770-
sleep 5
771-
done
772-
773-
echo Checking HAProxy pod is running
774-
local maxwaitsecs=100
775-
local mstart=`date +%s`
776-
while : ; do
777-
local mnow=`date +%s`
778-
local st=`kubectl get pod -n ${namespace} | grep ^voyager-${domainUID}-voyager- | awk ' { print $3; } '`
779-
if [ "$st" = "Running" ]; then
780-
echo "The HAProxy pod for Voyaer Ingress ${domainUID}-voyager is created successfully."
781-
break
782-
fi
783-
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
784-
fail "The HAProxy pod for Voyaer Ingress ${domainUID}-voyager was not created or running."
785-
fi
786-
sleep 5
787-
done
788-
789-
echo Checking Voyager service
790-
local maxwaitsecs=100
791-
local mstart=`date +%s`
792-
while : ; do
793-
local mnow=`date +%s`
794-
local vscv=`kubectl get service ${domainUID}-voyager-stats -n ${namespace} | grep ${domainUID}-voyager-stats | wc | awk ' { print $1; } '`
795-
if [ "$vscv" = "1" ]; then
796-
echo 'The service ${domainUID}-voyager-stats is created successfully.'
797-
break
798-
fi
799-
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
800-
fail "The service ${domainUID}-voyager-stats was not created."
801-
fi
802-
sleep 5
803-
done
747+
createVoyagerOperator ${voyagerSecurityOutput} ${voyagerOperatorOutput}
748+
createVoyagerIngress ${voyagerIngressOutput} ${namespace} ${domainUID}
804749
}
805750

806751
#
@@ -966,7 +911,9 @@ function outputJobSummary {
966911
echo " ${apacheSecurityOutput}"
967912
echo " ${apacheOutput}"
968913
elif [ "${loadBalancer}" = "VOYAGER" ]; then
969-
echo " ${voyagerOutput}"
914+
echo " ${voyagerOperatorOutput}"
915+
echo " ${voyagerSecurityOutput}"
916+
echo " ${voyagerIngressOutput}"
970917
fi
971918
}
972919

kubernetes/internal/utility.sh

Lines changed: 213 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,217 @@ function copyInputsFileToOutputDirectory {
315315
fi
316316
}
317317

318-
# uninstall voyager and delete namespace
319-
function deleteVoyagerController {
320-
curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0/hack/deploy/voyager.sh \
321-
| bash -s -- --provider=baremetal --namespace=voyager --uninstall --purge
322-
kubectl delete namespace voyager
318+
VOYAGER_ING_NAME="ingresses.voyager.appscode.com"
319+
#
320+
# Usage:
321+
# createVoyagerOperator voyagerSecurityYaml voyagerOperatorYaml
322+
#
323+
# If the voyager operator is already running, do nothing.
324+
#
325+
function createVoyagerOperator() {
326+
if [ "$#" != 2 ] ; then
327+
fail "requires 2 parameter: voyagerSecurityYaml voyagerOperatorYaml"
328+
fi
329+
330+
local vnamespace=voyager
331+
# only deploy Voyager Operator once
332+
if test "$(kubectl get pod -n $vnamespace --ignore-not-found | grep voyager | wc -l)" == 0; then
333+
echo "Deploying Voyager Operator to namespace $vnamespace..."
334+
335+
if test "$(kubectl get namespace $vnamespace --ignore-not-found | wc -l)" = 0; then
336+
kubectl create namespace $vnamespace
337+
fi
338+
kubectl apply -f $1
339+
kubectl apply -f $2
340+
fi
341+
342+
echo "Wait until Voyager Operator is ready..."
343+
local maxwaitsecs=100
344+
local mstart=`date +%s`
345+
while : ; do
346+
local mnow=`date +%s`
347+
if test "$(kubectl -n $vnamespace get pod --ignore-not-found | grep voyager-operator | awk ' { print $2; } ')" = "1/1"; then
348+
echo "The Voyager Operator is ready."
349+
break
350+
fi
351+
if test $((mnow - mstart)) -gt $((maxwaitsecs)); then
352+
fail "The Voyager Operator is not ready."
353+
fi
354+
sleep 5
355+
done
356+
357+
echo "Checking apiserver..."
358+
local maxwaitsecs=10
359+
local mstart=`date +%s`
360+
while test "$(kubectl get apiservice | grep v1beta1.admission.voyager.appscode.com | wc -l)" = 0; do
361+
sleep 2
362+
local mnow=`date +%s`
363+
if test $((mnow - mstart)) -gt $((maxwaitsecs)); then
364+
fail "The Voyager apiserver v1beta1.admission.voyager.appscode.com is not ready."
365+
fi
366+
done
367+
echo "The Voyager apiserver is ready."
368+
369+
echo "Checking Voyager CRDs..."
370+
local maxwaitsecs=10
371+
local mstart=`date +%s`
372+
while test "$(kubectl get crd | grep certificates.voyager.appscode.com | wc -l)" = 0; do
373+
sleep 2
374+
local mnow=`date +%s`
375+
if test $((mnow - mstart)) -gt $((maxwaitsecs)); then
376+
fail "The Voyager CRD certificates.voyager.appscode.com is not ready."
377+
fi
378+
done
379+
echo "The Voyager CRD certificates.voyager.appscode.com is ready."
380+
381+
local maxwaitsecs=10
382+
local mstart=`date +%s`
383+
while test "$(kubectl get crd | grep $VOYAGER_ING_NAME | wc -l)" = 0; do
384+
sleep 2
385+
local mnow=`date +%s`
386+
if test $((mnow - mstart)) -gt $((maxwaitsecs)); then
387+
fail "The Voyager CRD $VOYAGER_ING_NAME is not ready."
388+
fi
389+
done
390+
echo "The Voyager CRD $VOYAGER_ING_NAME is ready."
391+
echo
392+
}
393+
394+
#
395+
# delete voyager operator
396+
#
397+
function deleteVoyagerOperator {
398+
local vnamespace=voyager
399+
if test "$(kubectl get pod -n $vnamespace --ignore-not-found | grep voyager | wc -l)" == 0; then
400+
echo "Voyager operator has already been deleted."
401+
return
402+
fi
403+
404+
echo "Deleting Voyager opreator resources"
405+
kubectl delete apiservice -l app=voyager
406+
# delete voyager operator
407+
kubectl delete deployment -l app=voyager --namespace $vnamespace
408+
kubectl delete service -l app=voyager --namespace $vnamespace
409+
kubectl delete secret -l app=voyager --namespace $vnamespace
410+
# delete RBAC objects
411+
kubectl delete serviceaccount -l app=voyager --namespace $vnamespace
412+
kubectl delete clusterrolebindings -l app=voyager
413+
kubectl delete clusterrole -l app=voyager
414+
kubectl delete rolebindings -l app=voyager --namespace $vnamespace
415+
kubectl delete role -l app=voyager --namespace $vnamespace
416+
417+
echo "Wait until voyager operator pod stopped..."
418+
local maxwaitsecs=100
419+
local mstart=`date +%s`
420+
while : ; do
421+
local mnow=`date +%s`
422+
pods=($(kubectl get pods --all-namespaces -l app=voyager -o jsonpath='{range .items[*]}{.metadata.name} {end}'))
423+
total=${#pods[*]}
424+
if [ $total -eq 0 ] ; then
425+
echo "Voyager operator pod is stopped."
426+
break
427+
fi
428+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
429+
fail "Voyager operator pod is NOT stopped."
430+
fi
431+
sleep 5
432+
done
433+
echo
434+
#TODO purge CRDs
435+
}
436+
437+
#
438+
# Usage:
439+
# createVoyagerIngress voyagerIngressYaml namespace domainUID
440+
#
441+
function createVoyagerIngress {
442+
if [ "$#" != 3 ] ; then
443+
fail "requires 1 parameter: voyagerIngressYaml namespace domainUID"
444+
fi
445+
446+
# deploy Voyager Ingress resource
447+
kubectl apply -f $1
448+
449+
local namespace=$2
450+
local domainUID=$3
451+
452+
453+
echo "Checking Voyager Ingress resource..."
454+
local maxwaitsecs=100
455+
local mstart=$(date +%s)
456+
while : ; do
457+
local mnow=$(date +%s)
458+
local vdep=$(kubectl get ingresses.voyager.appscode.com -n ${namespace} | grep ${domainUID}-voyager | wc | awk ' { print $1; } ')
459+
if [ "$vdep" = "1" ]; then
460+
echo "The Voyager Ingress resource ${domainUID}-voyager is created successfully."
461+
break
462+
fi
463+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
464+
fail "The Voyager Ingress resource ${domainUID}-voyager was not created."
465+
fi
466+
sleep 2
467+
done
468+
469+
echo "Wait until HAProxy pod is running..."
470+
local maxwaitsecs=100
471+
local mstart=$(date +%s)
472+
while : ; do
473+
local mnow=$(date +%s)
474+
local st=$(kubectl get pod -n ${namespace} | grep ^voyager-${domainUID}-voyager- | awk ' { print $3; } ')
475+
if [ "$st" = "Running" ]; then
476+
echo "The HAProxy pod for Voyager Ingress ${domainUID}-voyager is running."
477+
break
478+
fi
479+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
480+
fail "The HAProxy pod for Voyager Ingress ${domainUID}-voyager was not created or running."
481+
fi
482+
sleep 5
483+
done
484+
485+
echo "Checking Voyager service..."
486+
local maxwaitsecs=10
487+
local mstart=`date +%s`
488+
while : ; do
489+
local mnow=`date +%s`
490+
local vscv=`kubectl get service ${domainUID}-voyager-stats -n ${namespace} | grep ${domainUID}-voyager-stats | wc | awk ' { print $1; } '`
491+
if [ "$vscv" = "1" ]; then
492+
echo "The service ${domainUID}-voyager-stats is created successfully."
493+
break
494+
fi
495+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
496+
fail "The service ${domainUID}-voyager-stats was not created."
497+
fi
498+
sleep 2
499+
done
500+
echo
501+
}
502+
503+
#
504+
# Usage:
505+
# deleteVoyagerIngress voyagerIngressYaml namespace domainUID
506+
#
507+
function deleteVoyagerIngress {
508+
if [ "$#" != 3 ] ; then
509+
fail "requires 1 parameter: voyagerIngressYaml namespace domainUID"
510+
fi
511+
512+
kubectl delete -f $1
513+
local namespace=$2
514+
local domainUID=$3
515+
516+
echo "Wait until HAProxy pod stoped..."
517+
local maxwaitsecs=100
518+
local mstart=$(date +%s)
519+
while : ; do
520+
local mnow=$(date +%s)
521+
if [ $(kubectl get pod -n ${namespace} | grep "^voyager-${domainUID}-voyager-" | wc -l) = 0 ]; then
522+
echo "The HAProxy pod for Voyaer Ingress ${domainUID}-voyager is stopped."
523+
break
524+
fi
525+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
526+
fail "The HAProxy pod for Voyaer Ingress ${domainUID}-voyager is NOT stopped."
527+
fi
528+
sleep 5
529+
done
530+
echo
323531
}

0 commit comments

Comments
 (0)