File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -35,13 +35,11 @@ const (
3535// exporter to be accessible
3636func PostgreSQLHBAs (inCluster * v1beta1.PostgresCluster , outHBAs * postgres.HBAs ) {
3737 if ExporterEnabled (inCluster ) {
38- // Kubernetes does guarantee localhost resolves to loopback:
39- // https://kubernetes.io/docs/concepts/cluster-administration/networking/
40- // https://releases.k8s.io/v1.21.0/pkg/kubelet/kubelet_pods.go#L343
41- outHBAs .Mandatory = append (outHBAs .Mandatory , * postgres .NewHBA ().TCP ().
42- User (MonitoringUser ).Network ("127.0.0.0/8" ).Method ("scram-sha-256" ))
43- outHBAs .Mandatory = append (outHBAs .Mandatory , * postgres .NewHBA ().TCP ().
44- User (MonitoringUser ).Network ("::1/128" ).Method ("scram-sha-256" ))
38+ // Limit the monitoring user to local connections using SCRAM.
39+ outHBAs .Mandatory = append (outHBAs .Mandatory ,
40+ * postgres .NewHBA ().TCP ().User (MonitoringUser ).Method ("scram-sha-256" ).Network ("127.0.0.0/8" ),
41+ * postgres .NewHBA ().TCP ().User (MonitoringUser ).Method ("scram-sha-256" ).Network ("::1/128" ),
42+ * postgres .NewHBA ().TCP ().User (MonitoringUser ).Method ("reject" ))
4543 }
4644}
4745
Original file line number Diff line number Diff line change @@ -46,8 +46,10 @@ func TestPostgreSQLHBA(t *testing.T) {
4646 outHBAs := postgres.HBAs {}
4747 PostgreSQLHBAs (inCluster , & outHBAs )
4848
49+ assert .Equal (t , len (outHBAs .Mandatory ), 3 )
4950 assert .Equal (t , outHBAs .Mandatory [0 ].String (), `host all "ccp_monitoring" "127.0.0.0/8" scram-sha-256` )
5051 assert .Equal (t , outHBAs .Mandatory [1 ].String (), `host all "ccp_monitoring" "::1/128" scram-sha-256` )
52+ assert .Equal (t , outHBAs .Mandatory [2 ].String (), `host all "ccp_monitoring" all reject` )
5153 })
5254}
5355
You can’t perform that action at this time.
0 commit comments