Skip to content

Commit 915dfb2

Browse files
committed
Merge branch 'mmalvezz' into 'master'
bug 35357707 See merge request rac-docker-dev/oracle-database-operator!247
2 parents 49eb449 + 3fa80db commit 915dfb2

File tree

20 files changed

+324
-90
lines changed

20 files changed

+324
-90
lines changed

config/samples/multitenant/cdb_secret.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ metadata:
99
namespace: oracle-database-operator-system
1010
type: Opaque
1111
data:
12-
ords_pwd: "d2VsY29tZTE="
13-
sysadmin_pwd: "V0VsY29tZV8xMiMj"
14-
cdbadmin_user: "QyMjREJBUElfQ0RCX0FETUlO"
15-
cdbadmin_pwd: "V0VsY29tZV8xMiMj"
16-
webserver_user: "c3FsX2FkbWlu"
17-
webserver_pwd: "d2VsY29tZTE="
12+
ords_pwd: "[base64 encode value]"
13+
sysadmin_pwd: "[base64 encode value]"
14+
cdbadmin_user: "[base64 encode value]"
15+
cdbadmin_pwd: "[base64 encode value]"
16+
webserver_user: "[base64 encode values]"
17+
webserver_pwd: "[base64 encode values]"

config/samples/multitenant/pdb_secret.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ metadata:
99
namespace: oracle-database-operator-system
1010
type: Opaque
1111
data:
12-
sysadmin_user: "cGRiYWRtaW4="
13-
sysadmin_pwd: "V0VsY29tZV8xMiMj"
12+
sysadmin_user: "[ base64 encode value]"
13+
sysadmin_pwd: "[ base64 encode value]"

controllers/database/pdb_controller.go

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
"fmt"
5050
"io/ioutil"
5151
"net/http"
52+
"regexp"
5253
"strconv"
5354
"strings"
5455
"time"
@@ -490,7 +491,7 @@ func (r *PDBReconciler) callAPI(ctx context.Context, req ctrl.Request, pdb *dbap
490491
return "", err
491492
}
492493
webUser := string(secret.Data[cdb.Spec.WebServerUser.Secret.Key])
493-
webUser = strings.TrimSpace(webUser)
494+
webUser = strings.TrimSpace(webUser)
494495

495496
// Get Web Server User Password
496497
secret = &corev1.Secret{}
@@ -504,8 +505,7 @@ func (r *PDBReconciler) callAPI(ctx context.Context, req ctrl.Request, pdb *dbap
504505
return "", err
505506
}
506507
webUserPwd := string(secret.Data[cdb.Spec.WebServerPwd.Secret.Key])
507-
webUserPwd = strings.TrimSpace(webUserPwd)
508-
508+
webUserPwd = strings.TrimSpace(webUserPwd)
509509

510510
var httpreq *http.Request
511511
if action == "GET" {
@@ -681,9 +681,11 @@ func (r *PDBReconciler) createPDB(ctx context.Context, req ctrl.Request, pdb *db
681681
if cdb.Spec.DBServer != "" {
682682
pdb.Status.ConnString = cdb.Spec.DBServer + ":" + strconv.Itoa(cdb.Spec.DBPort) + "/" + pdb.Spec.PDBName
683683
} else {
684+
ParseTnsAlias(&(cdb.Spec.DBTnsurl), &(pdb.Spec.PDBName))
684685
pdb.Status.ConnString = cdb.Spec.DBTnsurl
685686
}
686687

688+
log.Info("New connect strinng", "tnsurl", cdb.Spec.DBTnsurl)
687689
log.Info("Created PDB Resource", "PDB Name", pdb.Spec.PDBName)
688690
r.getPDBState(ctx, req, pdb)
689691
return nil
@@ -756,6 +758,7 @@ func (r *PDBReconciler) clonePDB(ctx context.Context, req ctrl.Request, pdb *dba
756758
if cdb.Spec.DBServer != "" {
757759
pdb.Status.ConnString = cdb.Spec.DBServer + ":" + strconv.Itoa(cdb.Spec.DBPort) + "/" + pdb.Spec.PDBName
758760
} else {
761+
ParseTnsAlias(&(cdb.Spec.DBTnsurl), &(pdb.Spec.PDBName))
759762
pdb.Status.ConnString = cdb.Spec.DBTnsurl
760763
}
761764

@@ -887,6 +890,14 @@ func (r *PDBReconciler) unplugPDB(ctx context.Context, req ctrl.Request, pdb *db
887890

888891
pdb.Status.Phase = pdbPhaseUnplug
889892
pdb.Status.Msg = "Waiting for PDB to be unplugged"
893+
894+
if cdb.Spec.DBServer != "" {
895+
pdb.Status.ConnString = cdb.Spec.DBServer + ":" + strconv.Itoa(cdb.Spec.DBPort) + "/" + pdb.Spec.PDBName
896+
} else {
897+
ParseTnsAlias(&(cdb.Spec.DBTnsurl), &(pdb.Spec.PDBName))
898+
pdb.Status.ConnString = cdb.Spec.DBTnsurl
899+
}
900+
890901
if err := r.Status().Update(ctx, pdb); err != nil {
891902
log.Error(err, "Failed to update status for :"+pdb.Name, "err", err.Error())
892903
}
@@ -1085,6 +1096,7 @@ func (r *PDBReconciler) mapPDB(ctx context.Context, req ctrl.Request, pdb *dbapi
10851096
if cdb.Spec.DBServer != "" {
10861097
pdb.Status.ConnString = cdb.Spec.DBServer + ":" + strconv.Itoa(cdb.Spec.DBPort) + "/" + pdb.Spec.PDBName
10871098
} else {
1099+
ParseTnsAlias(&(cdb.Spec.DBTnsurl), &(pdb.Spec.PDBName))
10881100
pdb.Status.ConnString = cdb.Spec.DBTnsurl
10891101
}
10901102

@@ -1235,3 +1247,29 @@ func (r *PDBReconciler) SetupWithManager(mgr ctrl.Manager) error {
12351247
WithOptions(controller.Options{MaxConcurrentReconciles: 100}).
12361248
Complete(r)
12371249
}
1250+
1251+
/*************************************************************
1252+
Enh 35357707 - PROVIDE THE PDB TNSALIAS INFORMATION
1253+
**************************************************************/
1254+
1255+
func ParseTnsAlias(tns *string, pdbsrv *string) {
1256+
fmt.Printf("Analyzing string [%s]\n", *tns)
1257+
fmt.Printf("Relacing srv [%s]\n", *pdbsrv)
1258+
1259+
if strings.Contains(strings.ToUpper(*tns), "SERVICE_NAME") == false {
1260+
fmt.Print("Cannot generate tns alias for pdb")
1261+
return
1262+
}
1263+
1264+
if strings.Contains(strings.ToUpper(*tns), "ORACLE_SID") == true {
1265+
fmt.Print("Cannot generate tns alias for pdb")
1266+
return
1267+
}
1268+
1269+
*pdbsrv = fmt.Sprintf("SERVICE_NAME=%s", *pdbsrv)
1270+
tnsreg := regexp.MustCompile(`SERVICE_NAME=\w+`)
1271+
*tns = tnsreg.ReplaceAllString(*tns, *pdbsrv)
1272+
1273+
fmt.Printf("Newstring [%s]\n", *tns)
1274+
1275+
}

docs/multitenant/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ Please refer [here](./provisioning/example_setup_using_oci_oke_cluster.md) for s
122122

123123
You can build this image by using the ORDS [Dockerfile](../../../ords/Dockerfile)
124124

125-
> **_NOTE:_** The current version of Oracle DB Operator Multitenant Controller has been tested with **ords 22.2.1.202.1302** version.
126125

127-
Please refer [here](./provisioning/ords_image.md) for the steps to build ORDS Docker Image with **ords 22.2.1.202.1302** version.
126+
Please refer [here](./provisioning/ords_image.md) for the steps to build ORDS Docker Image
128127

129128

130129
+ ## Kubernetes Secrets

docs/multitenant/provisioning/cdb_secret.log

Whitespace-only changes.

docs/multitenant/provisioning/cdb_secret.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ metadata:
99
namespace: oracle-database-operator-system
1010
type: Opaque
1111
data:
12-
ords_pwd: "V0VsY29tZV8yMSMj"
13-
sysadmin_pwd: "V0VsY29tZV8yMSMj"
14-
cdbadmin_user: "QyMjREJBUElfQ0RCX0FETUlO"
15-
cdbadmin_pwd: "V0VsY29tZV8yMSMj"
16-
webserver_user: "c3FsX2FkbWlu"
17-
webserver_pwd: "d2VsY29tZTE="
12+
ords_pwd: "[ base64 encode values ]"
13+
sysadmin_pwd: "[ base64 encode values ]"
14+
cdbadmin_user: "[ base64 encode values ]"
15+
cdbadmin_pwd: "[ base64 encode values ]"
16+
webserver_user: "[ base64 encode values ]"
17+
webserver_pwd: "[base64 encode values ]"

docs/multitenant/provisioning/pdb.log

Whitespace-only changes.

docs/multitenant/provisioning/pdb_secret.log

Whitespace-only changes.

docs/multitenant/provisioning/pdb_secret.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ metadata:
99
namespace: oracle-database-operator-system
1010
type: Opaque
1111
data:
12-
sysadmin_user: "cGRiYWRtaW4="
13-
sysadmin_pwd: "V0VsY29tZV8yMSMj"
12+
sysadmin_user: "[ base64 encode values ]"
13+
sysadmin_pwd: "[base64 encode values ]"

docs/multitenant/usecase01/README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
- [INTRODUCTION](#introduction)
77
- [OPERATION STEPS ](#operation-steps)
8-
- [Download latest version from orahub ](#download-latest-version-from-orahub-a-namedownloada)
8+
- [Download latest version from github ](#download-latest-version-from-orahub-a-namedownloada)
99
- [Upload webhook certificates](#upload-webhook-certificates-a-namewebhooka)
1010
- [Create the dboperator](#create-the-dboperator-a-namedboperatora)
1111
- [Create Secret for container registry](#create-secret-for-container-registry)
@@ -20,7 +20,7 @@
2020

2121

2222

23-
###### INTRODUCTION
23+
##### INTRODUCTION
2424

2525
This readme is a step by step guide used to implement database multi tenant operator. It assumes that a kubernets cluster and a database server are already available (no matter if single instance or RAC). kubectl must be configured in order to reach k8s cluster.
2626

@@ -48,12 +48,13 @@ The following table reports the parameters required to configure and use oracle
4848
| pdbTlsCrt | <certfile\> | [standalone.https.cert][cr] |
4949
| pdbTlsCat | <certauth\> | certificate authority |
5050

51-
51+
> A [makfile](./makefile) is available to sped up the command execution for the multitenant setup and test. See the comments in the header of file
5252
5353
### OPERATIONAL STEPS
5454
----
5555

56-
##### Download latest version from github <a name="Download"></a>
56+
57+
#### Download latest version from github <a name="Download"></a>
5758

5859

5960
```bash
@@ -77,13 +78,13 @@ make operator-yaml IMG=<public_container_registry>operator:latest
7778
7879
> <span style="color:red"> **NOTE:** If you are using oracle-container-registry make sure to accept the license agreement otherwise the operator image pull fails. </span>
7980
----
80-
##### Upload webhook certificates <a name="webhook"></a>
81+
#### Upload webhook certificates <a name="webhook"></a>
8182

8283
```bash
8384
kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml
8485
```
8586

86-
##### Create the dboperator <a name="dboperator"></a>
87+
#### Create the dboperator <a name="dboperator"></a>
8788

8889
```bash
8990
cd oracle-database-operator
@@ -100,7 +101,7 @@ oracle-database-operator-controller-manager-557ff6c659-xpswv 1/1 Running
100101

101102
```
102103
----
103-
##### Create secret for container registry
104+
#### Create secret for container registry
104105

105106
+ Make sure to login to your container registry and then create the secret for you container registry.
106107

@@ -118,7 +119,7 @@ container-registry-secret kubernetes.io/dockerconfigjson 1 19s
118119
webhook-server-cert kubernetes.io/tls
119120
```
120121
----
121-
##### Build ords immage <a name="ordsimage"></a>
122+
#### Build ords immage <a name="ordsimage"></a>
122123

123124
+ Build the ords image, downloading ords software is no longer needed; just build the image and push it to your repository
124125

@@ -137,7 +138,7 @@ docker push <public-container-registry>/ords-dboper:latest
137138
[example of execution](./ImagePush.log)
138139

139140
----
140-
##### Database Configuration
141+
#### Database Configuration
141142

142143
+ Configure Database
143144

@@ -152,7 +153,7 @@ GRANT SYSDBA TO <CDB_ADMIN_USER> CONTAINER = ALL;
152153
GRANT CREATE SESSION TO <CDB_ADMIN_USER> CONTAINER = ALL;
153154
```
154155
----
155-
##### Create CDB secret
156+
#### Create CDB secret
156157

157158
+ Create secret for CDB connection
158159

@@ -207,7 +208,7 @@ webhook-server-cert kubernetes.io/tls 3 4m55s
207208

208209
>**TIPS:** Use the following commands to analyze contents of an existing secret ```bash kubectl get secret <secret name> -o yaml -n <namespace_name>```
209210
----
210-
##### Create Certificates
211+
#### Create Certificates
211212

212213
+ Create certificates: At this stage we need to create certificates on our local machine and upload into kubernetes cluster by creating new secrets.
213214

@@ -261,7 +262,7 @@ kubectl create secret generic db-ca --from-file=<certfile> -n oracle-database-op
261262

262263

263264
----
264-
###### Apply cdb.yaml
265+
#### Apply cdb.yaml
265266

266267
+ Create ords container
267268

@@ -339,7 +340,7 @@ spec:
339340
[example of cdb.yaml](./cdb.yaml)
340341

341342
----
342-
###### CDB - Logs and throuble shutting
343+
#### CDB - Logs and throuble shutting
343344

344345
+ Check the status of ords container
345346

@@ -400,7 +401,7 @@ NAME CDB NAME DB SERVER DB PORT REPLICAS STATUS MESSAG
400401
[Example of executions](./ordsconfig.log)
401402

402403
-----
403-
###### Create PDB secret
404+
#### Create PDB secret
404405

405406

406407
```bash
@@ -433,7 +434,7 @@ pdb1-secret Opaque 2 79m <---
433434
webhook-server-cert kubernetes.io/tls 3 79m
434435
```
435436
---
436-
###### Apply pdb yaml file to create pdb
437+
#### Apply pdb yaml file to create pdb
437438

438439
```bash
439440
/usr/bin/kubectl apply -f pdb.yaml -n oracle-database-operator-system
@@ -523,7 +524,7 @@ kubectl logs -f $(kubectl get pods -n oracle-database-operator-system|grep oracl
523524
```
524525

525526
---
526-
###### Other actions
527+
#### Other actions
527528

528529
Configure and use other yaml files to perform pluggable database life cycle managment action **modify_pdb_open.yaml** **modify_pdb_close.yaml**
529530

0 commit comments

Comments
 (0)