Skip to content

Commit 0f95997

Browse files
committed
re-implement WATCH_NAMESPACE
1 parent 3ec3f6a commit 0f95997

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Diff for: charts/ext-postgres-operator/templates/operator.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ spec:
3030
securityContext:
3131
{{- toYaml .Values.securityContext | nindent 12 }}
3232
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
33-
command:
34-
- postgres-operator
3533
imagePullPolicy: {{ .Values.image.pullPolicy }}
3634
envFrom:
3735
- secretRef:
@@ -47,6 +45,10 @@ spec:
4745
valueFrom:
4846
fieldRef:
4947
fieldPath: metadata.name
48+
{{- if .Values.prefix }}
49+
- name: POSTGRES_OBJECT_PREFIX
50+
value: {{ .Values.prefix }}
51+
{{- end }}
5052
- name: OPERATOR_NAME
5153
value: {{ include "chart.fullname" . }}
5254
{{- range $key, $value := .Values.env }}

Diff for: charts/ext-postgres-operator/values.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
replicaCount: 1
66

77
image:
8-
repository: ghcr.io/movetokube/postgres-operator
9-
pullPolicy: IfNotPresent
8+
repository: public-docker.docker.ppidev.net/ppi/k5s/k5s-external-postgres-operator
9+
pullPolicy: Always
1010
# Overrides the image tag whose default is the chart appVersion.
11-
tag: "latest"
11+
tag: "0-release-0-0-1-int-SNAPSHOT"
1212

1313
# Override chart name, defaults to Chart.name
1414
nameOverride: ""

Diff for: cmd/main.go

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2828
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
2929
ctrl "sigs.k8s.io/controller-runtime"
30+
"sigs.k8s.io/controller-runtime/pkg/cache"
3031
"sigs.k8s.io/controller-runtime/pkg/healthz"
3132
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3233

@@ -66,13 +67,20 @@ func main() {
6667

6768
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
6869

70+
cacheOpts := cache.Options{}
71+
namespace, found := os.LookupEnv("WATCH_NAMESPACE")
72+
if found {
73+
cacheOpts.Namespaces = []string{namespace}
74+
}
75+
6976
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
7077
Scheme: scheme,
7178
MetricsBindAddress: metricsAddr,
7279
Port: 9443,
7380
HealthProbeBindAddress: probeAddr,
7481
LeaderElection: enableLeaderElection,
7582
LeaderElectionID: "c5655ffe.db.movetokube.com",
83+
Cache: cacheOpts,
7684
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
7785
// when the Manager ends. This requires the binary to immediately end when the
7886
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly

Diff for: internal/postgres/database.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const (
1212
CREATE_SCHEMA = `CREATE SCHEMA IF NOT EXISTS "%s" AUTHORIZATION "%s"`
1313
CREATE_EXTENSION = `CREATE EXTENSION IF NOT EXISTS "%s"`
1414
ALTER_DB_OWNER = `ALTER DATABASE "%s" OWNER TO "%s"`
15-
DROP_DATABASE = `DROP DATABASE "%s"`
15+
DROP_DATABASE = `DROP DATABASE IF EXISTS "%s" WITH (FORCE)`
1616
GRANT_USAGE_SCHEMA = `GRANT USAGE ON SCHEMA "%s" TO "%s"`
1717
GRANT_ALL_TABLES = `GRANT %s ON ALL TABLES IN SCHEMA "%s" TO "%s"`
1818
DEFAULT_PRIVS_SCHEMA = `ALTER DEFAULT PRIVILEGES FOR ROLE "%s" IN SCHEMA "%s" GRANT %s ON TABLES TO "%s"`

0 commit comments

Comments
 (0)