custom-resource-definition resource¶
Description¶
CustomResourceDefinitionResource manages a cluster-scoped custom API definition. It owns the complete desired specification, labels and annotations. Dependent instances can use dynamic.object after establishment and discovery complete. Establishment does not verify a conversion webhook or install an operator.
Deleting or replacing a CRD also deletes its instances. This resource does not migrate stored data, remove stored versions or force past finalizers.
Source: internal/api/apiextensions/v1/custom_resource_definition_rsrc.go:29
Example usage:
imports: {
kubernetes-apiextensions-v1: 'github.com/cloudboss/unobin-library-kubernetes//api/apiextensions/v1'
}
resources: {
example: kubernetes-apiextensions-v1.custom-resource-definition {
# Set input fields here.
}
}
Inputs¶
metadata
object
object({
name: string
labels: optional(map(string))
annotations: optional(map(string))
})
Metadata.name must equal spec.names.plural plus a dot plus spec.group.
spec
object
object({
group: string
names: object({
plural: string
singular: optional(string)
kind: string
list-kind: optional(string)
short-names: optional(list(string))
categories: optional(list(string))
})
scope: string
versions: list(
object({
name: string
served: boolean
storage: boolean
deprecated: optional(boolean)
deprecation-warning: optional(string)
schema: optional(map(opaque))
subresources: optional(
object({
status: optional(map(opaque))
scale: optional(
object({
spec-replicas-path: string
status-replicas-path: string
label-selector-path: optional(string)
})
)
})
)
additional-printer-columns: optional(
list(
object({
name: string
type: string
format: optional(string)
description: optional(string)
priority: optional(integer)
json-path: string
})
)
)
selectable-fields: optional(
list(
object({
json-path: string
})
)
)
})
)
conversion: optional(
object({
strategy: string
webhook: optional(
object({
conversion-review-versions: list(string)
client-config: object({
url: optional(string)
service: optional(
object({
namespace: string
name: string
path: optional(string)
port: optional(integer)
})
)
ca-bundle: optional(string)
})
})
)
})
)
preserve-unknown-fields: optional(boolean)
})
Spec defines the custom API. Version schemas are raw OpenAPI data and retain Kubernetes JSON keys inside their maps.
wait-for-established
optional(boolean)
WaitForEstablished defaults true and waits for establishment plus fresh discovery of every served version after create or update.
create-timeout
optional(string)
CreateTimeout bounds create HTTP requests and readiness polling; defaults to 5m.
update-timeout
optional(string)
UpdateTimeout bounds update HTTP requests and readiness polling; defaults to 5m.
delete-timeout
optional(string)
DeleteTimeout bounds UID-protected deletion and disappearance waiting; defaults to 5m.
Input Constraints¶
Metadata rules
metadata.namespace is forbidden for a cluster-scoped CRD.
Rule logic
- Require
!@core.has-key(input.metadata, 'namespace')
metadata.name must equal spec.names.plural plus dot plus spec.group.
Rule logic
- Require
input.metadata.name == input.spec.names.plural + '.' + input.spec.group
Requirement.
Rule logic
- Require
@core.length(input.metadata.name) >= 1
&& @core.length(input.metadata.name) <= 253
Spec rules
invalid spec.group.
Rule logic
- Require
@core.length(input.spec.group) >= 1
&& @core.is-match(input.spec.group, '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$')
&& @core.length(input.spec.group) <= 253
invalid spec.names.plural.
Rule logic
- Require
@core.length(input.spec.names.plural) >= 1
&& @core.is-match(input.spec.names.plural, '^[a-z]([-a-z0-9]*[a-z0-9])?$')
&& @core.length(input.spec.names.plural) <= 63
Requirement.
Rule logic
- Require
@core.length(input.spec.names.kind) >= 1
spec.scope must be Cluster or Namespaced.
Rule logic
- Require
input.spec.scope == 'Cluster'
|| input.spec.scope == 'Namespaced'
spec.versions must not be empty.
Rule logic
- Require
@core.length(input.spec.versions) >= 1
spec.versions names must be unique.
Rule logic
- Require
@core.is-unique([for item-25084 in input.spec.versions: item-25084.name])
spec.versions requires exactly one storage version.
Rule logic
- Require
@core.length([for item-25258 in input.spec.versions: true when (item-25258.storage == true)]) == 1
versions require served and storage.
Rule logic
- For each
input.spec.versions- Require
(@each.value.served == true || @each.value.served == false)
&& (@each.value.storage == true || @each.value.storage == false)
invalid spec.versions name.
Rule logic
- For each
input.spec.versions- Require
@each.value.name != null
&& @core.length(@each.value.name) >= 1
&& @core.is-match(@each.value.name, '^[a-z]([-a-z0-9]*[a-z0-9])?$')
&& @core.length(@each.value.name) <= 63
deprecation-warning requires deprecated.
Rule logic
- For each
input.spec.versions- When
@each.value.deprecation-warning != null- Require
@each.value.deprecated == true
selectable-fields must contain at most eight fields.
Rule logic
- For each
input.spec.versions- Require
@core.length(@each.value.selectable-fields ?? []) <= 8
scale requires spec-replicas-path and status-replicas-path.
Rule logic
- For each
input.spec.versions- When
@each.value.subresources.scale != null- Require
@core.length(@each.value.subresources.scale.spec-replicas-path ?? '') >= 1
&& @core.length(@each.value.subresources.scale.status-replicas-path ?? '') >= 1
selectable fields require json-path.
Rule logic
- For each
@vininput.spec.versions
@fin@v.value.selectable-fields ?? []- Require
@f.value.json-path != null
&& @core.length(@f.value.json-path) >= 1
subresources.status must be empty.
Rule logic
- For each
input.spec.versions- Require
@core.length(@each.value.subresources.status ?? {}) <= 0
printer columns require name, type and json-path.
Rule logic
- For each
@vininput.spec.versions
@cin@v.value.additional-printer-columns ?? []- Require
@c.value.name != null
&& @core.length(@c.value.name) >= 1
&& @c.value.type != null
&& @core.length(@c.value.type) >= 1
&& @c.value.json-path != null
&& @core.length(@c.value.json-path) >= 1
printer column priority must fit a nonnegative int32.
Rule logic
- For each
@vininput.spec.versions
@cin@v.value.additional-printer-columns ?? []- Require
(@c.value.priority == null || @c.value.priority >= 0)
&& (@c.value.priority == null || @c.value.priority <= 2147483647)
conversion.strategy must be None or Webhook.
Rule logic
- When
input.spec.conversion != null- Require
input.spec.conversion.strategy == 'None'
|| input.spec.conversion.strategy == 'Webhook'
Webhook conversion requires webhook configuration.
Rule logic
- When
input.spec.conversion.strategy == 'Webhook'- Require
input.spec.conversion.webhook != null
None conversion forbids webhook configuration.
Rule logic
- When
input.spec.conversion.strategy == 'None'- Require
input.spec.conversion.webhook == null
webhook configuration requires Webhook conversion.
Rule logic
- When
input.spec.conversion.webhook != null- Require
input.spec.conversion.strategy == 'Webhook'
conversion-review-versions must not be empty.
Rule logic
- When
input.spec.conversion.webhook != null- Require
@core.length(input.spec.conversion.webhook.conversion-review-versions ?? []) >= 1
webhook client-config requires exactly one URL or service.
Rule logic
- When
input.spec.conversion.webhook != null- Require
input.spec.conversion.webhook.client-config.url != null != (input.spec.conversion.webhook.client-config.service != null)
webhook ca-bundle must be base64.
Rule logic
- Require
@core.is-format(input.spec.conversion.webhook.client-config.ca-bundle, 'base64')
webhook service requires name and namespace.
Rule logic
- When
input.spec.conversion.webhook.client-config.service != null- Require
@core.length(input.spec.conversion.webhook.client-config.service.name ?? '') >= 1
&& @core.length(input.spec.conversion.webhook.client-config.service.namespace ?? '') >= 1
webhook service port must be between 1 and 65535.
Rule logic
- Require
(input.spec.conversion.webhook.client-config.service.port == null || input.spec.conversion.webhook.client-config.service.port >= 1)
&& (input.spec.conversion.webhook.client-config.service.port == null || input.spec.conversion.webhook.client-config.service.port <= 65535)
Create timeout rules
create-timeout must be a positive duration.
Rule logic
- Require
@core.is-format(input.create-timeout, 'positive-duration')
Update timeout rules
update-timeout must be a positive duration.
Rule logic
- Require
@core.is-format(input.update-timeout, 'positive-duration')
Delete timeout rules
delete-timeout must be a positive duration.
Rule logic
- Require
@core.is-format(input.delete-timeout, 'positive-duration')
Outputs¶
server
string
api-version
string
kind
string
name
string
uid
string
metadata
object
object({
name: string
labels: optional(map(string))
annotations: optional(map(string))
})
spec
object
object({
group: string
names: object({
plural: string
singular: optional(string)
kind: string
list-kind: optional(string)
short-names: optional(list(string))
categories: optional(list(string))
})
scope: string
versions: list(
object({
name: string
served: boolean
storage: boolean
deprecated: optional(boolean)
deprecation-warning: optional(string)
schema: optional(map(opaque))
subresources: optional(
object({
status: optional(map(opaque))
scale: optional(
object({
spec-replicas-path: string
status-replicas-path: string
label-selector-path: optional(string)
})
)
})
)
additional-printer-columns: optional(
list(
object({
name: string
type: string
format: optional(string)
description: optional(string)
priority: optional(integer)
json-path: string
})
)
)
selectable-fields: optional(
list(
object({
json-path: string
})
)
)
})
)
conversion: optional(
object({
strategy: string
webhook: optional(
object({
conversion-review-versions: list(string)
client-config: object({
url: optional(string)
service: optional(
object({
namespace: string
name: string
path: optional(string)
port: optional(integer)
})
)
ca-bundle: optional(string)
})
})
)
})
)
preserve-unknown-fields: optional(boolean)
})