diff --git a/apis/installer/v1alpha1/kubedb_catalog_types.go b/apis/installer/v1alpha1/kubedb_catalog_types.go index 60d2b477e..43c487c26 100644 --- a/apis/installer/v1alpha1/kubedb_catalog_types.go +++ b/apis/installer/v1alpha1/kubedb_catalog_types.go @@ -48,6 +48,7 @@ type KubedbCatalogSpec struct { Proxies RegistryProxies `json:"proxies"` FeatureGates map[string]bool `json:"featureGates"` Psp PSP `json:"psp"` + InstallCRDs bool `json:"installCRDs"` SkipDeprecated bool `json:"skipDeprecated"` } diff --git a/catalog/kubedb/fmt/main.go b/catalog/kubedb/fmt/main.go index 18efdf7a1..6e2a5ba3d 100644 --- a/catalog/kubedb/fmt/main.go +++ b/catalog/kubedb/fmt/main.go @@ -649,6 +649,10 @@ func main() { { // move new_templates to templates + err = os.Rename(filepath.Join(dir, "charts", "kubedb-catalog", "templates", "crds.yaml"), filepath.Join(dir, "charts", "kubedb-catalog", "new_templates", "crds.yaml")) + if err != nil { + panic(err) + } err = os.Rename(filepath.Join(dir, "charts", "kubedb-catalog", "templates", "_helpers.tpl"), filepath.Join(dir, "charts", "kubedb-catalog", "new_templates", "_helpers.tpl")) if err != nil { panic(err) diff --git a/charts/kubedb-catalog/README.md b/charts/kubedb-catalog/README.md index 951ec9cc8..7e39acca1 100644 --- a/charts/kubedb-catalog/README.md +++ b/charts/kubedb-catalog/README.md @@ -94,6 +94,7 @@ The following table lists the configurable parameters of the `kubedb-catalog` ch | psp.redis.privileged | | false | | psp.kafka.allowPrivilegeEscalation | | false | | psp.kafka.privileged | | false | +| installCRDs | Set true to install CRDs | false | | skipDeprecated | Set true to avoid deploying deprecated versions | true | diff --git a/charts/kubedb-catalog/ci/ci-values.yaml b/charts/kubedb-catalog/ci/ci-values.yaml index c9c6f08dd..6e0cc1ea4 100644 --- a/charts/kubedb-catalog/ci/ci-values.yaml +++ b/charts/kubedb-catalog/ci/ci-values.yaml @@ -1,2 +1,3 @@ # https://github.com/helm/charts/blob/master/test/README.md#providing-custom-test-values +installCRDs: true skipDeprecated: false diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_druidversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_druidversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_druidversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_druidversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_elasticsearchversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_elasticsearchversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_elasticsearchversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_elasticsearchversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_etcdversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_etcdversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_etcdversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_etcdversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_ferretdbversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_ferretdbversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_ferretdbversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_ferretdbversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_kafkaconnectorversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_kafkaconnectorversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_kafkaconnectorversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_kafkaconnectorversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_kafkaversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_kafkaversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_kafkaversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_kafkaversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_mariadbversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_mariadbversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_mariadbversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_mariadbversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_memcachedversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_memcachedversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_memcachedversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_memcachedversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_mongodbversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_mongodbversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_mongodbversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_mongodbversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_mysqlversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_mysqlversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_mysqlversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_mysqlversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_perconaxtradbversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_perconaxtradbversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_perconaxtradbversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_perconaxtradbversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_pgbouncerversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_pgbouncerversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_pgbouncerversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_pgbouncerversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_pgpoolversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_pgpoolversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_pgpoolversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_pgpoolversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_postgresversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_postgresversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_postgresversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_postgresversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_proxysqlversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_proxysqlversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_proxysqlversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_proxysqlversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_rabbitmqversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_rabbitmqversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_rabbitmqversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_rabbitmqversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_redisversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_redisversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_redisversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_redisversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_singlestoreversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_singlestoreversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_singlestoreversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_singlestoreversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_solrversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_solrversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_solrversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_solrversions.yaml diff --git a/charts/kubedb-catalog/crds/catalog.kubedb.com_zookeeperversions.yaml b/charts/kubedb-catalog/files/crds/catalog.kubedb.com_zookeeperversions.yaml similarity index 100% rename from charts/kubedb-catalog/crds/catalog.kubedb.com_zookeeperversions.yaml rename to charts/kubedb-catalog/files/crds/catalog.kubedb.com_zookeeperversions.yaml diff --git a/charts/kubedb-catalog/templates/crds.yaml b/charts/kubedb-catalog/templates/crds.yaml new file mode 100644 index 000000000..c9054ad3f --- /dev/null +++ b/charts/kubedb-catalog/templates/crds.yaml @@ -0,0 +1,33 @@ +{{ $featureGates := .Values.featureGates }} +{{- if .Values.global }} + {{ $featureGates = mergeOverwrite dict .Values.featureGates .Values.global.featureGates }} +{{- end }} + +{{- if .Values.installCRDs }} + +{{ $overrides := printf ` +metadata: + annotations: + "helm.sh/hook": pre-install,pre-upgrade,pre-rollback +` | fromYaml }} + +{{- range $db, $enabled := $featureGates }} +{{- if $enabled }} + +{{- $path := printf "files/crds/catalog.kubedb.com_%sversions.yaml" ($db | lower) }} +{{- $crd := $.Files.Get $path | fromYaml }} +{{- $crd = mergeOverwrite $crd $overrides }} +{{- $crd | toYaml }} +--- + +{{ if eq $db "Kafka" }} +{{ $path := "files/crds/catalog.kubedb.com_kafkaconnectorversions.yaml" }} +{{- $crd := $.Files.Get $path | fromYaml }} +{{- $crd = mergeOverwrite $crd $overrides }} +{{- $crd | toYaml }} +--- +{{ end }} + +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/kubedb-catalog/values.openapiv3_schema.yaml b/charts/kubedb-catalog/values.openapiv3_schema.yaml index 86bbead08..dcf4c5edc 100644 --- a/charts/kubedb-catalog/values.openapiv3_schema.yaml +++ b/charts/kubedb-catalog/values.openapiv3_schema.yaml @@ -5,6 +5,8 @@ properties: type: object fullnameOverride: type: string + installCRDs: + type: boolean nameOverride: type: string proxies: @@ -136,6 +138,7 @@ properties: type: boolean required: - featureGates +- installCRDs - psp - skipDeprecated type: object diff --git a/charts/kubedb-catalog/values.yaml b/charts/kubedb-catalog/values.yaml index a3ae3839a..3a254c552 100644 --- a/charts/kubedb-catalog/values.yaml +++ b/charts/kubedb-catalog/values.yaml @@ -76,5 +76,8 @@ psp: allowPrivilegeEscalation: false privileged: false +# Set true to install CRDs +installCRDs: false + # Set true to avoid deploying deprecated versions skipDeprecated: true diff --git a/charts/kubedb/values.openapiv3_schema.yaml b/charts/kubedb/values.openapiv3_schema.yaml index e967baf1c..d0938d7a7 100644 --- a/charts/kubedb/values.openapiv3_schema.yaml +++ b/charts/kubedb/values.openapiv3_schema.yaml @@ -1534,6 +1534,8 @@ properties: type: object fullnameOverride: type: string + installCRDs: + type: boolean nameOverride: type: string proxies: @@ -1666,6 +1668,7 @@ properties: required: - enabled - featureGates + - installCRDs - psp - skipDeprecated type: object diff --git a/hack/scripts/import-crds.sh b/hack/scripts/import-crds.sh index 1f2bb4304..a8dee7749 100755 --- a/hack/scripts/import-crds.sh +++ b/hack/scripts/import-crds.sh @@ -77,7 +77,7 @@ if [ "$update_kubedb_crds" = true ] && [ -d ${crd_dir} ]; then crd-importer \ --input=${crd_dir} \ - --out=./charts/kubedb-catalog/crds \ + --out=./charts/kubedb-catalog/files/crds \ --group=catalog.kubedb.com crd-importer \