From 79454f54927f9ee289bc372cdfe2f613db844b70 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Wed, 3 Jan 2024 08:51:26 +0100 Subject: [PATCH 1/2] Add a missing kind property to dbuser --- charts/db-operator/Chart.yaml | 2 +- charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/db-operator/Chart.yaml b/charts/db-operator/Chart.yaml index cab8a20..ada0b3a 100644 --- a/charts/db-operator/Chart.yaml +++ b/charts/db-operator/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 type: application name: db-operator -version: 1.16.1 +version: 1.16.2 # --------------------------------------------------------------------------------- # -- All supported k8s versions are in the test: # -- https://github.com/db-operator/charts/blob/main/.github/workflows/test.yaml diff --git a/charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml b/charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml index 74e0966..61860bf 100644 --- a/charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml +++ b/charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml @@ -51,6 +51,7 @@ spec: apiVersion: description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string + kind: description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: From 459e53f22e1db668ca177231468b847d84b2d401 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Wed, 3 Jan 2024 10:06:32 +0100 Subject: [PATCH 2/2] Try generating CRDs with a script --- .github/workflows/test.yaml | 6 +- charts/db-operator/Chart.yaml | 2 +- charts/db-operator/scripts/crd.tmpl | 34 ++ charts/db-operator/scripts/gen_crds | 32 ++ .../templates/crds/kinda.rocks_databases.yaml | 542 ------------------ .../crds/kinda.rocks_dbinstances.yaml | 410 ------------- .../templates/crds/kinda.rocks_dbuser.yaml | 119 ---- 7 files changed, 71 insertions(+), 1074 deletions(-) create mode 100644 charts/db-operator/scripts/crd.tmpl create mode 100755 charts/db-operator/scripts/gen_crds delete mode 100644 charts/db-operator/templates/crds/kinda.rocks_databases.yaml delete mode 100644 charts/db-operator/templates/crds/kinda.rocks_dbinstances.yaml delete mode 100644 charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b373927..60c4740 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -40,7 +40,9 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - + - uses: actions/setup-go@v4 + - run: go install github.com/google/yamlfmt/cmd/yamlfmt@latest + - run: cd charts/db-operator && ./scripts/gen_crds - uses: actions/setup-python@v3 with: python-version: 3.7 @@ -56,7 +58,7 @@ jobs: - name: Run chart-testing (list-changed) id: list-changed run: | - changed=$(ct list-changed --chart-dirs helm --target-branch ${{ github.event.repository.default_branch }}) + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) if [[ -n "$changed" ]]; then echo "changed=true" >> "$GITHUB_OUTPUT" fi diff --git a/charts/db-operator/Chart.yaml b/charts/db-operator/Chart.yaml index ada0b3a..833c7b2 100644 --- a/charts/db-operator/Chart.yaml +++ b/charts/db-operator/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 type: application name: db-operator -version: 1.16.2 +version: 1.17.0 # --------------------------------------------------------------------------------- # -- All supported k8s versions are in the test: # -- https://github.com/db-operator/charts/blob/main/.github/workflows/test.yaml diff --git a/charts/db-operator/scripts/crd.tmpl b/charts/db-operator/scripts/crd.tmpl new file mode 100644 index 0000000..43cc029 --- /dev/null +++ b/charts/db-operator/scripts/crd.tmpl @@ -0,0 +1,34 @@ +{{- if .Values.crds.install }} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: ${CRD_CONTROLLER_GEN_VERSION} + {{- if .Values.webhook.certificate.create }} + cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.name}} + {{ else }} + cert-manager.io/inject-ca-from-secret: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.secretName}} + {{- end }} + {{- if .Values.crds.keep }} + helm.sh/resource-policy: keep + {{- end }} + {{- with .Values.crds.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + name: ${CRD_NAME} +spec: + {{- if .Values.webhook.enabled }} + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: {{ .Release.Namespace }} + name: {{ include "webhook.name" . }} + path: /convert + conversionReviewVersions: +${CRD_CONVERSION_VERSIONS} + {{- end }} +${CRD_SPEC} +{{- end }} diff --git a/charts/db-operator/scripts/gen_crds b/charts/db-operator/scripts/gen_crds new file mode 100755 index 0000000..1afbf1e --- /dev/null +++ b/charts/db-operator/scripts/gen_crds @@ -0,0 +1,32 @@ +#!/bin/env bash + +# Get the current db-operator version +VERSION=$(yq .appVersion Chart.yaml) +echo $VERSION + +CURRENT_DIR=${PWD} +CRD_DIR="${PWD}/templates/crds" +mkdir "${CRD_DIR}" + +# Prepare the db-operator repo +cd /tmp +git clone git@github.com:db-operator/db-operator.git dbo +cd dbo +git checkout "v${VERSION}" + +# Generate CRDs +for crd in $(find config/crd/bases -type f); do + export CRD_SPEC=$(yq '.spec' $crd | yamlfmt - | sed -e 's/^/ /') + export CRD_NAME=$(yq '.metadata.name' $crd) + export CRD_CONTROLLER_GEN_VERSION=$(yq '.metadata.annotations."controller-gen.kubebuilder.io/version"' $crd) + CRD_PLURAL_NAME=$(yq '.spec.names.plural' $crd) + export CRD_CONVERSION_VERSIONS=$(yq '.spec.conversion.webhook.conversionReviewVersions' \ + ./config/crd/patches/webhook_in_$CRD_PLURAL_NAME.yaml | sed -e 's/^/ /') + WEBHOOK_FILE_NAME="webhook_in_${CRD_PLURAL_NAME}.yaml" + envsubst < $CURRENT_DIR/scripts/crd.tmpl > $CRD_DIR/$CRD_NAME.yaml +done + +# Cleanup +rm -rf /tmp/dbo + + diff --git a/charts/db-operator/templates/crds/kinda.rocks_databases.yaml b/charts/db-operator/templates/crds/kinda.rocks_databases.yaml deleted file mode 100644 index df08c2e..0000000 --- a/charts/db-operator/templates/crds/kinda.rocks_databases.yaml +++ /dev/null @@ -1,542 +0,0 @@ -{{- if .Values.crds.install }} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.1 - {{- if .Values.webhook.certificate.create }} - cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.name}} - {{ else }} - cert-manager.io/inject-ca-from-secret: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.secretName}} - {{- end }} - {{- if .Values.crds.keep }} - helm.sh/resource-policy: keep - {{- end }} - {{- with .Values.crds.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - name: databases.kinda.rocks -spec: - {{- if .Values.webhook.enabled }} - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: {{ .Release.Namespace }} - name: {{ include "webhook.name" . }} - path: /convert - conversionReviewVersions: - - v1alpha1 - - v1beta1 - {{- end }} - group: kinda.rocks - names: - kind: Database - listKind: DatabaseList - plural: databases - shortNames: - - db - singular: database - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: current db phase - jsonPath: .status.phase - name: Phase - type: string - - description: current db status - jsonPath: .status.status - name: Status - type: boolean - - description: If database is protected to not get deleted. - jsonPath: .spec.deletionProtected - name: Protected - type: boolean - - description: instance reference - jsonPath: .spec.instance - name: DBInstance - type: string - - description: time since creation of resource - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: Database is the Schema for the databases API - properties: - apiVersion: - description: - "APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources" - type: string - kind: - description: - "Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" - type: string - metadata: - type: object - spec: - description: DatabaseSpec defines the desired state of Database - properties: - backup: - description: - DatabaseBackup defines the desired state of backup and - schedule - properties: - cron: - type: string - enable: - type: boolean - required: - - cron - - enable - type: object - cleanup: - type: boolean - connectionStringTemplate: - description: - 'ConnectionStringTemplate field can be used to pass a - custom template for generating a db connection string. These keywords - can be used: Protocol, DatabaseHost, DatabasePort, UserName, Password, - DatabaseName. Default template looks like this: "{{ .Protocol }}://{{ - .UserName }}:{{ .Password }}@{{ .DatabaseHost }}:{{ .DatabasePort - }}/{{ .DatabaseName }}"' - type: string - deletionProtected: - type: boolean - extensions: - items: - type: string - type: array - instance: - type: string - postgres: - description: - Postgres struct should be used to provide resource that - only applicable to postgres - properties: - dropPublicSchema: - description: - If set to true, the public schema will be dropped - after the database creation - type: boolean - schemas: - description: - Specify schemas to be created. The user created by - db-operator will have all access on them. - items: - type: string - type: array - type: object - secretName: - type: string - secretsTemplates: - additionalProperties: - type: string - type: object - required: - - backup - - deletionProtected - - instance - - secretName - type: object - status: - description: DatabaseStatus defines the observed state of Database - properties: - database: - type: string - instanceRef: - description: DbInstance is the Schema for the dbinstances API - properties: - apiVersion: - description: - "APIVersion defines the versioned schema of this - representation of an object. Servers should convert recognized - schemas to the latest internal value, and may reject unrecognized - values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources" - type: string - kind: - description: - "Kind is a string value representing the REST resource - this object represents. Servers may infer this from the endpoint - the client submits requests to. Cannot be updated. In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" - type: string - metadata: - type: object - spec: - description: DbInstanceSpec defines the desired state of DbInstance - properties: - adminSecretRef: - description: - NamespacedName is a fork of the kubernetes api - type of the same name. Sadly this is required because CRD - structs must have all fields json tagged and the kubernetes - type is not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - backup: - description: - DbInstanceBackup defines name of google bucket - to use for storing database dumps for backup when backup - is enabled - properties: - bucket: - type: string - required: - - bucket - type: object - engine: - description: - 'Important: Run "make generate" to regenerate - code after modifying this file' - type: string - generic: - description: - GenericInstance is used when instance type is - generic and describes necessary informations to use instance - generic instance can be any backend, it must be reachable - by described address and port - properties: - backupHost: - description: - BackupHost address will be used for dumping - database for backup Usually secondary address for primary-secondary - setup or cluster lb address If it's not defined, above - Host will be used as backup host address. - type: string - host: - type: string - port: - type: integer - publicIp: - type: string - required: - - host - - port - type: object - google: - description: - GoogleInstance is used when instance type is - Google Cloud SQL and describes necessary informations to - use google API to create sql instances - properties: - apiEndpoint: - type: string - clientSecretRef: - description: - NamespacedName is a fork of the kubernetes - api type of the same name. Sadly this is required because - CRD structs must have all fields json tagged and the - kubernetes type is not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - configmapRef: - description: - NamespacedName is a fork of the kubernetes - api type of the same name. Sadly this is required because - CRD structs must have all fields json tagged and the - kubernetes type is not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - instance: - type: string - required: - - configmapRef - - instance - type: object - monitoring: - description: DbInstanceMonitoring defines if exporter - properties: - enabled: - type: boolean - required: - - enabled - type: object - sslConnection: - description: - DbInstanceSSLConnection defines weather connection - from db-operator to instance has to be ssl or not - properties: - enabled: - type: boolean - skip-verify: - description: - SkipVerity use SSL connection, but don't - check against a CA - type: boolean - required: - - enabled - - skip-verify - type: object - required: - - adminSecretRef - - engine - type: object - status: - description: DbInstanceStatus defines the observed state of DbInstance - properties: - checksums: - additionalProperties: - type: string - type: object - info: - additionalProperties: - type: string - type: object - phase: - description: - 'Important: Run "make generate" to regenerate - code after modifying this file' - type: string - status: - type: boolean - required: - - phase - - status - type: object - type: object - monitorUserSecret: - type: string - phase: - description: - 'Important: Run "make generate" to regenerate code after - modifying this file Add custom validation using kubebuilder tags: - https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html' - type: string - proxyStatus: - description: - DatabaseProxyStatus defines whether proxy for database - is enabled or not if so, provide information - properties: - serviceName: - type: string - sqlPort: - format: int32 - type: integer - status: - type: boolean - required: - - serviceName - - sqlPort - - status - type: object - status: - type: boolean - user: - type: string - required: - - database - - instanceRef - - phase - - status - - user - type: object - type: object - served: true - storage: false - subresources: - status: {} - - additionalPrinterColumns: - - description: current db phase - jsonPath: .status.phase - name: Phase - type: string - - description: current db status - jsonPath: .status.status - name: Status - type: boolean - - description: If database is protected to not get deleted. - jsonPath: .spec.deletionProtected - name: Protected - type: boolean - - description: instance reference - jsonPath: .spec.instance - name: DBInstance - type: string - - description: time since creation of resource - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1beta1 - schema: - openAPIV3Schema: - description: Database is the Schema for the databases API - properties: - apiVersion: - description: - "APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources" - type: string - kind: - description: - "Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" - type: string - metadata: - type: object - spec: - description: DatabaseSpec defines the desired state of Database - properties: - backup: - description: - DatabaseBackup defines the desired state of backup and - schedule - properties: - cron: - type: string - enable: - type: boolean - required: - - cron - - enable - type: object - cleanup: - type: boolean - credentials: - description: - "Credentials should be used to setup everything relates - to k8s secrets and configmaps TODO(@allanger): Field .spec.secretName - should be moved here in the v1beta2 version" - properties: - templates: - description: - Templates to add custom entries to ConfigMaps and - Secrets - items: - description: - Tempaltes to add custom entries to comfigmaps and - secrets - properties: - name: - type: string - secret: - type: boolean - template: - type: string - required: - - name - - secret - - template - type: object - type: array - type: object - deletionProtected: - type: boolean - instance: - type: string - postgres: - description: - Postgres struct should be used to provide resource that - only applicable to postgres - properties: - dropPublicSchema: - description: - If set to true, the public schema will be dropped - after the database creation - type: boolean - extensions: - items: - type: string - type: array - schemas: - description: - Specify schemas to be created. The user created by - db-operator will have all access on them. - items: - type: string - type: array - template: - description: Let user create database from template - type: string - type: object - secretName: - type: string - secretsTemplates: - additionalProperties: - type: string - type: object - required: - - backup - - deletionProtected - - instance - - secretName - type: object - status: - description: DatabaseStatus defines the observed state of Database - properties: - database: - type: string - engine: - type: string - monitorUserSecret: - type: string - phase: - description: - 'Important: Run "make generate" to regenerate code after - modifying this file Add custom validation using kubebuilder tags: - https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html' - type: string - proxyStatus: - description: - DatabaseProxyStatus defines whether proxy for database - is enabled or not if so, provide information - properties: - serviceName: - type: string - sqlPort: - format: int32 - type: integer - status: - type: boolean - required: - - serviceName - - sqlPort - - status - type: object - status: - type: boolean - user: - type: string - required: - - database - - engine - - phase - - status - - user - type: object - type: object - served: true - storage: true - subresources: - status: {} -{{- end }} diff --git a/charts/db-operator/templates/crds/kinda.rocks_dbinstances.yaml b/charts/db-operator/templates/crds/kinda.rocks_dbinstances.yaml deleted file mode 100644 index f9f27a6..0000000 --- a/charts/db-operator/templates/crds/kinda.rocks_dbinstances.yaml +++ /dev/null @@ -1,410 +0,0 @@ -{{- if .Values.crds.install }} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.1 - {{- if .Values.webhook.certificate.create }} - cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.name}} - {{ else }} - cert-manager.io/inject-ca-from-secret: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.secretName}} - {{- end }} - {{- if .Values.crds.keep }} - helm.sh/resource-policy: keep - {{- end }} - {{- with .Values.crds.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - name: dbinstances.kinda.rocks -spec: - {{- if .Values.webhook.enabled }} - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: {{ .Release.Namespace }} - name: {{ include "webhook.name" . }} - path: /convert - conversionReviewVersions: - - v1alpha1 - - v1beta1 - {{- end }} - group: kinda.rocks - names: - kind: DbInstance - listKind: DbInstanceList - plural: dbinstances - shortNames: - - dbin - singular: dbinstance - scope: Cluster - versions: - - additionalPrinterColumns: - - description: current phase - jsonPath: .status.phase - name: Phase - type: string - - description: health status - jsonPath: .status.status - name: Status - type: string - name: v1alpha1 - schema: - openAPIV3Schema: - description: DbInstance is the Schema for the dbinstances API - properties: - apiVersion: - description: - "APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources" - type: string - kind: - description: - "Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" - type: string - metadata: - type: object - spec: - description: DbInstanceSpec defines the desired state of DbInstance - properties: - adminSecretRef: - description: - NamespacedName is a fork of the kubernetes api type of - the same name. Sadly this is required because CRD structs must have - all fields json tagged and the kubernetes type is not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - backup: - description: - DbInstanceBackup defines name of google bucket to use - for storing database dumps for backup when backup is enabled - properties: - bucket: - type: string - required: - - bucket - type: object - engine: - description: - 'Important: Run "make generate" to regenerate code after - modifying this file' - type: string - generic: - description: - GenericInstance is used when instance type is generic - and describes necessary informations to use instance generic instance - can be any backend, it must be reachable by described address and - port - properties: - backupHost: - description: - BackupHost address will be used for dumping database - for backup Usually secondary address for primary-secondary setup - or cluster lb address If it's not defined, above Host will be - used as backup host address. - type: string - host: - type: string - port: - type: integer - publicIp: - type: string - required: - - host - - port - type: object - google: - description: - GoogleInstance is used when instance type is Google Cloud - SQL and describes necessary informations to use google API to create - sql instances - properties: - apiEndpoint: - type: string - clientSecretRef: - description: - NamespacedName is a fork of the kubernetes api type - of the same name. Sadly this is required because CRD structs - must have all fields json tagged and the kubernetes type is - not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - configmapRef: - description: - NamespacedName is a fork of the kubernetes api type - of the same name. Sadly this is required because CRD structs - must have all fields json tagged and the kubernetes type is - not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - instance: - type: string - required: - - configmapRef - - instance - type: object - monitoring: - description: DbInstanceMonitoring defines if exporter - properties: - enabled: - type: boolean - required: - - enabled - type: object - sslConnection: - description: - DbInstanceSSLConnection defines weather connection from - db-operator to instance has to be ssl or not - properties: - enabled: - type: boolean - skip-verify: - description: - SkipVerity use SSL connection, but don't check against - a CA - type: boolean - required: - - enabled - - skip-verify - type: object - required: - - adminSecretRef - - engine - type: object - status: - description: DbInstanceStatus defines the observed state of DbInstance - properties: - checksums: - additionalProperties: - type: string - type: object - info: - additionalProperties: - type: string - type: object - phase: - description: - 'Important: Run "make generate" to regenerate code after - modifying this file' - type: string - status: - type: boolean - required: - - phase - - status - type: object - type: object - served: true - storage: false - subresources: - status: {} - - additionalPrinterColumns: - - description: current phase - jsonPath: .status.phase - name: Phase - type: string - - description: health status - jsonPath: .status.status - name: Status - type: string - name: v1beta1 - schema: - openAPIV3Schema: - description: DbInstance is the Schema for the dbinstances API - properties: - apiVersion: - description: - "APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources" - type: string - kind: - description: - "Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" - type: string - metadata: - type: object - spec: - description: DbInstanceSpec defines the desired state of DbInstance - properties: - adminSecretRef: - description: - NamespacedName is a fork of the kubernetes api type of - the same name. Sadly this is required because CRD structs must have - all fields json tagged and the kubernetes type is not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - backup: - description: - DbInstanceBackup defines name of google bucket to use - for storing database dumps for backup when backup is enabled - properties: - bucket: - type: string - required: - - bucket - type: object - engine: - description: - 'Important: Run "make generate" to regenerate code after - modifying this file' - type: string - generic: - description: - GenericInstance is used when instance type is generic - and describes necessary informations to use instance generic instance - can be any backend, it must be reachable by described address and - port - properties: - backupHost: - description: - BackupHost address will be used for dumping database - for backup Usually secondary address for primary-secondary setup - or cluster lb address If it's not defined, above Host will be - used as backup host address. - type: string - host: - type: string - port: - type: integer - publicIp: - type: string - required: - - host - - port - type: object - google: - description: - GoogleInstance is used when instance type is Google Cloud - SQL and describes necessary informations to use google API to create - sql instances - properties: - apiEndpoint: - type: string - clientSecretRef: - description: - NamespacedName is a fork of the kubernetes api type - of the same name. Sadly this is required because CRD structs - must have all fields json tagged and the kubernetes type is - not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - configmapRef: - description: - NamespacedName is a fork of the kubernetes api type - of the same name. Sadly this is required because CRD structs - must have all fields json tagged and the kubernetes type is - not tagged. - properties: - Name: - type: string - Namespace: - type: string - required: - - Name - - Namespace - type: object - instance: - type: string - required: - - configmapRef - - instance - type: object - monitoring: - description: DbInstanceMonitoring defines if exporter - properties: - enabled: - type: boolean - required: - - enabled - type: object - sslConnection: - description: - DbInstanceSSLConnection defines weather connection from - db-operator to instance has to be ssl or not - properties: - enabled: - type: boolean - skip-verify: - description: - SkipVerity use SSL connection, but don't check against - a CA - type: boolean - required: - - enabled - - skip-verify - type: object - required: - - adminSecretRef - - engine - type: object - status: - description: DbInstanceStatus defines the observed state of DbInstance - properties: - checksums: - additionalProperties: - type: string - type: object - info: - additionalProperties: - type: string - type: object - phase: - description: - 'Important: Run "make generate" to regenerate code after - modifying this file' - type: string - status: - type: boolean - required: - - phase - - status - type: object - type: object - served: true - storage: true - subresources: - status: {} -{{- end }} diff --git a/charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml b/charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml deleted file mode 100644 index 61860bf..0000000 --- a/charts/db-operator/templates/crds/kinda.rocks_dbuser.yaml +++ /dev/null @@ -1,119 +0,0 @@ -{{- if .Values.crds.install }} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.13.0 - {{- if .Values.webhook.certificate.create }} - cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.name}} - {{ else }} - cert-manager.io/inject-ca-from-secret: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.secretName}} - {{- end }} - {{- if .Values.crds.keep }} - helm.sh/resource-policy: keep - {{- end }} - {{- with .Values.crds.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - name: dbusers.kinda.rocks -spec: - group: kinda.rocks - names: - kind: DbUser - listKind: DbUserList - plural: dbusers - singular: dbuser - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: current dbuser status - jsonPath: .status.status - name: Status - type: boolean - - description: To which database user should have access - jsonPath: .spec.databaseRef - name: DatabaseName - type: string - - description: A type of access the user has - jsonPath: .spec.accessType - name: AccessType - type: string - - description: time since creation of resosĀ”urce - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1beta1 - schema: - openAPIV3Schema: - description: DbUser is the Schema for the dbusers API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: DbUserSpec defines the desired state of DbUser - properties: - accessType: - description: AccessType that should be given to a user Currently only readOnly and readWrite are supported by the operator - type: string - cleanup: - type: boolean - credentials: - description: 'Credentials should be used to setup everything relates to k8s secrets and configmaps TODO(@allanger): Field .spec.secretName should be moved here in the v1beta2 version' - properties: - templates: - description: Templates to add custom entries to ConfigMaps and Secrets - items: - description: Tempaltes to add custom entries to ConfigMaps and Secrets - properties: - name: - type: string - secret: - type: boolean - template: - type: string - required: - - name - - secret - - template - type: object - type: array - type: object - databaseRef: - description: DatabaseRef should contain a name of a Database to create a user there Database should be in the same namespace with the user - type: string - secretName: - description: SecretName name that should be used to save user's credentials - type: string - required: - - accessType - - databaseRef - - secretName - type: object - status: - description: DbUserStatus defines the observed state of DbUser - properties: - created: - description: It's required to let the operator update users - type: boolean - database: - type: string - status: - type: boolean - required: - - created - - database - - status - type: object - type: object - served: true - storage: true - subresources: - status: {} -{{- end }}