From 0986e5622604467c1efa096e0b5208fd5a703cf0 Mon Sep 17 00:00:00 2001 From: Sergey Dudoladov Date: Wed, 14 Mar 2018 12:10:10 +0100 Subject: [PATCH] Add separate params for master and replica load balancers to operator configuration --- manifests/complete-postgres-manifest.yaml | 2 +- manifests/configmap.yaml | 3 +- pkg/cluster/k8sres.go | 2 +- pkg/util/config/config.go | 49 ++++++++++++----------- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/manifests/complete-postgres-manifest.yaml b/manifests/complete-postgres-manifest.yaml index e5908df03..5663dcbc2 100644 --- a/manifests/complete-postgres-manifest.yaml +++ b/manifests/complete-postgres-manifest.yaml @@ -13,7 +13,7 @@ spec: - superuser - createdb enableMasterLoadBalancer: true - # enableReplicaLoadBalancer: true # uncomment to enable a LB for a replica k8s service + # enableReplicaLoadBalancer: true allowedSourceRanges: # load balancers' source ranges for both master and replica services - 127.0.0.1/32 databases: diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index cc0af9fe0..edb308a37 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -36,7 +36,8 @@ data: team_admin_role: "admin" teams_api_url: http://fake-teams-api.default.svc.cluster.local workers: "4" - enable_load_balancer: "true" + enable_master_load_balancer: "true" + # enable_replica_load_balancer: "true" api_port: "8080" ring_log_lines: "100" cluster_history_entries: "1000" diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 58a5529bf..edd1d4cf9 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -679,7 +679,7 @@ func (c *Cluster) shouldCreateLoadBalancerForService(role PostgresRole, spec *sp // create a load balancer for the master service if either Postgres or operator manifests tell to do so // if ReplicaLoadBalancer is unset and LB for master service is created, also create a balancer for replicas return (spec.EnableMasterLoadBalancer != nil && *spec.EnableMasterLoadBalancer) || - (spec.EnableMasterLoadBalancer == nil && c.OpConfig.EnableLoadBalancer) + (spec.EnableMasterLoadBalancer == nil && c.OpConfig.EnableMasterLoadBalancer) } diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 2c83b36b3..76a9d6b70 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -67,30 +67,31 @@ type Config struct { Resources Auth Scalyr - WatchedNamespace string `name:"watched_namespace"` // special values: "*" means 'watch all namespaces', the empty string "" means 'watch a namespace where operator is deployed to' - EtcdHost string `name:"etcd_host" default:"etcd-client.default.svc.cluster.local:2379"` - DockerImage string `name:"docker_image" default:"registry.opensource.zalan.do/acid/spiloprivate-9.6:1.2-p4"` - ServiceAccountName string `name:"service_account_name" default:"operator"` - DbHostedZone string `name:"db_hosted_zone" default:"db.example.com"` - EtcdScope string `name:"etcd_scope" default:"service"` - WALES3Bucket string `name:"wal_s3_bucket"` - KubeIAMRole string `name:"kube_iam_role"` - DebugLogging bool `name:"debug_logging" default:"true"` - EnableDBAccess bool `name:"enable_database_access" default:"true"` - EnableTeamsAPI bool `name:"enable_teams_api" default:"true"` - EnableTeamSuperuser bool `name:"enable_team_superuser" default:"false"` - TeamAdminRole string `name:"team_admin_role" default:"admin"` - EnableLoadBalancer bool `name:"enable_load_balancer" default:"true"` - MasterDNSNameFormat stringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` - ReplicaDNSNameFormat stringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{team}.{hostedzone}"` - PDBNameFormat stringTemplate `name:"pdb_name_format" default:"postgres-{cluster}-pdb"` - Workers uint32 `name:"workers" default:"4"` - APIPort int `name:"api_port" default:"8080"` - RingLogLines int `name:"ring_log_lines" default:"100"` - ClusterHistoryEntries int `name:"cluster_history_entries" default:"1000"` - TeamAPIRoleConfiguration map[string]string `name:"team_api_role_configuration" default:"log_statement:all"` - PodTerminateGracePeriod time.Duration `name:"pod_terminate_grace_period" default:"5m"` - ProtectedRoles []string `name:"protected_role_names" default:"admin"` + WatchedNamespace string `name:"watched_namespace"` // special values: "*" means 'watch all namespaces', the empty string "" means 'watch a namespace where operator is deployed to' + EtcdHost string `name:"etcd_host" default:"etcd-client.default.svc.cluster.local:2379"` + DockerImage string `name:"docker_image" default:"registry.opensource.zalan.do/acid/spiloprivate-9.6:1.2-p4"` + ServiceAccountName string `name:"service_account_name" default:"operator"` + DbHostedZone string `name:"db_hosted_zone" default:"db.example.com"` + EtcdScope string `name:"etcd_scope" default:"service"` + WALES3Bucket string `name:"wal_s3_bucket"` + KubeIAMRole string `name:"kube_iam_role"` + DebugLogging bool `name:"debug_logging" default:"true"` + EnableDBAccess bool `name:"enable_database_access" default:"true"` + EnableTeamsAPI bool `name:"enable_teams_api" default:"true"` + EnableTeamSuperuser bool `name:"enable_team_superuser" default:"false"` + TeamAdminRole string `name:"team_admin_role" default:"admin"` + EnableMasterLoadBalancer bool `name:"enable_master_load_balancer" default:"true"` + EnableReplicaLoadBalancer bool `name:"enable_replica_load_balancer" default:"false"` + MasterDNSNameFormat stringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` + ReplicaDNSNameFormat stringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{team}.{hostedzone}"` + PDBNameFormat stringTemplate `name:"pdb_name_format" default:"postgres-{cluster}-pdb"` + Workers uint32 `name:"workers" default:"4"` + APIPort int `name:"api_port" default:"8080"` + RingLogLines int `name:"ring_log_lines" default:"100"` + ClusterHistoryEntries int `name:"cluster_history_entries" default:"1000"` + TeamAPIRoleConfiguration map[string]string `name:"team_api_role_configuration" default:"log_statement:all"` + PodTerminateGracePeriod time.Duration `name:"pod_terminate_grace_period" default:"5m"` + ProtectedRoles []string `name:"protected_role_names" default:"admin"` } // MustMarshal marshals the config or panics