Skip to content

Commit

Permalink
pgupgrade: Use different service for postgres old (PROJQUAY-6672)
Browse files Browse the repository at this point in the history
- Use a different service for the old postgres deployment during the upgrade process
- This ensures that the service will not point to the terminating deployment
  • Loading branch information
jonathankingfc authored and bcaton85 committed Oct 22, 2024
1 parent d8bc894 commit 9c25195
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ kind: Deployment
metadata:
name: clair-postgres-old
labels:
quay-component: clair-postgres
quay-component: clair-postgres-old
annotations:
quay-component: clair-postgres
quay-component: clair-postgres-old
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
quay-component: clair-postgres
quay-component: clair-postgres-old
template:
metadata:
labels:
quay-component: clair-postgres
quay-component: clair-postgres-old
spec:
terminationGracePeriodSeconds: 180
serviceAccountName: clair-postgres
Expand Down
17 changes: 17 additions & 0 deletions kustomize/components/clairpgupgrade/base/clair-pg-old.service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: clair-postgres-old
labels:
quay-component: clair-postgres-old
annotations:
quay-component: clair-postgres-old
spec:
type: ClusterIP
ports:
- port: 5432
protocol: TCP
name: postgres
targetPort: 5432
selector:
quay-component: clair-postgres-old
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
valueFrom:
secretKeyRef:
name: clair-config-secret
key: clair-db-host
key: clair-db-old-host
- name: POSTGRESQL_MIGRATION_ADMIN_PASSWORD
value: postgres
- name: POSTGRESQL_SHARED_BUFFERS
Expand All @@ -49,9 +49,9 @@ spec:
cpu: 500m
memory: 2Gi
command:
- "/bin/sh"
- "-c"
- "/bin/sh"
- "-c"
args:
- >
run-postgresql --version || (echo "postgres migration command failed, cleaning up..." && rm -rf /var/lib/pgsql/data/* && exit 1)
- >
run-postgresql --version || (echo "postgres migration command failed, cleaning up..." && rm -rf /var/lib/pgsql/data/* && exit 1)
backoffLimit: 50
1 change: 1 addition & 0 deletions pkg/kustomize/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ func componentConfigFilesFor(log logr.Logger, qctx *quaycontext.QuayRegistryCont
cfgFiles["config.yaml"] = cfg
cfgFiles["01_user_config.yaml"] = configFiles["clair-config.yaml"]
cfgFiles["clair-db-host"] = []byte(strings.TrimSpace(strings.Join([]string{quay.GetName(), "clair-postgres"}, "-")))
cfgFiles["clair-db-old-host"] = []byte(strings.TrimSpace(strings.Join([]string{quay.GetName(), "clair-postgres-old"}, "-")))

return cfgFiles, nil
default:
Expand Down

0 comments on commit 9c25195

Please sign in to comment.