From 4e025110040afc1c3ea45780f6399bd5278a98ab Mon Sep 17 00:00:00 2001 From: Dmitri Kozlov Date: Mon, 27 Jun 2022 00:10:16 -0400 Subject: [PATCH 1/3] Add CRD file --- crd.yaml | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 crd.yaml diff --git a/crd.yaml b/crd.yaml new file mode 100644 index 0000000000..cdbbe263d5 --- /dev/null +++ b/crd.yaml @@ -0,0 +1,124 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + # name must match the spec fields below, and be in the form: . + name: tenants.mobius.digitaled.com +spec: + # group name to use for REST API: /apis// + group: mobius.digitaled.com + # list of versions supported by this CustomResourceDefinition + versions: + - name: v1beta1 + # Each version can be enabled/disabled by Served flag. + served: true + # One and only one version must be marked as the storage version. + storage: true + schema: + openAPIV3Schema: + type: object + required: + - spec + properties: + spec: + type: object + required: + - tenantId + - hostname + - appVersion + - uuid + - conn + - pl + properties: + replicas: + type: integer + default: 1 + # As stated below, this may not make any sense in our multi-tenant world, but I'd rather + # put the infrastructure in place in case we have to go down this road later. If we don't, + # then this will effectivley just be ignored. + description: "How many replicas of the current tenant are to be deployed" + tenantId: + type: string + pattern: '^[a-z][a-z0-9-]{1,24}[a-z0-9]$' + description: "The tenant identifier" + hostname: + type: string + # This is actually a really difficult value to apply a regex to reliably + description: "The tenant hostname, usually .mobius.cloud" + appVersion: + type: string + pattern: '^[a-f0-9]+$|^20(19|2[0-9]).[0-9]+(.[0-9]+)?-((dev|rel|rc[0-9]+)-)?([a-f0-9]+)$' + description: "The tenant Möbius application version" + uuid: + type: string + # uuid v4 + pattern: '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89AB][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$' + format: uuid + description: "The tenant's UUID" + conn: + type: object + x-kubernetes-preserve-unknown-fields: true # This prevents k8s from pruning away any unknown JSON + description: "The tenant's database connection settings" + pl: + type: object + x-kubernetes-preserve-unknown-fields: true + description: "The tenant's private labelling settings" + props: + type: object + x-kubernetes-preserve-unknown-fields: true + description: "The tenant's system property settings" + status: + type: object + x-kubernetes-preserve-unknown-fields: true + properties: + replicas: + type: integer + labelSelector: + type: string + subresources: + # status enables the status subresource. + status: {} + # scale enables the scale subresource. They may not make any sense in our MT world, but + # I'd rather have it available now in case there are ways we can "scale" a tenant. + scale: + # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas. + specReplicasPath: .spec.replicas + # statusReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Replicas. + statusReplicasPath: .status.replicas + # labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector. + labelSelectorPath: .status.labelSelector + additionalPrinterColumns: + - name: ID + type: string + description: "The tenant ID" + jsonPath: .spec.tenantId + - name: Hostname + type: string + description: "The tenant hostname" + jsonPath: .spec.hostname + - name: Release + type: string + description: "The tenant Möbius application version" + jsonPath: .spec.appVersion + - name: UUID + type: string + description: "The tenant Möbius UUID" + jsonPath: .spec.uuid + - name: Status + type: string + description: "The tenant provisioning status" + jsonPath: .status.prov_status + - name: Age + type: date + jsonPath: .metadata.creationTimestamp + # either Namespaced or Cluster + scope: Namespaced + names: + # plural name to be used in the URL: /apis/// + plural: tenants + # singular name to be used as an alias on the CLI and for display + singular: tenant + # kind is normally the CamelCased singular type. Your resource manifests use this. + kind: Tenant + # shortNames allow shorter string to match your resource on the CLI + shortNames: + - tnnt From 2506fb15bb940525dd268f6fb68272094e90fc22 Mon Sep 17 00:00:00 2001 From: Dmitri Kozlov Date: Mon, 27 Jun 2022 00:48:36 -0400 Subject: [PATCH 2/3] Lint the CRD file --- crd.yaml | 173 +++++++++++++++++++++++++------------------------------ 1 file changed, 80 insertions(+), 93 deletions(-) diff --git a/crd.yaml b/crd.yaml index cdbbe263d5..fe552fa56a 100644 --- a/crd.yaml +++ b/crd.yaml @@ -1,124 +1,111 @@ +--- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - # name must match the spec fields below, and be in the form: . name: tenants.mobius.digitaled.com spec: - # group name to use for REST API: /apis// group: mobius.digitaled.com - # list of versions supported by this CustomResourceDefinition + names: + kind: Tenant + plural: tenants + shortNames: + - tnnt + singular: tenant + scope: Namespaced versions: - - name: v1beta1 - # Each version can be enabled/disabled by Served flag. - served: true - # One and only one version must be marked as the storage version. - storage: true + - + additionalPrinterColumns: + - + description: "The tenant ID" + jsonPath: .spec.tenantId + name: ID + type: string + - + description: "The tenant hostname" + jsonPath: .spec.hostname + name: Hostname + type: string + - + description: "The tenant Möbius application version" + jsonPath: .spec.appVersion + name: Release + type: string + - + description: "The tenant Möbius UUID" + jsonPath: .spec.uuid + name: UUID + type: string + - + description: "The tenant provisioning status" + jsonPath: .status.prov_status + name: Status + type: string + - + jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 schema: openAPIV3Schema: - type: object - required: - - spec properties: spec: - type: object - required: - - tenantId - - hostname - - appVersion - - uuid - - conn - - pl properties: - replicas: - type: integer - default: 1 - # As stated below, this may not make any sense in our multi-tenant world, but I'd rather - # put the infrastructure in place in case we have to go down this road later. If we don't, - # then this will effectivley just be ignored. - description: "How many replicas of the current tenant are to be deployed" - tenantId: - type: string - pattern: '^[a-z][a-z0-9-]{1,24}[a-z0-9]$' - description: "The tenant identifier" - hostname: - type: string - # This is actually a really difficult value to apply a regex to reliably - description: "The tenant hostname, usually .mobius.cloud" appVersion: - type: string - pattern: '^[a-f0-9]+$|^20(19|2[0-9]).[0-9]+(.[0-9]+)?-((dev|rel|rc[0-9]+)-)?([a-f0-9]+)$' description: "The tenant Möbius application version" - uuid: + pattern: "^[a-f0-9]+$|^20(19|2[0-9]).[0-9]+(.[0-9]+)?-((dev|rel|rc[0-9]+)-)?([a-f0-9]+)$" type: string - # uuid v4 - pattern: '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89AB][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$' - format: uuid - description: "The tenant's UUID" conn: - type: object - x-kubernetes-preserve-unknown-fields: true # This prevents k8s from pruning away any unknown JSON description: "The tenant's database connection settings" - pl: type: object x-kubernetes-preserve-unknown-fields: true + hostname: + description: "The tenant hostname, usually .mobius.cloud" + type: string + pl: description: "The tenant's private labelling settings" - props: type: object x-kubernetes-preserve-unknown-fields: true + props: description: "The tenant's system property settings" - status: - type: object - x-kubernetes-preserve-unknown-fields: true - properties: + type: object + x-kubernetes-preserve-unknown-fields: true replicas: + default: 1 + description: "How many replicas of the current tenant are to be deployed" type: integer + tenantId: + description: "The tenant identifier" + pattern: "^[a-z][a-z0-9-]{1,24}[a-z0-9]$" + type: string + uuid: + description: "The tenant's UUID" + format: uuid + pattern: "^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89AB][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$" + type: string + required: + - tenantId + - hostname + - appVersion + - uuid + - conn + - pl + type: object + status: + properties: labelSelector: type: string + replicas: + type: integer + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + served: true + storage: true subresources: - # status enables the status subresource. - status: {} - # scale enables the scale subresource. They may not make any sense in our MT world, but - # I'd rather have it available now in case there are ways we can "scale" a tenant. scale: - # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas. + labelSelectorPath: .status.labelSelector specReplicasPath: .spec.replicas - # statusReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Replicas. statusReplicasPath: .status.replicas - # labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector. - labelSelectorPath: .status.labelSelector - additionalPrinterColumns: - - name: ID - type: string - description: "The tenant ID" - jsonPath: .spec.tenantId - - name: Hostname - type: string - description: "The tenant hostname" - jsonPath: .spec.hostname - - name: Release - type: string - description: "The tenant Möbius application version" - jsonPath: .spec.appVersion - - name: UUID - type: string - description: "The tenant Möbius UUID" - jsonPath: .spec.uuid - - name: Status - type: string - description: "The tenant provisioning status" - jsonPath: .status.prov_status - - name: Age - type: date - jsonPath: .metadata.creationTimestamp - # either Namespaced or Cluster - scope: Namespaced - names: - # plural name to be used in the URL: /apis/// - plural: tenants - # singular name to be used as an alias on the CLI and for display - singular: tenant - # kind is normally the CamelCased singular type. Your resource manifests use this. - kind: Tenant - # shortNames allow shorter string to match your resource on the CLI - shortNames: - - tnnt + status: {} From 0a9a133582c4ec2cdcc48eb49c25a7a74d551a3c Mon Sep 17 00:00:00 2001 From: Dmitri Kozlov Date: Mon, 27 Jun 2022 09:49:35 -0400 Subject: [PATCH 3/3] Remove additionalPrinterColumns map --- crd.yaml | 149 ++++++++++++++++++++++++++----------------------------- 1 file changed, 69 insertions(+), 80 deletions(-) diff --git a/crd.yaml b/crd.yaml index fe552fa56a..73afca18d5 100644 --- a/crd.yaml +++ b/crd.yaml @@ -1,111 +1,100 @@ ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: + # name must match the spec fields below, and be in the form: . name: tenants.mobius.digitaled.com spec: + # group name to use for REST API: /apis// group: mobius.digitaled.com - names: - kind: Tenant - plural: tenants - shortNames: - - tnnt - singular: tenant - scope: Namespaced + # list of versions supported by this CustomResourceDefinition versions: - - - additionalPrinterColumns: - - - description: "The tenant ID" - jsonPath: .spec.tenantId - name: ID - type: string - - - description: "The tenant hostname" - jsonPath: .spec.hostname - name: Hostname - type: string - - - description: "The tenant Möbius application version" - jsonPath: .spec.appVersion - name: Release - type: string - - - description: "The tenant Möbius UUID" - jsonPath: .spec.uuid - name: UUID - type: string - - - description: "The tenant provisioning status" - jsonPath: .status.prov_status - name: Status - type: string - - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1beta1 + - name: v1beta1 + # Each version can be enabled/disabled by Served flag. + served: true + # One and only one version must be marked as the storage version. + storage: true schema: openAPIV3Schema: + type: object + required: + - spec properties: spec: + type: object + required: + - tenantId + - hostname + - appVersion + - uuid + - conn + - pl properties: + replicas: + type: integer + default: 1 + # As stated below, this may not make any sense in our multi-tenant world, but I'd rather + # put the infrastructure in place in case we have to go down this road later. If we don't, + # then this will effectivley just be ignored. + description: "How many replicas of the current tenant are to be deployed" + tenantId: + type: string + pattern: '^[a-z][a-z0-9-]{1,24}[a-z0-9]$' + description: "The tenant identifier" + hostname: + type: string + # This is actually a really difficult value to apply a regex to reliably + description: "The tenant hostname, usually .mobius.cloud" appVersion: + type: string + pattern: '^[a-f0-9]+$|^20(19|2[0-9]).[0-9]+(.[0-9]+)?-((dev|rel|rc[0-9]+)-)?([a-f0-9]+)$' description: "The tenant Möbius application version" - pattern: "^[a-f0-9]+$|^20(19|2[0-9]).[0-9]+(.[0-9]+)?-((dev|rel|rc[0-9]+)-)?([a-f0-9]+)$" + uuid: type: string + # uuid v4 + pattern: '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89AB][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$' + format: uuid + description: "The tenant's UUID" conn: - description: "The tenant's database connection settings" type: object - x-kubernetes-preserve-unknown-fields: true - hostname: - description: "The tenant hostname, usually .mobius.cloud" - type: string + x-kubernetes-preserve-unknown-fields: true # This prevents k8s from pruning away any unknown JSON + description: "The tenant's database connection settings" pl: - description: "The tenant's private labelling settings" type: object x-kubernetes-preserve-unknown-fields: true + description: "The tenant's private labelling settings" props: - description: "The tenant's system property settings" type: object x-kubernetes-preserve-unknown-fields: true - replicas: - default: 1 - description: "How many replicas of the current tenant are to be deployed" - type: integer - tenantId: - description: "The tenant identifier" - pattern: "^[a-z][a-z0-9-]{1,24}[a-z0-9]$" - type: string - uuid: - description: "The tenant's UUID" - format: uuid - pattern: "^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89AB][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$" - type: string - required: - - tenantId - - hostname - - appVersion - - uuid - - conn - - pl - type: object + description: "The tenant's system property settings" status: + type: object + x-kubernetes-preserve-unknown-fields: true properties: - labelSelector: - type: string replicas: type: integer - type: object - x-kubernetes-preserve-unknown-fields: true - required: - - spec - type: object - served: true - storage: true + labelSelector: + type: string subresources: + # status enables the status subresource. + status: {} + # scale enables the scale subresource. They may not make any sense in our MT world, but + # I'd rather have it available now in case there are ways we can "scale" a tenant. scale: - labelSelectorPath: .status.labelSelector + # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas. specReplicasPath: .spec.replicas + # statusReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Replicas. statusReplicasPath: .status.replicas - status: {} + # labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector. + labelSelectorPath: .status.labelSelector + # either Namespaced or Cluster + scope: Namespaced + names: + # plural name to be used in the URL: /apis/// + plural: tenants + # singular name to be used as an alias on the CLI and for display + singular: tenant + # kind is normally the CamelCased singular type. Your resource manifests use this. + kind: Tenant + # shortNames allow shorter string to match your resource on the CLI + shortNames: + - tnnt