Skip to content

Commit 624aab1

Browse files
committed
Merge branch 'develop' into support-apache-load-balancer
2 parents 78ea79e + 912b3fd commit 624aab1

File tree

18 files changed

+735
-424
lines changed

18 files changed

+735
-424
lines changed

kubernetes/create-weblogic-domain-inputs.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,17 @@ 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

95-
# Load balancer app prepath
95+
# Load balancer app prepath used for APACHE load balancer
96+
# This defines the /location in the built-in Apache plugin configuration module for WebLogic
9697
loadBalancerAppPrepath: /
9798

98-
# Docker volume path for APACHE
99-
# By default, the VolumePath is empty, which will cause the volume mount be disabled
99+
# Docker volume path for APACHE. By default, it is empty, which causes the volume mount be
100+
# disabled and, thereforem the built-in Apache plugin config be used.
101+
# Use this to provide your own Apache plugin configuration as needed; simply define this
102+
# path and put your own custom_mod_wl_apache.conf file under this path.
100103
loadBalancerVolumePath:
101104

102105
# 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: 97 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
@@ -353,6 +355,11 @@ function initialize {
353355
if [ ! -f ${apacheInput} ]; then
354356
validationError "The template file ${apacheInput} for generating the apache-webtier deployment was not found"
355357
fi
358+
359+
voyagerInput="${scriptDir}/voyager-ingress-template.yaml"
360+
if [ ! -f ${voyagerInput} ]; then
361+
validationError "The template file ${voyagerInput} for generating the Voyager Ingress was not found"
362+
fi
356363

357364
failIfValidationErrors
358365

@@ -424,7 +431,7 @@ function createYamlFiles {
424431
traefikOutput="${domainOutputDir}/weblogic-domain-traefik-${clusterNameLC}.yaml"
425432
apacheOutput="${domainOutputDir}/weblogic-domain-apache.yaml"
426433
apacheSecurityOutput="${domainOutputDir}/weblogic-domain-apache-security.yaml"
427-
434+
voyagerOutput="${domainOutputDir}/voyager-ingress.yaml"
428435

429436
enabledPrefix="" # uncomment the feature
430437
disabledPrefix="# " # comment out the feature
@@ -531,8 +538,9 @@ function createYamlFiles {
531538
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${traefikSecurityOutput}
532539
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${traefikSecurityOutput}
533540
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikSecurityOutput}
541+
fi
534542

535-
elif [ "${loadBalancer}" = "APACHE" ]; then
543+
if [ "${loadBalancer}" = "APACHE" ]; then
536544
# Apache file
537545
cp ${apacheInput} ${apacheOutput}
538546
echo Generating ${apacheOutput}
@@ -565,6 +573,19 @@ function createYamlFiles {
565573
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${apacheSecurityOutput}
566574
fi
567575

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

657678
}
658679

680+
#
681+
# Deploy Voyager/HAProxy load balancer
682+
#
683+
function setupVoyagerLoadBalancer {
684+
# only deploy Voyager Ingress Controller the first time
685+
local vpod=`kubectl get pod -n voyager | grep voyager | wc -l`
686+
if [ "$vpod" == "0" ]; then
687+
kubectl create namespace voyager
688+
curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0/hack/deploy/voyager.sh \
689+
| bash -s -- --provider=baremetal --namespace=voyager
690+
fi
691+
692+
# verify Voyager controller pod is ready
693+
local ready=`kubectl -n voyager get pod | grep voyager-operator | awk ' { print $2; } '`
694+
if [ "${ready}" != "1/1" ] ; then
695+
fail "Voyager Ingress Controller is not ready"
696+
fi
697+
698+
# deploy Voyager Ingress resource
699+
kubectl apply -f ${voyagerOutput}
700+
701+
echo Checking Voyager Ingress resource
702+
local maxwaitsecs=100
703+
local mstart=`date +%s`
704+
while : ; do
705+
local mnow=`date +%s`
706+
local vdep=`kubectl get ingresses.voyager.appscode.com -n ${namespace} | grep ${domainUID}-voyager | wc | awk ' { print $1; } '`
707+
if [ "$vdep" = "1" ]; then
708+
echo 'The Voyager Ingress resource ${domainUID}-voyager is created successfully.'
709+
break
710+
fi
711+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
712+
fail "The Voyager Ingress resource ${domainUID}-voyager was not created."
713+
fi
714+
sleep 5
715+
done
716+
717+
echo Checking Voyager service
718+
local maxwaitsecs=100
719+
local mstart=`date +%s`
720+
while : ; do
721+
local mnow=`date +%s`
722+
local vscv=`kubectl get service ${domainUID}-voyager-stats -n ${namespace} | grep ${domainUID}-voyager-stats | wc | awk ' { print $1; } '`
723+
if [ "$vscv" = "1" ]; then
724+
echo 'The service ${domainUID}-voyager-stats is created successfully.'
725+
break
726+
fi
727+
if [ $((mnow - mstart)) -gt $((maxwaitsecs)) ]; then
728+
fail "The service ${domainUID}-voyager-stats was not created."
729+
fi
730+
sleep 5
731+
done
732+
}
659733
#
660734
# Deploy traefik load balancer
661735
#
@@ -707,6 +781,21 @@ function setupApacheLoadBalancer {
707781

708782
apacheName="${domainUID}-apache-webtier"
709783

784+
echo Setting up apache security
785+
kubectl apply -f ${apacheSecurityOutput}
786+
787+
echo Checking the cluster role ${apacheName} was created
788+
CLUSTERROLE=`kubectl get clusterroles | grep ${apacheName} | wc | awk ' { print $1; } '`
789+
if [ "$CLUSTERROLE" != "1" ]; then
790+
fail "The cluster role ${apacheName} was not created"
791+
fi
792+
793+
echo Checking the cluster role binding ${apacheName} was created
794+
CLUSTERROLEBINDING=`kubectl get clusterrolebindings | grep ${apacheName} | wc | awk ' { print $1; } '`
795+
if [ "$CLUSTERROLEBINDING" != "1" ]; then
796+
fail "The cluster role binding ${apacheName} was not created"
797+
fi
798+
710799
echo Deploying apache
711800
kubectl apply -f ${apacheOutput}
712801

@@ -783,7 +872,7 @@ function outputJobSummary {
783872
if [ "${exposeAdminT3Channel}" = true ]; then
784873
echo "T3 access is available at t3:${K8S_IP}:${t3ChannelPort}"
785874
fi
786-
if [ "${loadBalancer}" = "TRAEFIK" ]; then
875+
if [ "${loadBalancer}" = "TRAEFIK" ] || [ "${loadBalancer}" = "VOYAGER" ]; then
787876
echo "The load balancer for cluster '${clusterName}' is available at http:${K8S_IP}:${loadBalancerWebPort}/ (add the application path to the URL)"
788877
echo "The load balancer dashboard for cluster '${clusterName}' is available at http:${K8S_IP}:${loadBalancerDashboardPort}"
789878
echo ""
@@ -803,7 +892,8 @@ function outputJobSummary {
803892
elif [ "${loadBalancer}" = "APACHE" ]; then
804893
echo " ${apacheSecurityOutput}"
805894
echo " ${apacheOutput}"
806-
895+
elif [ "${loadBalancer}" = "VOYAGER" ]; then
896+
echo " ${voyagerOutput}"
807897
fi
808898
}
809899

@@ -836,7 +926,8 @@ if [ "${generateOnly}" = false ]; then
836926
setupTraefikLoadBalancer
837927
elif [ "${loadBalancer}" = "APACHE" ]; then
838928
setupApacheLoadBalancer
839-
929+
elif [ "${loadBalancer}" = "VOYAGER" ]; then
930+
setupVoyagerLoadBalancer
840931
fi
841932

842933
# 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

operator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
<dependency>
245245
<groupId>io.kubernetes</groupId>
246246
<artifactId>client-java</artifactId>
247-
<version>1.0.0-beta4</version>
247+
<version>1.0.0</version>
248248
</dependency>
249249
<dependency>
250250
<groupId>javax</groupId>

0 commit comments

Comments
 (0)