Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose services handing for private clusters was improved #604

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controllers/clusters/cadence_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ func (r *CadenceReconciler) newWatchStatusJob(cadence *v1beta1.Cadence) schedule
err = exposeservice.Create(r.Client,
cadence.Name,
cadence.Namespace,
cadence.Spec.PrivateNetworkCluster,
nodes,
models.CadenceConnectionPort)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/clusters/cassandra_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ func (r *CassandraReconciler) newWatchStatusJob(cassandra *v1beta1.Cassandra) sc
err = exposeservice.Create(r.Client,
cassandra.Name,
cassandra.Namespace,
cassandra.Spec.PrivateNetworkCluster,
nodes,
models.CassandraConnectionPort)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/clusters/kafka_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ func (r *KafkaReconciler) newWatchStatusJob(kafka *v1beta1.Kafka) scheduler.Job
err = exposeservice.Create(r.Client,
kafka.Name,
kafka.Namespace,
kafka.Spec.PrivateNetworkCluster,
nodes,
models.KafkaConnectionPort)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/clusters/kafkaconnect_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ func (r *KafkaConnectReconciler) newWatchStatusJob(kc *v1beta1.KafkaConnect) sch
err = exposeservice.Create(r.Client,
kc.Name,
kc.Namespace,
kc.Spec.PrivateNetworkCluster,
nodes,
models.KafkaConnectConnectionPort)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/clusters/opensearch_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ func (r *OpenSearchReconciler) newWatchStatusJob(o *v1beta1.OpenSearch) schedule
err = exposeservice.Create(r.Client,
o.Name,
o.Namespace,
o.Spec.PrivateNetworkCluster,
nodes,
models.OpenSearchConnectionPort)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/clusters/postgresql_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ func (r *PostgreSQLReconciler) newWatchStatusJob(pg *v1beta1.PostgreSQL) schedul
err = exposeservice.Create(r.Client,
pg.Name,
pg.Namespace,
pg.Spec.PrivateNetworkCluster,
nodes,
models.PgConnectionPort)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/clusters/redis_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ func (r *RedisReconciler) newWatchStatusJob(redis *v1beta1.Redis) scheduler.Job
err = exposeservice.Create(r.Client,
redis.Name,
redis.Namespace,
redis.Spec.PrivateNetworkCluster,
nodes,
models.RedisConnectionPort)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions controllers/clusters/zookeeper_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ func (r *ZookeeperReconciler) newWatchStatusJob(zook *v1beta1.Zookeeper) schedul
err = exposeservice.Create(r.Client,
zook.Name,
zook.Namespace,
zook.Spec.PrivateNetworkCluster,
nodes,
models.ZookeeperConnectionPort)
if err != nil {
Expand Down
16 changes: 11 additions & 5 deletions pkg/exposeservice/expose_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,24 @@ func Create(
c client.Client,
clusterName string,
ns string,
privateNetworkCluster bool,
nodes []*v1beta1.Node,
targetPort int32,
) error {
addresses := []v1.EndpointAddress{}
for _, node := range nodes {
if node.PublicAddress == "" {
continue
address := ""
if !privateNetworkCluster {
address = node.PublicAddress
} else {
address = node.PrivateAddress
}

addresses = append(addresses, v1.EndpointAddress{
IP: node.PublicAddress,
})
if address != "" {
addresses = append(addresses, v1.EndpointAddress{
IP: address,
})
}
}

if len(addresses) == 0 {
Expand Down