Skip to content

Commit b67e434

Browse files
author
abhisbyk
committed
Added env vars for tcps support
Signed-off-by: abhisbyk <[email protected]>
1 parent 0c6249d commit b67e434

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

apis/database/v1alpha1/singleinstancedatabase_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ type SingleInstanceDatabaseSpec struct {
6565
FlashBack bool `json:"flashBack,omitempty"`
6666
ArchiveLog bool `json:"archiveLog,omitempty"`
6767
ForceLogging bool `json:"forceLog,omitempty"`
68+
EnableTCPS bool `json:"enableTCPS,omitempty"`
69+
TcpsPort int `json:"tcpsPort,omitempty"`
6870

6971
CloneFrom string `json:"cloneFrom,omitempty"`
7072
ReadinessCheckPeriod int `json:"readinessCheckPeriod,omitempty"`

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ spec:
8787
- enterprise
8888
- express
8989
type: string
90+
enableTCPS:
91+
type: boolean
9092
flashBack:
9193
type: boolean
9294
forceLog:
@@ -160,6 +162,8 @@ spec:
160162
maxLength: 12
161163
pattern: ^[a-zA-Z0-9]+$
162164
type: string
165+
tcpsPort:
166+
type: integer
163167
required:
164168
- image
165169
type: object

config/samples/sidb/singleinstancedatabase.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ spec:
4444
## Enable/Disable ForceLogging
4545
forceLog: false
4646

47+
## Enable TCPS
48+
enableTCPS: false
49+
50+
## TCPS custom port
51+
tcpsPort: 1522
52+
4753
## NA if cloning from a SourceDB (cloneFrom is set)
4854
## Specify both sgaSize and pgaSize (in MB) or dont specify both
4955
## Specify Non-Zero value to use

controllers/database/singleinstancedatabase_controller.go

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ type SingleInstanceDatabaseReconciler struct {
7878
var requeueY ctrl.Result = ctrl.Result{Requeue: true, RequeueAfter: 15 * time.Second}
7979
var requeueN ctrl.Result = ctrl.Result{}
8080

81+
// Service Port Declaration
82+
var svc_port string
83+
8184
const singleInstanceDatabaseFinalizer = "database.oracle.com/singleinstancedatabasefinalizer"
8285

8386
//+kubebuilder:rbac:groups=database.oracle.com,resources=singleinstancedatabases,verbs=get;list;watch;create;update;patch;delete
@@ -134,6 +137,14 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
134137
r.Status().Update(ctx, singleInstanceDatabase)
135138
}
136139

140+
// Service Port Initialization
141+
svc_port = func() string {
142+
if singleInstanceDatabase.Spec.EnableTCPS {
143+
return strconv.Itoa(singleInstanceDatabase.Spec.TcpsPort)
144+
}
145+
return "1521"
146+
}()
147+
137148
// Manage SingleInstanceDatabase Deletion
138149
result, err = r.manageSingleInstanceDatabaseDeletion(req, ctx, singleInstanceDatabase)
139150
if result.Requeue {
@@ -639,7 +650,16 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
639650
},
640651
},
641652
},
642-
Ports: []corev1.ContainerPort{{ContainerPort: 1521}, {ContainerPort: 5500}},
653+
Ports: []corev1.ContainerPort{
654+
{ContainerPort: func() int32 {
655+
if m.Spec.EnableTCPS {
656+
return int32(m.Spec.TcpsPort)
657+
}
658+
return int32(1521)
659+
}(),
660+
},
661+
{ContainerPort: 5500},
662+
},
643663

644664
ReadinessProbe: &corev1.Probe{
645665
ProbeHandler: corev1.ProbeHandler{
@@ -687,7 +707,7 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
687707
},
688708
{
689709
Name: "SVC_PORT",
690-
Value: "1521",
710+
Value: svc_port,
691711
},
692712
{
693713
Name: "ORACLE_CHARACTERSET",
@@ -697,6 +717,14 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
697717
Name: "ORACLE_EDITION",
698718
Value: m.Spec.Edition,
699719
},
720+
{
721+
Name: "ENABLE_TCPS",
722+
Value: strconv.FormatBool(m.Spec.EnableTCPS),
723+
},
724+
{
725+
Name: "TCPS_PORT",
726+
Value: strconv.Itoa(m.Spec.TcpsPort),
727+
},
700728
}
701729
}
702730
if m.Spec.CloneFrom == "" {
@@ -708,7 +736,7 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
708736
},
709737
{
710738
Name: "SVC_PORT",
711-
Value: "1521",
739+
Value: svc_port,
712740
},
713741
{
714742
Name: "CREATE_PDB",
@@ -766,6 +794,14 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
766794
Name: "SKIP_DATAPATCH",
767795
Value: "true",
768796
},
797+
{
798+
Name: "ENABLE_TCPS",
799+
Value: strconv.FormatBool(m.Spec.EnableTCPS),
800+
},
801+
{
802+
Name: "TCPS_PORT",
803+
Value: strconv.Itoa(m.Spec.TcpsPort),
804+
},
769805
}
770806
}
771807
// For clone DB use case
@@ -776,7 +812,7 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
776812
},
777813
{
778814
Name: "SVC_PORT",
779-
Value: "1521",
815+
Value: svc_port,
780816
},
781817
{
782818
Name: "ORACLE_SID",
@@ -790,7 +826,7 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
790826
Name: "PRIMARY_DB_CONN_STR",
791827
Value: func() string {
792828
if dbcommons.IsSourceDatabaseOnCluster(m.Spec.CloneFrom) {
793-
return n.Name + ":1521/" + n.Spec.Sid
829+
return n.Name + ":" + svc_port + "/" + n.Spec.Sid
794830
}
795831
return m.Spec.CloneFrom
796832
}(),

0 commit comments

Comments
 (0)