Secret exists when postgresql resource be deleted
Issue
In my k8s environment, I created a postgresql resource named acid-pgcluster in testdb namespace:
[root@master1~]# kubectl get postgresql -n testdb
NAME AGE
acid-pgcluster 10m
[root@master1 ~]# kubectl get po -n testdb
NAME READY STATUS RESTARTS AGE
acid-pgcluster-0 1/1 Running 0 6m
acid-pgcluster-1 1/1 Running 0 6m
[root@master1 ~]# kubectl get po -n testdb
NAME READY STATUS RESTARTS AGE
acid-pgcluster-0 1/1 Running 0 6m
acid-pgcluster-1 1/1 Running 0 6m
And then, I deleted the acid-pgcluster postgresql resource:
[root@master1 ~]# kubectl delete postgresql -n testdb acid-pgcluster
postgresql.acid.zalan.do "acid-pgcluster" deleted
After 30 seconds, I found pod, sts, service resources were all deleted, but the secret resource remained:
[root@master1 ~]# kubectl get secret -n testdb
NAME TYPE DATA AGE
default-token-xqnh7 kubernetes.io/service-account-token 3 27m
postgres.acid-pgcluster.credentials Opaque 2 16m
standby.acid-pgcluster.credentials Opaque 2 16m
zalando-postgres-operator-token-x85l9 kubernetes.io/service-account-token 3 16m
yaml file
postgersql.yaml:
apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
name: acid-pgcluster
namespace: testdb
spec:
teamId: "ACID"
volume:
size: 1Gi
numberOfInstances: 2
users:
# database owner
zalando:
- superuser
- createdb
testdb:
- superuser
- createdb
# role for application foo
foo_user:
enableMasterLoadBalancer: true
enableReplicaLoadBalancer: true
#databases: name->owner
databases:
testdb: testdb
foo: zalando
resources:
requests:
cpu: 10m
memory: 100Mi
limits:
cpu: 300m
memory: 300Mi
postgresql:
version: "10"
Version
registry.opensource.zalan.do/acid/postgres-operator:v1.0.0
Question
Is this normal?
Operator will not remove secrets for replication user and superuser (see this code). Other than that you can check the log, because for every secret there should be a message with decision to remove or not.
Operator will not remove secrets for replication user and superuser (see this code). Other than that you can check the log, because for every secret there should be a message with decision to remove or not.
@erthalion Hi, thanks for your answer. :) I saw the git log in this commit:
make sure that the secrets for the system users (superuser, replication) are not deleted when the main
cluster is. Therefore, we can re-create the cluster, potentially forcing Patroni to restore it from the backup
and enable Patroni to connect, since it will use the old password, not the newly generated random one.