From 42a4c174913f28d1bb5fe565b013d86cfa09c64f Mon Sep 17 00:00:00 2001 From: Alec Merdler Date: Mon, 21 Sep 2020 19:36:44 -0700 Subject: [PATCH] adding downstream official Red Hat container images for components --- apis/quay/v1/quayregistry_types.go | 107 ++++++++++++++---- apis/quay/v1/quayregistry_types_test.go | 39 +++++-- controllers/quay/quayregistry_controller.go | 7 +- .../quay-operator.clusterserviceversion.yaml | 10 +- .../components/clair/clair.deployment.yaml | 5 +- .../components/clair/postgres.deployment.yaml | 18 +-- .../components/postgres/create-extensions.sh | 6 + kustomize/components/postgres/init.job.yaml | 35 ++++++ .../components/postgres/kustomization.yaml | 6 +- .../components/postgres/migrate.job.yaml | 31 ----- .../postgres/postgres.deployment.yaml | 35 +++--- kustomize/components/postgres/restore.sh | 4 +- .../downstream/v3.4.0/kustomization.yaml | 19 ++++ .../v3.4.0}/upgrade/kustomization.yaml | 15 ++- .../upgrade/quay.deployment.patch.yaml | 2 +- .../upgrade/upgrade.deployment.patch.yaml | 2 +- .../upstream/qui-gon/kustomization.yaml | 12 -- pkg/kustomize/kustomize.go | 7 +- pkg/kustomize/kustomize_test.go | 4 +- pkg/kustomize/secrets.go | 2 +- 20 files changed, 244 insertions(+), 122 deletions(-) create mode 100644 kustomize/components/postgres/create-extensions.sh create mode 100644 kustomize/components/postgres/init.job.yaml delete mode 100644 kustomize/components/postgres/migrate.job.yaml create mode 100644 kustomize/overlays/downstream/v3.4.0/kustomization.yaml rename kustomize/overlays/{upstream/qui-gon => downstream/v3.4.0}/upgrade/kustomization.yaml (51%) rename kustomize/overlays/{upstream/qui-gon => downstream/v3.4.0}/upgrade/quay.deployment.patch.yaml (79%) rename kustomize/overlays/{upstream/qui-gon => downstream/v3.4.0}/upgrade/upgrade.deployment.patch.yaml (80%) delete mode 100644 kustomize/overlays/upstream/qui-gon/kustomization.yaml diff --git a/apis/quay/v1/quayregistry_types.go b/apis/quay/v1/quayregistry_types.go index 0e960033a..3b0753e8e 100644 --- a/apis/quay/v1/quayregistry_types.go +++ b/apis/quay/v1/quayregistry_types.go @@ -18,6 +18,7 @@ package v1 import ( "errors" + "os" "strings" "k8s.io/apimachinery/pkg/api/meta" @@ -25,8 +26,6 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) -type QuayVersion string - const ( SupportsRoutesAnnotation = "supports-routes" ClusterHostnameAnnotation = "router-canonical-hostname" @@ -36,28 +35,76 @@ const ( StorageBucketNameAnnotation = "storage-bucketname" StorageAccessKeyAnnotation = "storage-access-key" StorageSecretKeyAnnotation = "storage-secret-key" + + defaultVersionStreamKey = "DEFAULT_STREAM" +) + +type QuayStream string + +const ( + QuayUpstream QuayStream = "upstream" + QuayDownstream QuayStream = "downstream" + + QuayStreamNone QuayStream = "" ) +type QuayVersion string + const ( - QuayVersionVader QuayVersion = "vader" - QuayVersionQuiGon QuayVersion = "qui-gon" + // Upstream versions + QuayVersionVader QuayVersion = "vader" + + // Downstream versions + QuayVersion340 QuayVersion = "v3.4.0" + // QuayVersionDev is used to provide Kustomize overrides. QuayVersionDev QuayVersion = "dev" + + QuayVersionNone QuayVersion = "" ) -var quayVersions = map[QuayVersion]int{ - QuayVersionDev: 0, - QuayVersionQuiGon: 1, - QuayVersionVader: 2, +var quayVersions = map[QuayVersion]struct { + Next QuayVersion + Stream QuayStream +}{ + QuayVersionVader: { + Next: "", + Stream: QuayUpstream, + }, + QuayVersion340: { + Next: "", + Stream: QuayDownstream, + }, + QuayVersionDev: { + Next: QuayVersionDev, + Stream: QuayStreamNone, + }, + QuayVersionNone: { + Next: QuayVersionNone, + Stream: QuayStreamNone, + }, +} + +// Next returns the version that succeeds this version. +func (version QuayVersion) Next() QuayVersion { + return quayVersions[version].Next +} + +// Stream returns the source for this version. +func (version QuayVersion) Stream() QuayStream { + return quayVersions[version].Stream } func mostRecentVersion() QuayVersion { - var mostRecent QuayVersion - mostRecentRank := 0 - for v, rank := range quayVersions { - if rank > mostRecentRank { - mostRecent = v - mostRecentRank = rank + defaultVersionStream := QuayUpstream + if os.Getenv(defaultVersionStreamKey) == string(QuayDownstream) { + defaultVersionStream = QuayDownstream + } + + mostRecent := QuayVersionNone + for version, info := range quayVersions { + if info.Stream == defaultVersionStream && info.Next == QuayVersionNone { + mostRecent = version } } @@ -197,18 +244,32 @@ func ComponentsMatch(firstComponents, secondComponents []Component) bool { func EnsureDesiredVersion(quay *QuayRegistry) (*QuayRegistry, error) { updatedQuay := quay.DeepCopy() - if updatedQuay.Spec.DesiredVersion == "" { - updatedQuay.Spec.DesiredVersion = mostRecentVersion() + if quay.Status.CurrentVersion == QuayVersionNone { + if updatedQuay.Spec.DesiredVersion == QuayVersionNone { + updatedQuay.Spec.DesiredVersion = mostRecentVersion() + return updatedQuay, nil + } - return updatedQuay, nil - } + if _, ok := quayVersions[updatedQuay.Spec.DesiredVersion]; !ok { + return updatedQuay, errors.New("invalid `desiredVersion`: " + string(updatedQuay.Spec.DesiredVersion)) + } + } else { + if updatedQuay.Spec.DesiredVersion == QuayVersionNone { + updatedQuay.Spec.DesiredVersion = quay.Status.CurrentVersion + return updatedQuay, nil + } - if quay.Status.CurrentVersion != "" && quayVersions[quay.Status.CurrentVersion] > quayVersions[updatedQuay.Spec.DesiredVersion] { - return updatedQuay, errors.New("cannot downgrade from `currentVersion`: " + string(quay.Status.CurrentVersion) + " > " + string(updatedQuay.Spec.DesiredVersion)) - } + if quay.Spec.DesiredVersion == quay.Status.CurrentVersion { + return updatedQuay, nil + } - if _, ok := quayVersions[updatedQuay.Spec.DesiredVersion]; !ok { - return updatedQuay, errors.New("invalid `desiredVersion`: " + string(updatedQuay.Spec.DesiredVersion)) + if _, ok := quayVersions[updatedQuay.Spec.DesiredVersion]; !ok { + return updatedQuay, errors.New("invalid `desiredVersion`: " + string(updatedQuay.Spec.DesiredVersion)) + } + + if updatedQuay.Spec.DesiredVersion != quay.Status.CurrentVersion.Next() { + return updatedQuay, errors.New("cannot downgrade from `currentVersion`: " + string(quay.Status.CurrentVersion) + " > " + string(updatedQuay.Spec.DesiredVersion)) + } } return updatedQuay, nil diff --git a/apis/quay/v1/quayregistry_types_test.go b/apis/quay/v1/quayregistry_types_test.go index 9e2f1de3c..2c937d7d0 100644 --- a/apis/quay/v1/quayregistry_types_test.go +++ b/apis/quay/v1/quayregistry_types_test.go @@ -194,6 +194,22 @@ var ensureDesiredVersionTests = []struct { expected QuayVersion expectedErr error }{ + { + "DesiredVersionEmptyCurrentVersionEmpty", + QuayRegistry{}, + QuayVersionVader, + nil, + }, + { + "DesiredVersionEmptyCurrentVersionSet", + QuayRegistry{ + Status: QuayRegistryStatus{ + CurrentVersion: QuayVersionVader, + }, + }, + QuayVersionVader, + nil, + }, { "InvalidDesiredVersion", QuayRegistry{ @@ -205,33 +221,40 @@ var ensureDesiredVersionTests = []struct { errors.New("invalid `desiredVersion`: not-a-real-version"), }, { - "EmptyDesiredVersion", - QuayRegistry{}, - QuayVersionVader, + "DevOverrideDesiredVersionCurrentVersionEmpty", + QuayRegistry{ + Spec: QuayRegistrySpec{ + DesiredVersion: QuayVersionDev, + }, + }, + QuayVersionDev, nil, }, { - "DevOverrideDesiredVersion", + "DevOverrideDesiredVersionCurrentVersionSet", QuayRegistry{ Spec: QuayRegistrySpec{ DesiredVersion: QuayVersionDev, }, + Status: QuayRegistryStatus{ + CurrentVersion: QuayVersionVader, + }, }, - QuayVersionDev, - nil, + QuayVersionVader, + errors.New("cannot downgrade from `currentVersion`: vader > dev"), }, { "DowngradeProhibited", QuayRegistry{ Spec: QuayRegistrySpec{ - DesiredVersion: QuayVersionQuiGon, + DesiredVersion: QuayVersionDev, }, Status: QuayRegistryStatus{ CurrentVersion: QuayVersionVader, }, }, QuayVersionVader, - errors.New("cannot downgrade from `currentVersion`: qui-gon > vader"), + errors.New("cannot downgrade from `currentVersion`: vader > dev"), }, } diff --git a/controllers/quay/quayregistry_controller.go b/controllers/quay/quayregistry_controller.go index 2c3521f50..9fa5569a2 100644 --- a/controllers/quay/quayregistry_controller.go +++ b/controllers/quay/quayregistry_controller.go @@ -44,7 +44,7 @@ import ( ) const upgradePollInterval = time.Second * 10 -const upgradePollTimeout = time.Second * 120 +const upgradePollTimeout = time.Second * 360 // QuayRegistryReconciler reconciles a QuayRegistry object type QuayRegistryReconciler struct { @@ -217,6 +217,11 @@ func (r *QuayRegistryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error return upgradeDeployment.Status.ReadyReplicas > 0, nil }) + + if err != nil { + log.Error(err, "Quay upgrade deployment never reached ready phase") + // TODO(alecmerdler): Update `status` block with failure condition. + } }(updatedQuay.DeepCopy()) } diff --git a/deploy/manifests/quay-operator/0.0.1/quay-operator.clusterserviceversion.yaml b/deploy/manifests/quay-operator/0.0.1/quay-operator.clusterserviceversion.yaml index 7171c9de7..3fc73f728 100644 --- a/deploy/manifests/quay-operator/0.0.1/quay-operator.clusterserviceversion.yaml +++ b/deploy/manifests/quay-operator/0.0.1/quay-operator.clusterserviceversion.yaml @@ -18,6 +18,7 @@ metadata: "name": "example-registry" }, "spec": { + "desiredVersion": "v3.4.0", "configBundleSecret": "example-registry-config-bundle", "components": [ {"kind": "clair", "managed": true}, @@ -25,7 +26,8 @@ metadata: {"kind": "objectstorage", "managed": true}, {"kind": "redis", "managed": true}, {"kind": "horizontalpodautoscaler", "managed": true}, - {"kind": "route", "managed": true} + {"kind": "route", "managed": true}, + {"kind": "mirror", "managed": true} ] } } @@ -62,8 +64,7 @@ spec: displayName: Desired Version description: Declares the version of Quay that should deployed and managed. Defaults to latest version. x-descriptors: - - 'urn:alm:descriptor:com.tectonic.ui:select:padme' - - 'urn:alm:descriptor:com.tectonic.ui:select:qui-gon' + - 'urn:alm:descriptor:com.tectonic.ui:select:v3.4.0' - 'urn:alm:descriptor:com.tectonic.ui:advanced' - path: components displayName: Components @@ -116,6 +117,9 @@ spec: valueFrom: fieldRef: fieldPath: metadata.annotations['olm.targetNamespaces'] + # NOTE: This controls the default value for `desiredVersion` if left blank. + - name: DEFAULT_STREAM + value: downstream image: quay.io/projectquay/quay-operator@sha256:4f88b7231dcac284893e7c6371ee631fccf592b553d0df76e624068bc9bb7553 name: quay-operator volumeMounts: diff --git a/kustomize/components/clair/clair.deployment.yaml b/kustomize/components/clair/clair.deployment.yaml index 597cfd0ce..526871f5f 100644 --- a/kustomize/components/clair/clair.deployment.yaml +++ b/kustomize/components/clair/clair.deployment.yaml @@ -35,7 +35,10 @@ spec: name: config - mountPath: /var/run/certs name: certs - # TODO(alecmerdler): Define `readinessProbe` which waits until indexer/matcher services are ready. + readinessProbe: + httpGet: + path: /indexer/api/v1/index_state + port: 8080 restartPolicy: Always volumes: - name: config diff --git a/kustomize/components/clair/postgres.deployment.yaml b/kustomize/components/clair/postgres.deployment.yaml index 196b691db..fbfe49732 100644 --- a/kustomize/components/clair/postgres.deployment.yaml +++ b/kustomize/components/clair/postgres.deployment.yaml @@ -18,22 +18,24 @@ spec: - name: postgres-data persistentVolumeClaim: claimName: clair-postgres + securityContext: + fsGroup: 0 containers: - name: postgres - image: postgres:latest + image: centos/postgresql-10-centos7 imagePullPolicy: "IfNotPresent" ports: - containerPort: 5432 protocol: TCP env: - - name: POSTGRES_USER + - name: POSTGRESQL_USER value: postgres - - name: POSTGRES_DB - value: clair - - name: POSTGRES_PASSWORD + - name: POSTGRESQL_DATABASE + value: postgres + - name: POSTGRESQL_PASSWORD + value: postgres + - name: POSTGRESQL_ADMIN_PASSWORD value: postgres - - name: PGDATA - value: /var/lib/postgresql/data/pgdata volumeMounts: - name: postgres-data - mountPath: /var/lib/postgresql/data + mountPath: /var/lib/pgsql/data diff --git a/kustomize/components/postgres/create-extensions.sh b/kustomize/components/postgres/create-extensions.sh new file mode 100644 index 000000000..0413b1896 --- /dev/null +++ b/kustomize/components/postgres/create-extensions.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "attempting to create pg_trgm extension" +psql -d $POSTGRESQL_DATABASE -h $POSTGRESQL_DATABASE -U postgres -c 'CREATE EXTENSION pg_trgm;' || true +echo "succesfully created pg_trgm extension" +break diff --git a/kustomize/components/postgres/init.job.yaml b/kustomize/components/postgres/init.job.yaml new file mode 100644 index 000000000..df868f2aa --- /dev/null +++ b/kustomize/components/postgres/init.job.yaml @@ -0,0 +1,35 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: quay-postgres-init +spec: + template: + metadata: + name: quay-postgres-init + spec: + restartPolicy: Never + securityContext: + fsGroup: 0 + volumes: + - name: postgres-bootstrap + secret: + secretName: postgres-bootstrap + defaultMode: 0777 + items: + - key: create-extensions.sh + path: create-extensions.sh + - key: restore.sh + path: restore.sh + containers: + - name: quay-postgres-init + image: centos/postgresql-10-centos7 + command: + - /opt/app-root/src/docker-entrypoint-initdb.d/create-extensions.sh + env: + - name: POSTGRESQL_DATABASE + value: $(POSTGRES_DEPLOYMENT_NAME) + - name: PGPASSWORD + value: postgres + volumeMounts: + - name: postgres-bootstrap + mountPath: /opt/app-root/src/docker-entrypoint-initdb.d diff --git a/kustomize/components/postgres/kustomization.yaml b/kustomize/components/postgres/kustomization.yaml index b20baf437..4bd967b75 100644 --- a/kustomize/components/postgres/kustomization.yaml +++ b/kustomize/components/postgres/kustomization.yaml @@ -5,14 +5,14 @@ resources: - ./postgres.persistentvolumeclaim.yaml - ./postgres.deployment.yaml - ./postgres.service.yaml + - ./init.job.yaml generatorOptions: disableNameSuffixHash: true secretGenerator: - name: postgres-bootstrap - literals: - - create-extensions.sql=CREATE EXTENSION pg_trgm; files: - - restore.sh=./restore.sh + - ./restore.sh + - ./create-extensions.sh vars: - name: POSTGRES_DEPLOYMENT_NAME objref: diff --git a/kustomize/components/postgres/migrate.job.yaml b/kustomize/components/postgres/migrate.job.yaml deleted file mode 100644 index dfedcc43d..000000000 --- a/kustomize/components/postgres/migrate.job.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: quay-postgres-migrate -spec: - template: - metadata: - name: quay-postgres-migrate - spec: - restartPolicy: Never - volumes: - - name: postgres-data - persistentVolumeClaim: - # FIXME(alecmerdler): Change PVC name - claimName: quay-database - containers: - - name: quay-postgres-migrate - image: postgres:latest - env: - - name: DB_URI - value: postgresql://old-quay-database:old-quay-database@old-quay-postgresql/old-quay-database - command: - - "pg_dump" - - "$(DB_URI)" - - "--format" - - "c" - - "--file" - - "/var/lib/postgresql/data/dump.sql" - volumeMounts: - - name: postgres-data - mountPath: /var/lib/postgresql/data diff --git a/kustomize/components/postgres/postgres.deployment.yaml b/kustomize/components/postgres/postgres.deployment.yaml index f6abadd28..f2029846d 100644 --- a/kustomize/components/postgres/postgres.deployment.yaml +++ b/kustomize/components/postgres/postgres.deployment.yaml @@ -18,36 +18,29 @@ spec: - name: postgres-data persistentVolumeClaim: claimName: quay-database - - name: postgres-bootstrap - secret: - secretName: postgres-bootstrap - items: - - key: create-extensions.sql - path: create-extensions.sql - - key: restore.sh - path: restore.sh + securityContext: + fsGroup: 0 containers: - name: postgres - image: postgres:latest + image: centos/postgresql-10-centos7 imagePullPolicy: IfNotPresent - args: [ - "-c", "shared_buffers=256MB", - "-c", "max_connections=2000", - ] ports: - containerPort: 5432 protocol: TCP + # TODO(alecmerdler): Readiness/liveliness probes which execute `psql` command to check if database is created. env: - - name: POSTGRES_USER + - name: POSTGRESQL_USER value: $(POSTGRES_DEPLOYMENT_NAME) - - name: POSTGRES_DB + - name: POSTGRESQL_DATABASE value: $(POSTGRES_DEPLOYMENT_NAME) - - name: POSTGRES_PASSWORD + - name: POSTGRESQL_ADMIN_PASSWORD value: postgres - - name: PGDATA - value: /var/lib/postgresql/data/pgdata + - name: POSTGRESQL_PASSWORD + value: postgres + - name: POSTGRESQL_SHARED_BUFFERS + value: 256MB + - name: POSTGRESQL_MAX_CONNECTIONS + value: "2000" volumeMounts: - name: postgres-data - mountPath: /var/lib/postgresql/data - - name: postgres-bootstrap - mountPath: /docker-entrypoint-initdb.d + mountPath: /var/lib/pgsql/data diff --git a/kustomize/components/postgres/restore.sh b/kustomize/components/postgres/restore.sh index 3634e6224..11388182f 100644 --- a/kustomize/components/postgres/restore.sh +++ b/kustomize/components/postgres/restore.sh @@ -1,6 +1,8 @@ #!/bin/sh -# NOTE: The Postgres container will not run this init script if `$PGDATA` is populated, so no need to have extra checks here to prevent re-restoring. +# FIXME(alecmerdler): Ensure this only runs once... + +# FIXME(alecmerdler): This file path is wrong for SCL Postgres... RESTORE_FILE=/var/lib/postgresql/data/dump.sql if [ -f "$RESTORE_FILE" ]; then diff --git a/kustomize/overlays/downstream/v3.4.0/kustomization.yaml b/kustomize/overlays/downstream/v3.4.0/kustomization.yaml new file mode 100644 index 000000000..0ddcd7bba --- /dev/null +++ b/kustomize/overlays/downstream/v3.4.0/kustomization.yaml @@ -0,0 +1,19 @@ +# Overlay variant for Project Quay "padme" release. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +commonAnnotations: + quay-version: v3.4.0 +bases: + - ../../../tmp +images: + - name: quay.io/projectquay/quay + newName: quay.io/quay/quay + newTag: v3.4.0-osbs + - name: quay.io/projectquay/clair + newName: quay.io/quay/clair + newTag: v3.4.0-osbs + - name: redis + newName: registry.access.redhat.com/rhscl/redis-32-rhel7 + - name: centos/postgresql-10-centos7 + newName: registry.access.redhat.com/rhscl/postgresql-10-rhel7 + newTag: latest diff --git a/kustomize/overlays/upstream/qui-gon/upgrade/kustomization.yaml b/kustomize/overlays/downstream/v3.4.0/upgrade/kustomization.yaml similarity index 51% rename from kustomize/overlays/upstream/qui-gon/upgrade/kustomization.yaml rename to kustomize/overlays/downstream/v3.4.0/upgrade/kustomization.yaml index 1f1e7e89b..2b527f86b 100644 --- a/kustomize/overlays/upstream/qui-gon/upgrade/kustomization.yaml +++ b/kustomize/overlays/downstream/v3.4.0/upgrade/kustomization.yaml @@ -1,8 +1,8 @@ -# Overlay variant for upgrading to Project Quay "qui-gon" release. +# Overlay variant for upgrading to Red Hat Quay "v3.4.0" release. apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization commonAnnotations: - quay-version: qui-gon + quay-version: v3.4.0 bases: - ../../../../tmp patchesStrategicMerge: @@ -11,6 +11,13 @@ patchesStrategicMerge: - ./upgrade.deployment.patch.yaml images: - name: quay.io/projectquay/quay - newTag: qui-gon + newName: quay.io/quay/quay + newTag: v3.4.0-osbs - name: quay.io/projectquay/clair - newTag: qui-gon + newName: quay.io/quay/clair + newTag: v3.4.0-osbs + - name: redis + newName: registry.access.redhat.com/rhscl/redis-32-rhel7 + - name: centos/postgresql-10-centos7 + newName: registry.access.redhat.com/rhscl/postgresql-10-rhel7 + newTag: latest diff --git a/kustomize/overlays/upstream/qui-gon/upgrade/quay.deployment.patch.yaml b/kustomize/overlays/downstream/v3.4.0/upgrade/quay.deployment.patch.yaml similarity index 79% rename from kustomize/overlays/upstream/qui-gon/upgrade/quay.deployment.patch.yaml rename to kustomize/overlays/downstream/v3.4.0/upgrade/quay.deployment.patch.yaml index a39ce878e..3b630d6b3 100644 --- a/kustomize/overlays/upstream/qui-gon/upgrade/quay.deployment.patch.yaml +++ b/kustomize/overlays/downstream/v3.4.0/upgrade/quay.deployment.patch.yaml @@ -3,6 +3,6 @@ kind: Deployment metadata: name: quay-app annotations: - quay-upgrade: qui-gon + quay-upgrade: v3.4.0 spec: replicas: 0 diff --git a/kustomize/overlays/upstream/qui-gon/upgrade/upgrade.deployment.patch.yaml b/kustomize/overlays/downstream/v3.4.0/upgrade/upgrade.deployment.patch.yaml similarity index 80% rename from kustomize/overlays/upstream/qui-gon/upgrade/upgrade.deployment.patch.yaml rename to kustomize/overlays/downstream/v3.4.0/upgrade/upgrade.deployment.patch.yaml index fa36e003e..65d3548e4 100644 --- a/kustomize/overlays/upstream/qui-gon/upgrade/upgrade.deployment.patch.yaml +++ b/kustomize/overlays/downstream/v3.4.0/upgrade/upgrade.deployment.patch.yaml @@ -3,6 +3,6 @@ kind: Deployment metadata: name: quay-app-upgrade annotations: - quay-upgrade: qui-gon + quay-upgrade: v3.4.0 spec: replicas: 1 diff --git a/kustomize/overlays/upstream/qui-gon/kustomization.yaml b/kustomize/overlays/upstream/qui-gon/kustomization.yaml deleted file mode 100644 index b175ce70e..000000000 --- a/kustomize/overlays/upstream/qui-gon/kustomization.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# Overlay variant for Project Quay "qui-gon" release. -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -commonAnnotations: - quay-version: qui-gon -bases: - - ../../../tmp -images: - - name: quay.io/projectquay/quay - newTag: qui-gon - - name: quay.io/projectquay/clair - newTag: qui-gon diff --git a/pkg/kustomize/kustomize.go b/pkg/kustomize/kustomize.go index b50da1266..fc4e3e374 100644 --- a/pkg/kustomize/kustomize.go +++ b/pkg/kustomize/kustomize.go @@ -13,6 +13,7 @@ import ( route "github.com/openshift/api/route/v1" apps "k8s.io/api/apps/v1" autoscaling "k8s.io/api/autoscaling/v2beta2" + batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" rbac "k8s.io/api/rbac/v1beta1" "k8s.io/apimachinery/pkg/api/meta" @@ -47,11 +48,11 @@ func appDir() string { } func overlayDir(desiredVersion v1.QuayVersion) string { - return filepath.Join(kustomizeDir(), "overlays", "upstream", string(desiredVersion)) + return filepath.Join(kustomizeDir(), "overlays", string(desiredVersion.Stream()), string(desiredVersion)) } func upgradeOverlayDir(desiredVersion v1.QuayVersion) string { - return filepath.Join(kustomizeDir(), "overlays", "upstream", string(desiredVersion), "upgrade") + return filepath.Join(kustomizeDir(), "overlays", string(desiredVersion.Stream()), string(desiredVersion), "upgrade") } func check(err error) { @@ -97,6 +98,8 @@ func ModelFor(gvk schema.GroupVersionKind) k8sruntime.Object { return &objectbucket.ObjectBucketClaim{} case schema.GroupVersionKind{Group: "autoscaling", Version: "v2beta2", Kind: "HorizontalPodAutoscaler"}.String(): return &autoscaling.HorizontalPodAutoscaler{} + case schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "Job"}.String(): + return &batchv1.Job{} default: panic(fmt.Sprintf("Missing model for GVK %s", gvk.String())) } diff --git a/pkg/kustomize/kustomize_test.go b/pkg/kustomize/kustomize_test.go index 0e6b95cbc..cac504eab 100644 --- a/pkg/kustomize/kustomize_test.go +++ b/pkg/kustomize/kustomize_test.go @@ -8,6 +8,7 @@ import ( objectbucket "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" + batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" rbac "k8s.io/api/rbac/v1beta1" "k8s.io/apimachinery/pkg/api/meta" @@ -220,6 +221,7 @@ var quayComponents = map[string][]runtime.Object{ &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "quay-database"}}, &corev1.PersistentVolumeClaim{ObjectMeta: metav1.ObjectMeta{Name: "quay-database"}}, &corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: "quay-database"}}, + &batchv1.Job{ObjectMeta: metav1.ObjectMeta{Name: "quay-database-init"}}, }, "redis": { &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "quay-redis"}}, @@ -332,7 +334,7 @@ var inflateTests = []struct { }, }, Spec: v1.QuayRegistrySpec{ - DesiredVersion: v1.QuayVersionQuiGon, + DesiredVersion: v1.QuayVersionVader, Components: []v1.Component{ {Kind: "postgres", Managed: true}, {Kind: "clair", Managed: true}, diff --git a/pkg/kustomize/secrets.go b/pkg/kustomize/secrets.go index 070d46db8..17f59ab45 100644 --- a/pkg/kustomize/secrets.go +++ b/pkg/kustomize/secrets.go @@ -298,7 +298,7 @@ func componentConfigFilesFor(component string, quay *v1.QuayRegistry) (map[strin // clairConfigFor returns a Clair v4 config with the correct values. func clairConfigFor(quay *v1.QuayRegistry) []byte { host := strings.Join([]string{quay.GetName(), "clair-postgres"}, "-") - dbname := "clair" + dbname := "postgres" user := "postgres" // FIXME(alecmerdler): Make this more secure... password := "postgres"