Skip to content

Commit 90de960

Browse files
MikeDevressehorsegegunesinelpandzic
authored
K8SPSMDB-1032: Added possibility to specify nodeport for mongos expose (#1392)
* Added possibility to specify nodeport for mongos expose * Fix unused variable * Added example in deploy/cr.yaml * Fix indent * Fix indent * Fix indent * Update CRD to have nodeport * Added nodeport to cw-bundle * Generated new manifests * Fix objects not getting replaced * Fix nodeport in the right place * Fix port to be in range --------- Co-authored-by: Viacheslav Sarzhan <[email protected]> Co-authored-by: Ege Güneş <[email protected]> Co-authored-by: Inel Pandzic <[email protected]>
1 parent 0672d76 commit 90de960

File tree

8 files changed

+53
-0
lines changed

8 files changed

+53
-0
lines changed

config/crd/bases/psmdb.percona.com_perconaservermongodbs.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,6 +3041,9 @@ spec:
30413041
items:
30423042
type: string
30433043
type: array
3044+
nodePort:
3045+
format: int32
3046+
type: integer
30443047
serviceAnnotations:
30453048
additionalProperties:
30463049
type: string
@@ -10231,6 +10234,9 @@ spec:
1023110234
items:
1023210235
type: string
1023310236
type: array
10237+
nodePort:
10238+
format: int32
10239+
type: integer
1023410240
serviceAnnotations:
1023510241
additionalProperties:
1023610242
type: string
@@ -15307,6 +15313,9 @@ spec:
1530715313
items:
1530815314
type: string
1530915315
type: array
15316+
nodePort:
15317+
format: int32
15318+
type: integer
1531015319
serviceAnnotations:
1531115320
additionalProperties:
1531215321
type: string

deploy/bundle.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,6 +3680,9 @@ spec:
36803680
items:
36813681
type: string
36823682
type: array
3683+
nodePort:
3684+
format: int32
3685+
type: integer
36833686
serviceAnnotations:
36843687
additionalProperties:
36853688
type: string
@@ -10870,6 +10873,9 @@ spec:
1087010873
items:
1087110874
type: string
1087210875
type: array
10876+
nodePort:
10877+
format: int32
10878+
type: integer
1087310879
serviceAnnotations:
1087410880
additionalProperties:
1087510881
type: string
@@ -15946,6 +15952,9 @@ spec:
1594615952
items:
1594715953
type: string
1594815954
type: array
15955+
nodePort:
15956+
format: int32
15957+
type: integer
1594915958
serviceAnnotations:
1595015959
additionalProperties:
1595115960
type: string

deploy/cr.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ spec:
497497
# service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
498498
# serviceLabels:
499499
# rack: rack-22
500+
# nodePort: 32017
500501
# hostAliases:
501502
# - ip: "10.10.0.2"
502503
# hostnames:

deploy/crd.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,6 +3680,9 @@ spec:
36803680
items:
36813681
type: string
36823682
type: array
3683+
nodePort:
3684+
format: int32
3685+
type: integer
36833686
serviceAnnotations:
36843687
additionalProperties:
36853688
type: string
@@ -10870,6 +10873,9 @@ spec:
1087010873
items:
1087110874
type: string
1087210875
type: array
10876+
nodePort:
10877+
format: int32
10878+
type: integer
1087310879
serviceAnnotations:
1087410880
additionalProperties:
1087510881
type: string
@@ -15946,6 +15952,9 @@ spec:
1594615952
items:
1594715953
type: string
1594815954
type: array
15955+
nodePort:
15956+
format: int32
15957+
type: integer
1594915958
serviceAnnotations:
1595015959
additionalProperties:
1595115960
type: string

deploy/cw-bundle.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,6 +3680,9 @@ spec:
36803680
items:
36813681
type: string
36823682
type: array
3683+
nodePort:
3684+
format: int32
3685+
type: integer
36833686
serviceAnnotations:
36843687
additionalProperties:
36853688
type: string
@@ -10870,6 +10873,9 @@ spec:
1087010873
items:
1087110874
type: string
1087210875
type: array
10876+
nodePort:
10877+
format: int32
10878+
type: integer
1087310879
serviceAnnotations:
1087410880
additionalProperties:
1087510881
type: string
@@ -15946,6 +15952,9 @@ spec:
1594615952
items:
1594715953
type: string
1594815954
type: array
15955+
nodePort:
15956+
format: int32
15957+
type: integer
1594915958
serviceAnnotations:
1595015959
additionalProperties:
1595115960
type: string

e2e-tests/version-service/conf/crd.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,6 +3680,9 @@ spec:
36803680
items:
36813681
type: string
36823682
type: array
3683+
nodePort:
3684+
format: int32
3685+
type: integer
36833686
serviceAnnotations:
36843687
additionalProperties:
36853688
type: string
@@ -10870,6 +10873,9 @@ spec:
1087010873
items:
1087110874
type: string
1087210875
type: array
10876+
nodePort:
10877+
format: int32
10878+
type: integer
1087310879
serviceAnnotations:
1087410880
additionalProperties:
1087510881
type: string
@@ -15946,6 +15952,9 @@ spec:
1594615952
items:
1594715953
type: string
1594815954
type: array
15955+
nodePort:
15956+
format: int32
15957+
type: integer
1594915958
serviceAnnotations:
1595015959
additionalProperties:
1595115960
type: string

pkg/apis/psmdb/v1/psmdb_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ type Expose struct {
856856
LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty"`
857857
ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"`
858858
ServiceLabels map[string]string `json:"serviceLabels,omitempty"`
859+
NodePort int32 `json:"nodePort,omitempty"`
859860
}
860861

861862
func (e *Expose) SaveOldMeta() bool {

pkg/psmdb/mongos.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ func MongosServiceSpec(cr *api.PerconaServerMongoDB, podName string) corev1.Serv
443443
case corev1.ServiceTypeNodePort:
444444
spec.Type = corev1.ServiceTypeNodePort
445445
spec.ExternalTrafficPolicy = "Local"
446+
if !cr.Spec.Sharding.Mongos.Expose.ServicePerPod {
447+
for i, port := range spec.Ports {
448+
port.NodePort = cr.Spec.Sharding.Mongos.Expose.NodePort
449+
spec.Ports[i] = port
450+
}
451+
}
446452
case corev1.ServiceTypeLoadBalancer:
447453
spec.Type = corev1.ServiceTypeLoadBalancer
448454
spec.ExternalTrafficPolicy = "Cluster"

0 commit comments

Comments
 (0)