Skip to content

Commit 4655cf5

Browse files
Abhishek Kumaryunus-qureshi
authored andcommitted
Additional TCPS features
1 parent f1068a9 commit 4655cf5

File tree

8 files changed

+202
-74
lines changed

8 files changed

+202
-74
lines changed

apis/database/v1alpha1/singleinstancedatabase_types.go

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ 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"`
64+
ListenerPort int `json:"listenerPort,omitempty"`
65+
TcpsListenerPort int `json:"tcpsListenerPort,omitempty"`
6566
ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"`
6667
FlashBack bool `json:"flashBack,omitempty"`
6768
ArchiveLog bool `json:"archiveLog,omitempty"`
@@ -131,28 +132,31 @@ type SingleInstanceDatabaseStatus struct {
131132
DatafilesPatched string `json:"datafilesPatched,omitempty"`
132133
ConnectString string `json:"connectString,omitempty"`
133134
ClusterConnectString string `json:"clusterConnectString,omitempty"`
135+
TcpsConnectString string `json:"tcpsConnectString,omitempty"`
134136
StandbyDatabases map[string]string `json:"standbyDatabases,omitempty"`
135137
// +kubebuilder:default:="false"
136-
DatafilesCreated string `json:"datafilesCreated,omitempty"`
137-
Sid string `json:"sid,omitempty"`
138-
Edition string `json:"edition,omitempty"`
139-
Charset string `json:"charset,omitempty"`
140-
Pdbname string `json:"pdbName,omitempty"`
141-
InitSgaSize int `json:"initSgaSize,omitempty"`
142-
InitPgaSize int `json:"initPgaSize,omitempty"`
143-
CloneFrom string `json:"cloneFrom,omitempty"`
144-
FlashBack string `json:"flashBack,omitempty"`
145-
ArchiveLog string `json:"archiveLog,omitempty"`
146-
ForceLogging string `json:"forceLog,omitempty"`
147-
OemExpressUrl string `json:"oemExpressUrl,omitempty"`
148-
OrdsReference string `json:"ordsReference,omitempty"`
149-
PdbConnectString string `json:"pdbConnectString,omitempty"`
150-
ApexInstalled bool `json:"apexInstalled,omitempty"`
151-
PrebuiltDB bool `json:"prebuiltDB,omitempty"`
138+
DatafilesCreated string `json:"datafilesCreated,omitempty"`
139+
Sid string `json:"sid,omitempty"`
140+
Edition string `json:"edition,omitempty"`
141+
Charset string `json:"charset,omitempty"`
142+
Pdbname string `json:"pdbName,omitempty"`
143+
InitSgaSize int `json:"initSgaSize,omitempty"`
144+
InitPgaSize int `json:"initPgaSize,omitempty"`
145+
CloneFrom string `json:"cloneFrom,omitempty"`
146+
FlashBack string `json:"flashBack,omitempty"`
147+
ArchiveLog string `json:"archiveLog,omitempty"`
148+
ForceLogging string `json:"forceLog,omitempty"`
149+
OemExpressUrl string `json:"oemExpressUrl,omitempty"`
150+
OrdsReference string `json:"ordsReference,omitempty"`
151+
PdbConnectString string `json:"pdbConnectString,omitempty"`
152+
TcpsPdbConnectString string `json:"tcpsPdbConnectString,omitempty"`
153+
ApexInstalled bool `json:"apexInstalled,omitempty"`
154+
PrebuiltDB bool `json:"prebuiltDB,omitempty"`
152155
// +kubebuilder:default:=false
153156
IsTcpsEnabled bool `json:"isTcpsEnabled"`
154157
CertCreationTimestamp string `json:"certCreationTimestamp,omitempty"`
155-
CertRenewDuration string `json:"certRenewDuration,omitempty"`
158+
CertRenewInterval string `json:"certRenewInterval,omitempty"`
159+
ClientWalletLoc string `json:"clientWalletLoc,omitempty"`
156160

157161
// +patchMergeKey=type
158162
// +patchStrategy=merge
@@ -172,6 +176,8 @@ type SingleInstanceDatabaseStatus struct {
172176
// +kubebuilder:printcolumn:JSONPath=".status.role",name="Role",type="string",priority=1
173177
// +kubebuilder:printcolumn:JSONPath=".status.releaseUpdate",name="Version",type="string"
174178
// +kubebuilder:printcolumn:JSONPath=".status.connectString",name="Connect Str",type="string"
179+
// +kubebuilder:printcolumn:JSONPath=".status.tcpsConnectString",name="TCPS Connect Str",type="string"
180+
// +kubebuilder:printcolumn:JSONPath=".status.tcpsPdbConnectString",name="TCPS Pdb Connect Str",type="string", priority=1
175181
// +kubebuilder:printcolumn:JSONPath=".status.pdbConnectString",name="Pdb Connect Str",type="string",priority=1
176182
// +kubebuilder:printcolumn:JSONPath=".status.oemExpressUrl",name="Oem Express Url",type="string"
177183

apis/database/v1alpha1/singleinstancedatabase_webhook.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,24 @@ func (r *SingleInstanceDatabase) ValidateCreate() error {
235235
}
236236
}
237237

238-
// servicePort validation
238+
// servicePort and tcpServicePort validation
239239
if !r.Spec.LoadBalancer {
240240
// NodePort service is expected. In this case servicePort should be in range 30000-32767
241-
if r.Spec.ServicePort != 0 && (r.Spec.ServicePort < 30000 || r.Spec.ServicePort > 32767) {
241+
if r.Spec.ListenerPort != 0 && (r.Spec.ListenerPort < 30000 || r.Spec.ListenerPort > 32767) {
242242
allErrs = append(allErrs,
243-
field.Invalid(field.NewPath("spec").Child("servicePort"), r.Spec.ServicePort,
244-
"servicePort should be in 30000-32767 range."))
243+
field.Invalid(field.NewPath("spec").Child("listenerPort"), r.Spec.ListenerPort,
244+
"listenerPort should be in 30000-32767 range."))
245245
}
246+
if r.Spec.TcpsListenerPort != 0 && (r.Spec.TcpsListenerPort < 30000 || r.Spec.TcpsListenerPort > 32767) {
247+
allErrs = append(allErrs,
248+
field.Invalid(field.NewPath("spec").Child("tcpsListenerPort"), r.Spec.TcpsListenerPort,
249+
"tcpsListenerPort should be in 30000-32767 range."))
250+
}
251+
}
252+
if r.Spec.ListenerPort != 0 && r.Spec.TcpsListenerPort != 0 && r.Spec.ListenerPort == r.Spec.TcpsListenerPort {
253+
allErrs = append(allErrs,
254+
field.Invalid(field.NewPath("spec").Child("tcpsListenerPort"), r.Spec.TcpsListenerPort,
255+
"listenerPort and tcpsListenerPort can not be equal."))
246256
}
247257

248258
// Certificate Renew Duration Validation

commons/database/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,3 +495,6 @@ const DisableTcpsCMD string = "$ORACLE_BASE/$CONFIG_TCPS_FILE disable"
495495

496496
// TCPS clientWallet update command
497497
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"
498+
499+
// TCPS clientWallet location
500+
const ClientWalletLocation string = "/opt/oracle/oradata/clientWallet/%s"

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ spec:
3333
- jsonPath: .status.connectString
3434
name: Connect Str
3535
type: string
36+
- jsonPath: .status.tcpsConnectString
37+
name: TCPS Connect Str
38+
type: string
39+
- jsonPath: .status.tcpsPdbConnectString
40+
name: TCPS Pdb Connect Str
41+
priority: 1
42+
type: string
3643
- jsonPath: .status.pdbConnectString
3744
name: Pdb Connect Str
3845
priority: 1
@@ -77,8 +84,6 @@ spec:
7784
type: object
7885
archiveLog:
7986
type: boolean
80-
certRenewDuration:
81-
type: string
8287
charset:
8388
type: string
8489
cloneFrom:
@@ -122,6 +127,8 @@ spec:
122127
sgaTarget:
123128
type: integer
124129
type: object
130+
listenerPort:
131+
type: integer
125132
loadBalancer:
126133
type: boolean
127134
nodeSelector:
@@ -158,14 +165,16 @@ spec:
158165
additionalProperties:
159166
type: string
160167
type: object
161-
servicePort:
162-
type: integer
163168
sid:
164169
description: SID must be alphanumeric (no special characters, only
165170
a-z, A-Z, 0-9), and no longer than 12 characters.
166171
maxLength: 12
167172
pattern: ^[a-zA-Z0-9]+$
168173
type: string
174+
tcpsCertRenewInterval:
175+
type: string
176+
tcpsListenerPort:
177+
type: integer
169178
required:
170179
- image
171180
type: object
@@ -179,10 +188,12 @@ spec:
179188
type: string
180189
certCreationTimestamp:
181190
type: string
182-
certRenewDuration:
191+
certRenewInterval:
183192
type: string
184193
charset:
185194
type: string
195+
clientWalletLoc:
196+
type: string
186197
cloneFrom:
187198
type: string
188199
clusterConnectString:
@@ -338,6 +349,10 @@ spec:
338349
type: object
339350
status:
340351
type: string
352+
tcpsConnectString:
353+
type: string
354+
tcpsPdbConnectString:
355+
type: string
341356
required:
342357
- isTcpsEnabled
343358
- persistence

config/samples/sidb/singleinstancedatabase.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,13 @@ spec:
8989
## if loadBalService : false, service type = "NodePort" else "LoadBalancer"
9090
loadBalancer: false
9191

92-
## If loadBalancer is enabled, the servicePort is the load balancer port number
93-
## If loadBalancer is disabled, the servicePort is the NodePort(should be in range 30000-32767)
94-
#servicePort: 30001
92+
## 'listenerPort' and 'tcpsListenerPort' fields customizes port cofigurations for normal and tcps database listeners
93+
## 'tcpsListenerPort' will come in effect only when 'enableTCPS' field is set
94+
## If loadBalancer is enabled, the listenerPort, tcpsListenerPort will be the load balancer ports
95+
## If loadBalancer is disabled, the listenerPort, tcpsListenerPort will be the node ports(should be in range 30000-32767)
96+
## If enableTCPS is set, and listenerPort is commented/not mentioned in the YAML file, only TCPS endpoint will be exposed
97+
#listenerPort: 30001
98+
#tcpsListenerPort: 30002
9599

96100
## Service Annotations (Cloud provider specific), for configuring the service (e.g. private LoadBalancer service)
97101
#serviceAnnotations:

controllers/database/oraclerestdataservice_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ func (r *OracleRestDataServiceReconciler) instantiatePodSpec(m *dbapi.OracleRest
582582
{
583583
Name: "init-permissions",
584584
Image: m.Spec.Image.PullFrom,
585-
Command: []string{"/bin/sh", "-c", fmt.Sprintf("chown %d:%d /opt/oracle/ords/config/ords", int(dbcommons.ORACLE_UID), int(dbcommons.DBA_GUID))},
585+
Command: []string{"/bin/sh", "-c", fmt.Sprintf("chown %d:%d /opt/oracle/ords/config/ords || true", int(dbcommons.ORACLE_UID), int(dbcommons.DBA_GUID))},
586586
SecurityContext: &corev1.SecurityContext{
587587
// User ID 0 means, root user
588588
RunAsUser: func() *int64 { i := int64(0); return &i }(),
@@ -728,6 +728,7 @@ func (r *OracleRestDataServiceReconciler) instantiatePodSpec(m *dbapi.OracleRest
728728
SecurityContext: &corev1.PodSecurityContext{
729729
RunAsUser: func() *int64 { i := int64(dbcommons.ORACLE_UID); return &i }(),
730730
RunAsGroup: func() *int64 { i := int64(dbcommons.DBA_GUID); return &i }(),
731+
FSGroup: func() *int64 { i := int64(dbcommons.DBA_GUID); return &i }(),
731732
},
732733

733734
ImagePullSecrets: []corev1.LocalObjectReference{

0 commit comments

Comments
 (0)