Skip to content

Commit 96c4d55

Browse files
authored
Merge branch 'develop' into support-apache-load-balancer
2 parents 28abfe4 + 09d5d83 commit 96c4d55

File tree

16 files changed

+678
-408
lines changed

16 files changed

+678
-408
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, APACHE, NONE
92+
# Load balancer to deploy. Supported values are: APACHE, TRAEFIK, VOYAGER, NONE
9393
loadBalancer: TRAEFIK
9494

9595
# Load balancer app prepath used for APACHE load balancer

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: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,12 @@ function validateLoadBalancer {
188188
;;
189189
"APACHE")
190190
;;
191+
"VOYAGER")
192+
;;
191193
"NONE")
192194
;;
193195
*)
194-
validationError "Invalid value for loadBalancer: ${loadBalancer}. Valid values are TRAEFIK, APACHE and NONE."
196+
validationError "Invalid value for loadBalancer: ${loadBalancer}. Valid values are APACHE, TRAEFIK, VOYAGER and NONE."
195197
;;
196198
esac
197199
fi
@@ -352,6 +354,10 @@ function initialize {
352354
apacheInput="${scriptDir}/weblogic-domain-apache-template.yaml"
353355
if [ ! -f ${apacheInput} ]; then
354356
validationError "The template file ${apacheInput} for generating the apache-webtier deployment was not found"
357+
358+
voyagerInput="${scriptDir}/voyager-ingress-template.yaml"
359+
if [ ! -f ${voyagerInput} ]; then
360+
validationError "The template file ${voyagerInput} for generating the Voyager Ingress was not found"
355361
fi
356362

357363
failIfValidationErrors
@@ -424,7 +430,7 @@ function createYamlFiles {
424430
traefikOutput="${domainOutputDir}/weblogic-domain-traefik-${clusterNameLC}.yaml"
425431
apacheOutput="${domainOutputDir}/weblogic-domain-apache.yaml"
426432
apacheSecurityOutput="${domainOutputDir}/weblogic-domain-apache-security.yaml"
427-
433+
voyagerOutput="${domainOutputDir}/voyager-ingress.yaml"
428434

429435
enabledPrefix="" # uncomment the feature
430436
disabledPrefix="# " # comment out the feature
@@ -531,8 +537,9 @@ function createYamlFiles {
531537
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${traefikSecurityOutput}
532538
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${traefikSecurityOutput}
533539
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikSecurityOutput}
540+
fi
534541

535-
elif [ "${loadBalancer}" = "APACHE" ]; then
542+
if [ "${loadBalancer}" = "APACHE" ]; then
536543
# Apache file
537544
cp ${apacheInput} ${apacheOutput}
538545
echo Generating ${apacheOutput}
@@ -565,6 +572,19 @@ function createYamlFiles {
565572
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${apacheSecurityOutput}
566573
fi
567574

575+
if [ "${loadBalancer}" = "VOYAGER" ]; then
576+
# Voyager Ingress file
577+
cp ${voyagerInput} ${voyagerOutput}
578+
echo Generating ${voyagerOutput}
579+
sed -i -e "s:%NAMESPACE%:$namespace:g" ${voyagerOutput}
580+
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${voyagerOutput}
581+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${voyagerOutput}
582+
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${voyagerOutput}
583+
sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${voyagerOutput}
584+
sed -i -e "s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort:g" ${voyagerOutput}
585+
sed -i -e "s:%LOAD_BALANCER_DASHBOARD_PORT%:$loadBalancerDashboardPort:g" ${voyagerOutput}
586+
fi
587+
568588
# Remove any "...yaml-e" files left over from running sed
569589
rm -f ${domainOutputDir}/*.yaml-e
570590
}
@@ -656,6 +676,59 @@ function createDomain {
656676

657677
}
658678

679+
#
680+
# Deploy Voyager/HAProxy load balancer
681+
#
682+
function setupVoyagerLoadBalancer {
683+
# only deploy Voyager Ingress Controller the first time
684+
local vpod=`kubectl get pod -n voyager | grep voyager | wc -l`
685+
if [ "$vpod" == "0" ]; then
686+
kubectl create namespace voyager
687+
curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0/hack/deploy/voyager.sh \
688+
| bash -s -- --provider=baremetal --namespace=voyager
689+
fi
690+
691+
# verify Voyager controller pod is ready
692+
local ready=`kubectl -n voyager get pod | grep voyager-operator | awk ' { print $2; } '`
693+
if [ "${ready}" != "1/1" ] ; then
694+
fail "Voyager Ingress Controller is not ready"
695+
fi
696+
697+
# deploy Voyager Ingress resource
698+
kubectl apply -f ${voyagerOutput}
699+
700+
echo Checking Voyager Ingress resource
701+
local maxwaitsecs=100
702+
local mstart=`date +%s`
703+
while : ; do
704+
local mnow=`date +%s`
705+
local vdep=`kubectl get ingresses.voyager.appscode.com -n ${namespace} | grep ${domainUID}-voyager | wc | awk ' { print $1; } '`
706+
if [ "$vdep" = "1" ]; then
707+
echo 'The Voyager Ingress resource ${domainUID}-voyager is created successfully.'
708+
break
709+
fi
710+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
711+
fail "The Voyager Ingress resource ${domainUID}-voyager was not created."
712+
fi
713+
sleep 5
714+
done
715+
716+
echo Checking Voyager service
717+
local maxwaitsecs=100
718+
local mstart=`date +%s`
719+
while : ; do
720+
local mnow=`date +%s`
721+
local vscv=`kubectl get service ${domainUID}-voyager-stats -n ${namespace} | grep ${domainUID}-voyager-stats | wc | awk ' { print $1; } '`
722+
if [ "$vscv" = "1" ]; then
723+
echo 'The service ${domainUID}-voyager-stats is created successfully.'
724+
break
725+
fi
726+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
727+
fail "The service ${domainUID}-voyager-stats was not created."
728+
fi
729+
sleep 5
730+
done
731+
}
659732
#
660733
# Deploy traefik load balancer
661734
#
@@ -798,7 +871,7 @@ function outputJobSummary {
798871
if [ "${exposeAdminT3Channel}" = true ]; then
799872
echo "T3 access is available at t3:${K8S_IP}:${t3ChannelPort}"
800873
fi
801-
if [ "${loadBalancer}" = "TRAEFIK" ]; then
874+
if [ "${loadBalancer}" = "TRAEFIK" ] || [ "${loadBalancer}" = "VOYAGER" ]; then
802875
echo "The load balancer for cluster '${clusterName}' is available at http:${K8S_IP}:${loadBalancerWebPort}/ (add the application path to the URL)"
803876
echo "The load balancer dashboard for cluster '${clusterName}' is available at http:${K8S_IP}:${loadBalancerDashboardPort}"
804877
echo ""
@@ -818,7 +891,8 @@ function outputJobSummary {
818891
elif [ "${loadBalancer}" = "APACHE" ]; then
819892
echo " ${apacheSecurityOutput}"
820893
echo " ${apacheOutput}"
821-
894+
elif [ "${loadBalancer}" = "VOYAGER" ]; then
895+
echo " ${voyagerOutput}"
822896
fi
823897
}
824898

@@ -851,7 +925,8 @@ if [ "${generateOnly}" = false ]; then
851925
setupTraefikLoadBalancer
852926
elif [ "${loadBalancer}" = "APACHE" ]; then
853927
setupApacheLoadBalancer
854-
928+
elif [ "${loadBalancer}" = "VOYAGER" ]; then
929+
setupVoyagerLoadBalancer
855930
fi
856931

857932
# 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)