Skip to content

Commit 09d5d83

Browse files
authored
Merge pull request #198 from oracle/voyager-integ
OWLS-64528 - Integrate Voyager to WLS Operator
2 parents 8413056 + 2066884 commit 09d5d83

File tree

6 files changed

+327
-195
lines changed

6 files changed

+327
-195
lines changed

kubernetes/create-weblogic-domain-inputs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ exposeAdminNodePort: false
8989
# Name of the domain namespace
9090
namespace: default
9191

92-
# Load balancer to deploy. Supported values are:TRAEFIK, NONE
92+
# Load balancer to deploy. Supported values are:TRAEFIK, VOYAGER, NONE
9393
loadBalancer: TRAEFIK
9494

9595
# Load balancer web port

kubernetes/delete-weblogic-domain-resources.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ cat << EOF
5353
EOF
5454
}
5555

56-
5756
#
5857
# getDomainResources domain(s) outfilename
5958
#
@@ -75,8 +74,12 @@ function getDomainResources {
7574
LABEL_SELECTOR="weblogic.domainUID in ($1)"
7675
fi
7776

78-
# first, let's get all namespaced types with -l $LABEL_SELECTOR
77+
# clean the output file
78+
if [ -e $2 ]; then
79+
rm $2
80+
fi
7981

82+
# first, let's get all namespaced types with -l $LABEL_SELECTOR
8083
NAMESPACED_TYPES="pod,job,deploy,rs,service,pvc,ingress,cm,serviceaccount,role,rolebinding,secret"
8184

8285
# if domain crd exists, look for domains too:
@@ -85,10 +88,15 @@ function getDomainResources {
8588
NAMESPACED_TYPES="domain,$NAMESPACED_TYPES"
8689
fi
8790

91+
VOYAGER_ING_NAME="ingresses.voyager.appscode.com"
92+
if [ `kubectl get crd $VOYAGER_ING_NAME |grep $VOYAGER_ING_NAME | wc -l` = 1 ]; then
93+
NAMESPACED_TYPES="$VOYAGER_ING_NAME,$NAMESPACED_TYPES"
94+
fi
95+
8896
kubectl get $NAMESPACED_TYPES \
8997
-l "$LABEL_SELECTOR" \
9098
-o=jsonpath='{range .items[*]}{.kind}{" "}{.metadata.name}{" -n "}{.metadata.namespace}{"\n"}{end}' \
91-
--all-namespaces=true > $2
99+
--all-namespaces=true >> $2
92100

93101
# now, get all non-namespaced types with -l $LABEL_SELECTOR
94102

@@ -196,9 +204,9 @@ function deleteDomains {
196204
# for each namespace with leftover resources, try delete them
197205
cat $tempfile | awk '{ print $4 }' | grep -v "^$" | sort -u | while read line; do
198206
if [ "$test_mode" = "true" ]; then
199-
echo kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR"
207+
echo kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR"
200208
else
201-
kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR"
209+
kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR"
202210
fi
203211
done
204212

@@ -260,3 +268,4 @@ if [ ! -x "$(command -v kubectl)" ]; then
260268
fi
261269

262270
deleteDomains "${domains}" "${maxwaitsecs:-$default_maxwaitsecs}"
271+

kubernetes/internal/create-weblogic-domain.sh

Lines changed: 101 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@ function validateLoadBalancer {
183183
case ${loadBalancer} in
184184
"TRAEFIK")
185185
;;
186+
"VOYAGER")
187+
;;
186188
"NONE")
187189
;;
188190
*)
189-
validationError "Invalid value for loadBalancer: ${loadBalancer}. Valid values are TRAEFIK and NONE."
191+
validationError "Invalid value for loadBalancer: ${loadBalancer}. Valid values are TRAEFIK, VOYAGER and NONE."
190192
;;
191193
esac
192194
fi
@@ -339,6 +341,11 @@ function initialize {
339341
validationError "The template file ${traefikInput} for generating the traefik deployment was not found"
340342
fi
341343

344+
voyagerInput="${scriptDir}/voyager-ingress-template.yaml"
345+
if [ ! -f ${voyagerInput} ]; then
346+
validationError "The template file ${voyagerInput} for generating the Voyager Ingress was not found"
347+
fi
348+
342349
failIfValidationErrors
343350

344351
# Parse the commonn inputs file
@@ -407,6 +414,7 @@ function createYamlFiles {
407414
dcrOutput="${domainOutputDir}/domain-custom-resource.yaml"
408415
traefikSecurityOutput="${domainOutputDir}/weblogic-domain-traefik-security-${clusterNameLC}.yaml"
409416
traefikOutput="${domainOutputDir}/weblogic-domain-traefik-${clusterNameLC}.yaml"
417+
voyagerOutput="${domainOutputDir}/voyager-ingress.yaml"
410418

411419
enabledPrefix="" # uncomment the feature
412420
disabledPrefix="# " # comment out the feature
@@ -493,25 +501,40 @@ function createYamlFiles {
493501
sed -i -e "s:%JAVA_OPTIONS%:${javaOptions}:g" ${dcrOutput}
494502
sed -i -e "s:%STARTUP_CONTROL%:${startupControl}:g" ${dcrOutput}
495503

496-
# Traefik file
497-
cp ${traefikInput} ${traefikOutput}
498-
echo Generating ${traefikOutput}
499-
sed -i -e "s:%NAMESPACE%:$namespace:g" ${traefikOutput}
500-
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${traefikOutput}
501-
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${traefikOutput}
502-
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${traefikOutput}
503-
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikOutput}
504-
sed -i -e "s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort:g" ${traefikOutput}
505-
sed -i -e "s:%LOAD_BALANCER_DASHBOARD_PORT%:$loadBalancerDashboardPort:g" ${traefikOutput}
506-
507-
# Traefik security file
508-
cp ${traefikSecurityInput} ${traefikSecurityOutput}
509-
echo Generating ${traefikSecurityOutput}
510-
sed -i -e "s:%NAMESPACE%:$namespace:g" ${traefikSecurityOutput}
511-
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${traefikSecurityOutput}
512-
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${traefikSecurityOutput}
513-
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${traefikSecurityOutput}
514-
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikSecurityOutput}
504+
if [ "${loadBalancer}" = "TRAEFIK" ]; then
505+
# Traefik file
506+
cp ${traefikInput} ${traefikOutput}
507+
echo Generating ${traefikOutput}
508+
sed -i -e "s:%NAMESPACE%:$namespace:g" ${traefikOutput}
509+
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${traefikOutput}
510+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${traefikOutput}
511+
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${traefikOutput}
512+
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikOutput}
513+
sed -i -e "s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort:g" ${traefikOutput}
514+
sed -i -e "s:%LOAD_BALANCER_DASHBOARD_PORT%:$loadBalancerDashboardPort:g" ${traefikOutput}
515+
516+
# Traefik security file
517+
cp ${traefikSecurityInput} ${traefikSecurityOutput}
518+
echo Generating ${traefikSecurityOutput}
519+
sed -i -e "s:%NAMESPACE%:$namespace:g" ${traefikSecurityOutput}
520+
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${traefikSecurityOutput}
521+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${traefikSecurityOutput}
522+
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${traefikSecurityOutput}
523+
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikSecurityOutput}
524+
fi
525+
526+
if [ "${loadBalancer}" = "VOYAGER" ]; then
527+
# Voyager Ingress file
528+
cp ${voyagerInput} ${voyagerOutput}
529+
echo Generating ${voyagerOutput}
530+
sed -i -e "s:%NAMESPACE%:$namespace:g" ${voyagerOutput}
531+
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${voyagerOutput}
532+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${voyagerOutput}
533+
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${voyagerOutput}
534+
sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${voyagerOutput}
535+
sed -i -e "s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort:g" ${voyagerOutput}
536+
sed -i -e "s:%LOAD_BALANCER_DASHBOARD_PORT%:$loadBalancerDashboardPort:g" ${voyagerOutput}
537+
fi
515538

516539
# Remove any "...yaml-e" files left over from running sed
517540
rm -f ${domainOutputDir}/*.yaml-e
@@ -604,6 +627,59 @@ function createDomain {
604627

605628
}
606629

630+
#
631+
# Deploy Voyager/HAProxy load balancer
632+
#
633+
function setupVoyagerLoadBalancer {
634+
# only deploy Voyager Ingress Controller the first time
635+
local vpod=`kubectl get pod -n voyager | grep voyager | wc -l`
636+
if [ "$vpod" == "0" ]; then
637+
kubectl create namespace voyager
638+
curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0/hack/deploy/voyager.sh \
639+
| bash -s -- --provider=baremetal --namespace=voyager
640+
fi
641+
642+
# verify Voyager controller pod is ready
643+
local ready=`kubectl -n voyager get pod | grep voyager-operator | awk ' { print $2; } '`
644+
if [ "${ready}" != "1/1" ] ; then
645+
fail "Voyager Ingress Controller is not ready"
646+
fi
647+
648+
# deploy Voyager Ingress resource
649+
kubectl apply -f ${voyagerOutput}
650+
651+
echo Checking Voyager Ingress resource
652+
local maxwaitsecs=100
653+
local mstart=`date +%s`
654+
while : ; do
655+
local mnow=`date +%s`
656+
local vdep=`kubectl get ingresses.voyager.appscode.com -n ${namespace} | grep ${domainUID}-voyager | wc | awk ' { print $1; } '`
657+
if [ "$vdep" = "1" ]; then
658+
echo 'The Voyager Ingress resource ${domainUID}-voyager is created successfully.'
659+
break
660+
fi
661+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
662+
fail "The Voyager Ingress resource ${domainUID}-voyager was not created."
663+
fi
664+
sleep 5
665+
done
666+
667+
echo Checking Voyager service
668+
local maxwaitsecs=100
669+
local mstart=`date +%s`
670+
while : ; do
671+
local mnow=`date +%s`
672+
local vscv=`kubectl get service ${domainUID}-voyager-stats -n ${namespace} | grep ${domainUID}-voyager-stats | wc | awk ' { print $1; } '`
673+
if [ "$vscv" = "1" ]; then
674+
echo 'The service ${domainUID}-voyager-stats is created successfully.'
675+
break
676+
fi
677+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
678+
fail "The service ${domainUID}-voyager-stats was not created."
679+
fi
680+
sleep 5
681+
done
682+
}
607683
#
608684
# Deploy traefik load balancer
609685
#
@@ -702,7 +778,7 @@ function outputJobSummary {
702778
if [ "${exposeAdminT3Channel}" = true ]; then
703779
echo "T3 access is available at t3:${K8S_IP}:${t3ChannelPort}"
704780
fi
705-
if [ "${loadBalancer}" = "TRAEFIK" ]; then
781+
if [ "${loadBalancer}" = "TRAEFIK" ] || [ "${loadBalancer}" = "VOYAGER" ]; then
706782
echo "The load balancer for cluster '${clusterName}' is available at http:${K8S_IP}:${loadBalancerWebPort}/ (add the application path to the URL)"
707783
echo "The load balancer dashboard for cluster '${clusterName}' is available at http:${K8S_IP}:${loadBalancerDashboardPort}"
708784
echo ""
@@ -716,6 +792,8 @@ function outputJobSummary {
716792
if [ "${loadBalancer}" = "TRAEFIK" ]; then
717793
echo " ${traefikSecurityOutput}"
718794
echo " ${traefikOutput}"
795+
elif [ "${loadBalancer}" = "VOYAGER" ]; then
796+
echo " ${voyagerOutput}"
719797
fi
720798
}
721799

@@ -746,6 +824,8 @@ if [ "${generateOnly}" = false ]; then
746824
# Setup load balancer
747825
if [ "${loadBalancer}" = "TRAEFIK" ]; then
748826
setupTraefikLoadBalancer
827+
elif [ "${loadBalancer}" = "VOYAGER" ]; then
828+
setupVoyagerLoadBalancer
749829
fi
750830

751831
# Create the domain custom resource
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: voyager.appscode.com/v1beta1
2+
kind: Ingress
3+
metadata:
4+
name: %DOMAIN_UID%-voyager
5+
namespace: %NAMESPACE%
6+
labels:
7+
weblogic.domainUID: %DOMAIN_UID%
8+
weblogic.domainName: %DOMAIN_NAME%
9+
annotations:
10+
ingress.appscode.com/type: 'NodePort'
11+
ingress.appscode.com/stats: 'true'
12+
spec:
13+
rules:
14+
- host: %DOMAIN_UID%.%CLUSTER_NAME%
15+
http:
16+
nodePort: '%LOAD_BALANCER_WEB_PORT%'
17+
paths:
18+
- backend:
19+
serviceName: %DOMAIN_UID%-cluster-%CLUSTER_NAME%
20+
servicePort: '%MANAGED_SERVER_PORT%'
21+
22+
---
23+
apiVersion: v1
24+
kind: Service
25+
metadata:
26+
name: %DOMAIN_UID%-voyager-stats
27+
namespace: %NAMESPACE%
28+
labels:
29+
app: %DOMAIN_UID%-voyager-stats
30+
weblogic.domainUID: %DOMAIN_UID%
31+
weblogic.domainName: %DOMAIN_NAME%
32+
spec:
33+
type: NodePort
34+
ports:
35+
- name: client
36+
protocol: TCP
37+
port: 56789
38+
targetPort: 56789
39+
nodePort: %LOAD_BALANCER_DASHBOARD_PORT%
40+
selector:
41+
origin: voyager
42+
origin-name: %DOMAIN_UID%-voyager

0 commit comments

Comments
 (0)