Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions config/v1/0000_10_config-operator_01_dns-TechPreviewNoUpgrade.crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.openshift.io: https://github.com/openshift/api/pull/470
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
release.openshift.io/feature-set: TechPreviewNoUpgrade
name: dnses.config.openshift.io
spec:
group: config.openshift.io
names:
kind: DNS
listKind: DNSList
plural: dnses
singular: dns
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: "DNS holds cluster-wide information about DNS. The canonical name is `cluster` \n Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer)."
type: object
required:
- spec
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: spec holds user settable values for configuration
type: object
properties:
baseDomain:
description: "baseDomain is the base domain of the cluster. All managed DNS records will be sub-domains of this base. \n For example, given the base domain `openshift.example.com`, an API server DNS record may be created for `cluster-api.openshift.example.com`. \n Once set, this field cannot be changed."
type: string
platform:
description: platform holds configuration specific to the underlying infrastructure provider for DNS. When omitted, this means the user has no opinion and the platform is left to choose reasonable defaults. These defaults are subject to change over time.
type: object
required:
- type
properties:
aws:
description: aws contains DNS configuration specific to the Amazon Web Services cloud provider.
type: object
properties:
privateZoneIAMRole:
description: privateZoneIAMRole contains the ARN of an IAM role that should be assumed when performing operations on the cluster's private hosted zone specified in the cluster DNS config. When left empty, no role should be assumed.
type: string
pattern: ^arn:(aws|aws-cn|aws-us-gov):iam:[0-9]{12}:role\/.*$
type:
description: "type is the underlying infrastructure provider for the cluster. Allowed values: \"\", \"AWS\". \n Individual components may not support all platforms, and must handle unrecognized platforms with best-effort defaults."
type: string
enum:
- ""
- AWS
- Azure
- BareMetal
- GCP
- Libvirt
- OpenStack
- None
- VSphere
- oVirt
- IBMCloud
- KubeVirt
- EquinixMetal
- PowerVS
- AlibabaCloud
- Nutanix
- External
Comment on lines +60 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to cause confusing error messages, or does the x-kubernetes-validations rule take precedence and prevent the enum rule from causing unsupported values to be printed in error messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the test, the x-kubernetes-validations message takes precedence, so I think we're ok.

x-kubernetes-validations:
- rule: self in ['','AWS']
message: allowed values are '' and 'AWS'
x-kubernetes-validations:
- rule: 'has(self.type) && self.type == ''AWS'' ? has(self.aws) : !has(self.aws)'
message: aws configuration is required when platform is AWS, and forbidden otherwise
privateZone:
description: "privateZone is the location where all the DNS records that are only available internally to the cluster exist. \n If this field is nil, no private records should be created. \n Once set, this field cannot be changed."
type: object
properties:
id:
description: "id is the identifier that can be used to find the DNS hosted zone. \n on AWS zone can be fetched using `ID` as id in [1] on Azure zone can be fetched using `ID` as a pre-determined name in [2], on GCP zone can be fetched using `ID` as a pre-determined name in [3]. \n [1]: https://docs.aws.amazon.com/cli/latest/reference/route53/get-hosted-zone.html#options [2]: https://docs.microsoft.com/en-us/cli/azure/network/dns/zone?view=azure-cli-latest#az-network-dns-zone-show [3]: https://cloud.google.com/dns/docs/reference/v1/managedZones/get"
type: string
tags:
description: "tags can be used to query the DNS hosted zone. \n on AWS, resourcegroupstaggingapi [1] can be used to fetch a zone using `Tags` as tag-filters, \n [1]: https://docs.aws.amazon.com/cli/latest/reference/resourcegroupstaggingapi/get-resources.html#options"
type: object
additionalProperties:
type: string
publicZone:
description: "publicZone is the location where all the DNS records that are publicly accessible to the internet exist. \n If this field is nil, no public records should be created. \n Once set, this field cannot be changed."
type: object
properties:
id:
description: "id is the identifier that can be used to find the DNS hosted zone. \n on AWS zone can be fetched using `ID` as id in [1] on Azure zone can be fetched using `ID` as a pre-determined name in [2], on GCP zone can be fetched using `ID` as a pre-determined name in [3]. \n [1]: https://docs.aws.amazon.com/cli/latest/reference/route53/get-hosted-zone.html#options [2]: https://docs.microsoft.com/en-us/cli/azure/network/dns/zone?view=azure-cli-latest#az-network-dns-zone-show [3]: https://cloud.google.com/dns/docs/reference/v1/managedZones/get"
type: string
tags:
description: "tags can be used to query the DNS hosted zone. \n on AWS, resourcegroupstaggingapi [1] can be used to fetch a zone using `Tags` as tag-filters, \n [1]: https://docs.aws.amazon.com/cli/latest/reference/resourcegroupstaggingapi/get-resources.html#options"
type: object
additionalProperties:
type: string
status:
description: status holds observed values from the cluster. They may not be overridden.
type: object
served: true
storage: true
subresources:
status: {}
104 changes: 104 additions & 0 deletions config/v1/techpreview.dns.testsuite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[TechPreview] DNS"
crd: 0000_10_config-operator_01_dns-TechPreviewNoUpgrade.crd.yaml
tests:
onCreate:
- name: Should be able to create a minimal DNS
initial: |
apiVersion: config.openshift.io/v1
kind: DNS
spec: {} # No spec is required for a DNS
expected: |
apiVersion: config.openshift.io/v1
kind: DNS
spec: {}
- name: Should be able to specify an AWS role ARN for a private hosted zone
initial: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: AWS
aws:
privateZoneIAMRole: arn:aws:iam:123456789012:role/foo
expected: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: AWS
aws:
privateZoneIAMRole: arn:aws:iam:123456789012:role/foo
- name: Should not be able to specify unsupported platform
initial: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: Azure
azure:
privateZoneIAMRole: arn:aws:iam:123456789012:role/foo
expectedError: "Invalid value: \"string\": allowed values are '' and 'AWS'"
- name: Should not be able to specify invalid AWS role ARN
initial: |
apiVersion: config.openshift.io/v1
kind: DNS
metadata:
name: cluster
spec:
platform:
type: AWS
aws:
privateZoneIAMRole: arn:aws:iam:bad:123456789012:role/foo
expectedError: "DNS.config.openshift.io \"cluster\" is invalid: spec.platform.aws.privateZoneIAMRole: Invalid value: \"arn:aws:iam:bad:123456789012:role/foo\": spec.platform.aws.privateZoneIAMRole in body should match '^arn:(aws|aws-cn|aws-us-gov):iam:[0-9]{12}:role\\/.*$'"
- name: Should not be able to specify different type and platform
initial: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: ""
aws:
privateZoneIAMRole: arn:aws:iam:123456789012:role/foo
expectedError: "Invalid value: \"object\": aws configuration is required when platform is AWS, and forbidden otherwise"
onUpdate:
- name: Can switch from empty (default), to AWS
initial: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: ""
updated: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: AWS
aws:
privateZoneIAMRole: arn:aws:iam:123456789012:role/foo
expected: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: AWS
aws:
privateZoneIAMRole: arn:aws:iam:123456789012:role/foo
- name: Upgrade case is valid
initial: |
apiVersion: config.openshift.io/v1
kind: DNS
spec: {} # No spec is required for a DNS
updated: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: ""
expected: |
apiVersion: config.openshift.io/v1
kind: DNS
spec:
platform:
type: ""
38 changes: 38 additions & 0 deletions config/v1/types_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ type DNSSpec struct {
//
// +optional
PrivateZone *DNSZone `json:"privateZone,omitempty"`
// platform holds configuration specific to the underlying
// infrastructure provider for DNS.
// When omitted, this means the user has no opinion and the platform is left
// to choose reasonable defaults. These defaults are subject to change over time.
// +openshift:enable:FeatureSets=TechPreviewNoUpgrade
// +optional
Platform DNSPlatformSpec `json:"platform,omitempty"`
}

// DNSZone is used to define a DNS hosted zone.
Expand Down Expand Up @@ -96,3 +103,34 @@ type DNSList struct {

Items []DNS `json:"items"`
}

// DNSPlatformSpec holds cloud-provider-specific configuration
// for DNS administration.
// +union
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'AWS' ? has(self.aws) : !has(self.aws)",message="aws configuration is required when platform is AWS, and forbidden otherwise"
type DNSPlatformSpec struct {
// type is the underlying infrastructure provider for the cluster.
// Allowed values: "", "AWS".
//
// Individual components may not support all platforms,
// and must handle unrecognized platforms with best-effort defaults.
//
// +unionDiscriminator
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self in ['','AWS']",message="allowed values are '' and 'AWS'"
Type PlatformType `json:"type"`

// aws contains DNS configuration specific to the Amazon Web Services cloud provider.
// +optional
AWS *AWSDNSSpec `json:"aws"`
}

// AWSDNSSpec contains DNS configuration specific to the Amazon Web Services cloud provider.
type AWSDNSSpec struct {
// privateZoneIAMRole contains the ARN of an IAM role that should be assumed when performing
// operations on the cluster's private hosted zone specified in the cluster DNS config.
// When left empty, no role should be assumed.
// +kubebuilder:validation:Pattern:=`^arn:(aws|aws-cn|aws-us-gov):iam:[0-9]{12}:role\/.*$`
// +optional
PrivateZoneIAMRole string `json:"privateZoneIAMRole"`
}
38 changes: 38 additions & 0 deletions config/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions config/v1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading