Skip to content

Commit ea48a4e

Browse files
author
abhisbyk
committed
Two services: clusterIP for internal communication and external LB/NP for users
Signed-off-by: abhisbyk <abhishek.by.kumar@oracle.com>
1 parent 9886cb9 commit ea48a4e

File tree

6 files changed

+224
-146
lines changed

6 files changed

+224
-146
lines changed

apis/database/v1alpha1/singleinstancedatabase_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ type SingleInstanceDatabaseSpec struct {
6161
Charset string `json:"charset,omitempty"`
6262
Pdbname string `json:"pdbName,omitempty"`
6363
LoadBalancer bool `json:"loadBalancer,omitempty"`
64+
ServicePort int `json:"servicePort,omitempty"`
6465
ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"`
6566
FlashBack bool `json:"flashBack,omitempty"`
6667
ArchiveLog bool `json:"archiveLog,omitempty"`
6768
ForceLogging bool `json:"forceLog,omitempty"`
6869
EnableTCPS bool `json:"enableTCPS,omitempty"`
69-
TcpsPort int `json:"tcpsPort,omitempty"`
7070

7171
CloneFrom string `json:"cloneFrom,omitempty"`
7272
ReadinessCheckPeriod int `json:"readinessCheckPeriod,omitempty"`
@@ -150,8 +150,9 @@ type SingleInstanceDatabaseStatus struct {
150150
PrebuiltDB bool `json:"prebuiltDB,omitempty"`
151151
// +kubebuilder:default:=false
152152
IsTcpsEnabled bool `json:"isTcpsEnabled"`
153-
TcpsPort int `json:"tcpsPort,omitempty"`
154153
CertCreationTimestamp string `json:"certCreationTimestamp,omitempty"`
154+
DbHostname string `json:"dbHostname,omitempty"`
155+
DbPort int `json:"dbPort,omitempty"`
155156

156157
// +patchMergeKey=type
157158
// +patchStrategy=merge

apis/database/v1alpha1/singleinstancedatabase_webhook.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ func (r *SingleInstanceDatabase) ValidateCreate() error {
234234
}
235235
}
236236

237+
// servicePort validation
238+
if !r.Spec.LoadBalancer {
239+
// NodePort service is expected. In this case servicePort should be in range 30000-32767
240+
if r.Spec.ServicePort != 0 && (r.Spec.ServicePort < 30000 || r.Spec.ServicePort > 32767) {
241+
allErrs = append(allErrs,
242+
field.Invalid(field.NewPath("spec").Child("servicePort"), r.Spec.ServicePort,
243+
"servicePort should be in 30000-32767 range."))
244+
}
245+
}
246+
237247
if len(allErrs) == 0 {
238248
return nil
239249
}
@@ -297,10 +307,6 @@ func (r *SingleInstanceDatabase) ValidateUpdate(oldRuntimeObject runtime.Object)
297307
allErrs = append(allErrs,
298308
field.Forbidden(field.NewPath("spec").Child("persistence"), "uninstall ORDS to change Persistence"))
299309
}
300-
if old.Status.IsTcpsEnabled && old.Status.TcpsPort != r.Spec.TcpsPort {
301-
allErrs = append(allErrs,
302-
field.Forbidden(field.NewPath("spec").Child("tcpsPort"), "cannot change TCPS port, please disable TCPS first then enable it with newly desired port"))
303-
}
304310
if len(allErrs) == 0 {
305311
return nil
306312
}

commons/database/constants.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838

3939
package commons
4040

41-
const DEFAULT_LISTENER_PORT int32 = 1521
41+
const CONTAINER_LISTENER_PORT int32 = 1521
42+
43+
const CONTAINER_TCPS_PORT int32 = 1522
4244

4345
const ORACLE_UID int64 = 54321
4446

@@ -483,10 +485,13 @@ const SetApexUsers string = "\numask 177" +
483485
const GetSidPdbEditionCMD string = "echo $ORACLE_SID,$ORACLE_PDB,$ORACLE_EDITION,Edition;"
484486

485487
// Command to enable TCPS as a formatted string. The parameter would be the port at which TCPS is enabled.
486-
const EnableTcpsCMD string = "$ORACLE_BASE/$CONFIG_TCPS_FILE %d"
488+
const EnableTcpsCMD string = "$ORACLE_BASE/$CONFIG_TCPS_FILE"
487489

488490
// Command for TCPS certs renewal to prevent their expiry. It is same as the EnableTcpsCMD
489491
const RenewCertsCMD string = EnableTcpsCMD
490492

491493
// Command to disable TCPS
492494
const DisableTcpsCMD string = "$ORACLE_BASE/$CONFIG_TCPS_FILE disable"
495+
496+
// TCPS clientWallet update command
497+
const ClientWalletUpdate string = "sed -i -e 's/HOST.*$/HOST=%s)/g' -e 's/PORT.*$/PORT=%d)/g' ${ORACLE_BASE}/oradata/clientWallet/${ORACLE_SID}/tnsnames.ora"

config/crd/bases/database.oracle.com_singleinstancedatabases.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ spec:
156156
additionalProperties:
157157
type: string
158158
type: object
159+
servicePort:
160+
type: integer
159161
sid:
160162
description: SID must be alphanumeric (no special characters, only
161163
a-z, A-Z, 0-9), and no longer than 12 characters.
162164
maxLength: 12
163165
pattern: ^[a-zA-Z0-9]+$
164166
type: string
165-
tcpsPort:
166-
type: integer
167167
required:
168168
- image
169169
type: object
@@ -263,6 +263,10 @@ spec:
263263
datafilesPatched:
264264
default: "false"
265265
type: string
266+
dbHostname:
267+
type: string
268+
dbPort:
269+
type: integer
266270
edition:
267271
type: string
268272
flashBack:
@@ -334,8 +338,6 @@ spec:
334338
type: object
335339
status:
336340
type: string
337-
tcpsPort:
338-
type: integer
339341
required:
340342
- isTcpsEnabled
341343
- persistence

config/samples/sidb/singleinstancedatabase.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ spec:
4747
## Enable TCPS
4848
enableTCPS: false
4949

50-
## TCPS custom port
51-
tcpsPort: 1522
52-
5350
## NA if cloning from a SourceDB (cloneFrom is set)
5451
## Specify both sgaSize and pgaSize (in MB) or dont specify both
5552
## Specify Non-Zero value to use
@@ -85,6 +82,11 @@ spec:
8582
## Type of service . Applicable on cloud enviroments only
8683
## if loadBalService : false, service type = "NodePort" else "LoadBalancer"
8784
loadBalancer: false
85+
86+
## If loadBalancer is enabled, the servicePort is the load balancer port number
87+
## If loadBalancer is disabled, the servicePort is the NodePort(should be in range 30000-32767)
88+
#servicePort: 30001
89+
8890
## Service Annotations (Cloud provider specific), for configuring the service (e.g. private LoadBalancer service)
8991
#serviceAnnotations:
9092
# service.beta.kubernetes.io/oci-load-balancer-internal: "true"

0 commit comments

Comments
 (0)