Skip to content

Commit 9648538

Browse files
committed
Sample updates
1 parent 1744704 commit 9648538

File tree

5 files changed

+47
-10
lines changed

5 files changed

+47
-10
lines changed

kubernetes/samples/scripts/common/utility.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ function checkPodState(){
641641
kubectl -n ${ns} get po ${pname}
642642
}
643643

644-
# Checks if a pod is available in a given namesapce
644+
# Checks if a pod is available in a given namespace
645645
function checkPod(){
646646

647647
max=20
@@ -676,3 +676,21 @@ function checkPod(){
676676
exit 1
677677
fi
678678
}
679+
680+
# Checks if a service is available in a given namespace
681+
function checkService(){
682+
svc=$1
683+
ns=$2
684+
startSecs=$SECONDS
685+
maxWaitSecs=20
686+
while [ -z "`kubectl get service -n ${ns} | grep -w ${svc}`" ]; do
687+
if [ $((SECONDS - startSecs)) -lt $maxWaitSecs ]; then
688+
echo "Service [$svc] not found after $((SECONDS - startSecs)) seconds, retrying ..."
689+
sleep 5
690+
else
691+
echo "[Error] Could not find Service [$svc] after $((SECONDS - startSecs)) seconds"
692+
exit 1
693+
fi
694+
done
695+
echo "Service [$svc] found"
696+
}

kubernetes/samples/scripts/create-oracle-db-service/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ usage: ./start-db-service.sh -p <nodeport> -i <image> -s <pullsecret> -n <namesp
1717
-i Oracle DB Image (optional)
1818
(default: container-registry.oracle.com/database/enterprise:12.2.0.1-slim)
1919
-p DB Service NodePort (optional)
20-
(default: 30011)
20+
(default: 30011, set to 'none' to deploy service without a NodePort)
2121
-s DB Image PullSecret (optional)
2222
(default: docker-store)
2323
-n Configurable Kubernetes NameSpace for Oracle DB Service (optional)"

kubernetes/samples/scripts/create-oracle-db-service/common/oracle.db.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ spec:
5959
limits:
6060
cpu: "2"
6161
memory: "6Gi"
62+
ephemeral-storage: "8Gi"
6263
requests:
6364
cpu: 500m
65+
ephemeral-storage: "6Gi"
6466
terminationMessagePath: /dev/termination-log
6567
terminationMessagePolicy: File
6668
dnsPolicy: ClusterFirst

kubernetes/samples/scripts/create-oracle-db-service/start-db-service.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ source ${scriptDir}/../common/utility.sh
1111
function usage {
1212
echo "usage: ${script} -p <nodeport> -i <image> -s <pullsecret> -n <namespace> [-h]"
1313
echo " -i Oracle DB Image (optional)"
14-
echo " (default: container-registry.oracle.com/database/enterprise:12.2.0.1-slim ) "
14+
echo " (default: container-registry.oracle.com/database/enterprise:12.2.0.1-slim)"
1515
echo " -p DB Service NodePort (optional)"
16-
echo " (default: 30011) "
16+
echo " (default: 30011, set to 'none' to deploy service without a NodePort)"
1717
echo " -s DB Image PullSecret (optional)"
1818
echo " (default: docker-store) "
1919
echo " -n Configurable Kubernetes NameSpace for Oracle DB Service (optional)"
@@ -73,25 +73,40 @@ echo ' - name: docker-store' >> ${scriptDir}/common/oracle.db.yaml
7373
sed -i -e "s?name: docker-store?name: ${pullsecret}?g" ${scriptDir}/common/oracle.db.yaml
7474
sed -i -e "s?image:.*?image: ${dbimage}?g" ${scriptDir}/common/oracle.db.yaml
7575
sed -i -e "s?namespace:.*?namespace: ${namespace}?g" ${scriptDir}/common/oracle.db.yaml
76-
kubectl apply -f ${scriptDir}/common/oracle.db.yaml
7776

78-
# Modify the NodePort based on input
79-
sed -i -e "s?nodePort:.*?nodePort: ${nodeport}?g" ${scriptDir}/common/oracle.db.yaml
77+
# Modify the NodePort based on input
78+
if [ "${nodeport}" = "none" ]; then
79+
sed -i -e "s? nodePort:? #nodePort:?g" ${scriptDir}/common/oracle.db.yaml
80+
sed -i -e "s? type:.*LoadBalancer? #type: LoadBalancer?g" ${scriptDir}/common/oracle.db.yaml
81+
else
82+
sed -i -e "s?[#]*nodePort:.*?nodePort: ${nodeport}?g" ${scriptDir}/common/oracle.db.yaml
83+
sed -i -e "s?[#]*type:.*LoadBalancer?type: LoadBalancer?g" ${scriptDir}/common/oracle.db.yaml # default type is ClusterIP
84+
fi
85+
86+
kubectl delete service oracle-db -n ${namespace} --ignore-not-found
8087
kubectl apply -f ${scriptDir}/common/oracle.db.yaml
88+
8189
dbpod=`kubectl get po -n ${namespace} | grep oracle-db | cut -f1 -d " " `
90+
8291
checkPod ${dbpod} ${namespace}
8392
checkPodState ${dbpod} ${namespace} "1/1"
93+
checkService oracle-db ${namespace}
94+
8495
kubectl get po -n ${namespace}
8596
kubectl get service -n ${namespace}
8697

8798
kubectl cp ${scriptDir}/common/checkDbState.sh -n ${namespace} ${dbpod}:/home/oracle/
8899
kubectl exec -it ${dbpod} -n ${namespace} /bin/bash /home/oracle/checkDbState.sh
89100
if [ $? != 0 ]; then
90101
echo "######################";
91-
echo "[ERROR] Could not create Oracle DB Service";
102+
echo "[ERROR] Could not create Oracle DB Service, check the pod log for pod ${dbpod} in namespace ${namespace}";
92103
echo "######################";
93104
exit -3;
94105
fi
95106

96-
echo "Oracle DB Service is RUNNING with NodePort [${nodeport}]"
97-
echo "Oracle DB Service URL [oracle-db.${namespace}.svc.cluster.local:1521/devpdb.k8s]"
107+
if [ ! "${nodeport}" = "none" ]; then
108+
echo "Oracle DB Service is RUNNING with NodePort [${nodeport}]"
109+
else
110+
echo "Oracle DB Service is RUNNING and does not specify a public NodePort"
111+
fi
112+
echo "Oracle DB Service URL [oracle-db.${namespace}.svc.cluster.local:1521/devpdb.k8s]"

kubernetes/samples/scripts/create-rcu-schema/common/createRepository.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ do
2424
done
2525

2626
if [ $counter -gt ${max} ]; then
27+
echo "Error output from 'java utils.dbping ORACLE_THIN \"sys as sysdba\" SYSPASSWORD ${connectString}' from '$(pwd)/dbping.err':"
28+
cat dbping.err
2729
echo "[ERROR] Oracle DB Service is not ready after [${max}] iterations ..."
2830
exit -1
2931
else

0 commit comments

Comments
 (0)