@@ -36,6 +36,7 @@ import (
3636// ServiceInterface has methods to work with Service resources.
3737type ServiceInterface interface {
3838 Create (* v1.Service ) (* v1.Service , error )
39+ Update (* v1.Service ) (* v1.Service , error )
3940 Delete (name string , options * metav1.DeleteOptions ) error
4041 Get (name string , options metav1.GetOptions ) (* v1.Service , error )
4142}
@@ -120,7 +121,7 @@ func CreateHeadlessService(svcs ServiceInterface, deployment metav1.Object, owne
120121 }
121122 publishNotReadyAddresses := true
122123 serviceType := v1 .ServiceTypeClusterIP
123- newlyCreated , err := createService (svcs , svcName , deploymentName , deployment .GetNamespace (), ClusterIPNone , "" , serviceType , ports , "" , publishNotReadyAddresses , owner )
124+ newlyCreated , err := createService (svcs , svcName , deploymentName , deployment .GetNamespace (), ClusterIPNone , "" , serviceType , ports , "" , nil , publishNotReadyAddresses , owner )
124125 if err != nil {
125126 return "" , false , maskAny (err )
126127 }
@@ -149,7 +150,7 @@ func CreateDatabaseClientService(svcs ServiceInterface, deployment metav1.Object
149150 }
150151 serviceType := v1 .ServiceTypeClusterIP
151152 publishNotReadyAddresses := false
152- newlyCreated , err := createService (svcs , svcName , deploymentName , deployment .GetNamespace (), "" , role , serviceType , ports , "" , publishNotReadyAddresses , owner )
153+ newlyCreated , err := createService (svcs , svcName , deploymentName , deployment .GetNamespace (), "" , role , serviceType , ports , "" , nil , publishNotReadyAddresses , owner )
153154 if err != nil {
154155 return "" , false , maskAny (err )
155156 }
@@ -160,7 +161,7 @@ func CreateDatabaseClientService(svcs ServiceInterface, deployment metav1.Object
160161// If the service already exists, nil is returned.
161162// If another error occurs, that error is returned.
162163// The returned bool is true if the service is created, or false when the service already existed.
163- func CreateExternalAccessService (svcs ServiceInterface , svcName , role string , deployment metav1.Object , serviceType v1.ServiceType , port , nodePort int , loadBalancerIP string , owner metav1.OwnerReference ) (string , bool , error ) {
164+ func CreateExternalAccessService (svcs ServiceInterface , svcName , role string , deployment metav1.Object , serviceType v1.ServiceType , port , nodePort int , loadBalancerIP string , loadBalancerSourceRanges [] string , owner metav1.OwnerReference ) (string , bool , error ) {
164165 deploymentName := deployment .GetName ()
165166 ports := []v1.ServicePort {
166167 v1.ServicePort {
@@ -171,7 +172,7 @@ func CreateExternalAccessService(svcs ServiceInterface, svcName, role string, de
171172 },
172173 }
173174 publishNotReadyAddresses := false
174- newlyCreated , err := createService (svcs , svcName , deploymentName , deployment .GetNamespace (), "" , role , serviceType , ports , loadBalancerIP , publishNotReadyAddresses , owner )
175+ newlyCreated , err := createService (svcs , svcName , deploymentName , deployment .GetNamespace (), "" , role , serviceType , ports , loadBalancerIP , loadBalancerSourceRanges , publishNotReadyAddresses , owner )
175176 if err != nil {
176177 return "" , false , maskAny (err )
177178 }
@@ -183,7 +184,7 @@ func CreateExternalAccessService(svcs ServiceInterface, svcName, role string, de
183184// If another error occurs, that error is returned.
184185// The returned bool is true if the service is created, or false when the service already existed.
185186func createService (svcs ServiceInterface , svcName , deploymentName , ns , clusterIP , role string , serviceType v1.ServiceType ,
186- ports []v1.ServicePort , loadBalancerIP string , publishNotReadyAddresses bool , owner metav1.OwnerReference ) (bool , error ) {
187+ ports []v1.ServicePort , loadBalancerIP string , loadBalancerSourceRanges [] string , publishNotReadyAddresses bool , owner metav1.OwnerReference ) (bool , error ) {
187188 labels := LabelsForDeployment (deploymentName , role )
188189 svc := & v1.Service {
189190 ObjectMeta : metav1.ObjectMeta {
@@ -203,6 +204,7 @@ func createService(svcs ServiceInterface, svcName, deploymentName, ns, clusterIP
203204 ClusterIP : clusterIP ,
204205 PublishNotReadyAddresses : publishNotReadyAddresses ,
205206 LoadBalancerIP : loadBalancerIP ,
207+ LoadBalancerSourceRanges : loadBalancerSourceRanges ,
206208 },
207209 }
208210 addOwnerRefToObject (svc .GetObjectMeta (), & owner )
0 commit comments