Skip to content

Support custom list of services to be added to /etc/hosts in cluster DNS operator - RFE-4145 #2435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
56 changes: 55 additions & 1 deletion openapi/generated_openapi/zz_generated.openapi.go

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

33 changes: 33 additions & 0 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -28801,6 +28801,26 @@
}
}
},
"com.github.openshift.api.operator.v1.DNSNodeService": {
"description": "DNSNodeService represents a Kubernetes service by name and namespace for node services.",
"type": "object",
"required": [
"name",
"namespace"
],
"properties": {
"name": {
"description": "name is the name of the service. The name should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens, and should start with an alphabetic character and end with an alphanumeric character.",
"type": "string",
"default": ""
},
"namespace": {
"description": "namespace is the namespace of the service. The namespace should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens, and should start and end with an alphanumeric character.",
"type": "string",
"default": ""
}
}
},
"com.github.openshift.api.operator.v1.DNSOverTLSConfig": {
"description": "DNSOverTLSConfig describes optional DNSTransportConfig fields that should be captured.",
"type": "object",
Expand Down Expand Up @@ -28842,6 +28862,19 @@
"default": {},
"$ref": "#/definitions/com.github.openshift.api.operator.v1.DNSNodePlacement"
},
"nodeServices": {
"description": "nodeServices specifies a list of service objects for which host level resolvable entries should be added. Services in this list will be added to /etc/hosts on each node in the cluster by the node resolver. When not specified, only the default image registry service is resolvable. Services in this list will be added in addition to the default \"image-registry.openshift-image-registry.svc\" service. The default image registry service cannot be removed. For each service reference, entries will be created using the format \"<name>.<namespace>.svc\" and an alias with the CLUSTER_DOMAIN suffix of cluster.local will also be added.",
"type": "array",
"items": {
"default": {},
"$ref": "#/definitions/com.github.openshift.api.operator.v1.DNSNodeService"
},
"x-kubernetes-list-map-keys": [
"name",
"namespace"
],
"x-kubernetes-list-type": "map"
},
"operatorLogLevel": {
"description": "operatorLogLevel controls the logging level of the DNS Operator. Valid values are: \"Normal\", \"Debug\", \"Trace\". Defaults to \"Normal\". setting operatorLogLevel: Trace will produce extremely verbose logs.",
"type": "string"
Expand Down
37 changes: 37 additions & 0 deletions operator/v1/types_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ type DNSSpec struct {
// +kubebuilder:default=Normal
OperatorLogLevel DNSLogLevel `json:"operatorLogLevel,omitempty"`

// nodeServices specifies a list of service objects for which host level resolvable entries should be added.
// Services in this list will be added to /etc/hosts on each node in the cluster by the node resolver.
// When not specified, only the default image registry service is resolvable.
// Services in this list will be added in addition to the default "image-registry.openshift-image-registry.svc" service.
// The default image registry service cannot be removed.
// For each service reference, entries will be created using the format "<name>.<namespace>.svc"
// and an alias with the CLUSTER_DOMAIN suffix of cluster.local will also be added.
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect we probably want to shorten this and drop CLUSTER_DOMAIN if it is not configurable, CC @Miciah to confirm

//
// +optional
// +kubebuilder:validation:MaxItems=20
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to get input from the network team about the appropriate maximum for this list. 20 sounds ok to me, but I wonder if we can reasonably expand this to account for a larger use case.

@Miciah could you or one of your team consider the implications of adding new entries, and what an appropriate maximum scale might be?

// +kubebuilder:validation:MinItems=1
// +listType=map
// +listMapKey=name
// +listMapKey=namespace
NodeServices []DNSNodeService `json:"nodeServices,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also add

Suggested change
NodeServices []DNSNodeService `json:"nodeServices,omitempty"`
// +kubebuilder:validation:MinItems=1
// +listType=map
// +listMapKey=name
// +listMapKey=namespace
NodeServices []DNSNodeService `json:"nodeServices,omitempty"`


// logLevel describes the desired logging verbosity for CoreDNS.
// Any one of the following values may be specified:
// * Normal logs errors from upstream resolvers.
Expand Down Expand Up @@ -163,6 +179,27 @@ var (
DNSLogLevelTrace DNSLogLevel = "Trace"
)

// DNSNodeService represents a Kubernetes service by name and namespace for node services.
type DNSNodeService struct {
// name is the name of the service.
Copy link
Contributor

Choose a reason for hiding this comment

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

Service names are validated as DNS 1035 labels, so we should explain that here

Suggested change
// name is the name of the service.
// name is the name of the service.
// The name should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens,
// and should start with an alphabetic character and end with an alphanumeric character.

// The name should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens,
// and should start with an alphabetic character and end with an alphanumeric character.
// +required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:XValidation:rule=`!format.dns1035Label().validate(self).hasValue()`,message="a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character"
Name string `json:"name"`

// namespace is the namespace of the service.
Copy link
Contributor

Choose a reason for hiding this comment

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

Namespace names are DNS 1123 Labels, so we will explain that here too

Suggested change
// namespace is the namespace of the service.
// namespace is the namespace of the service.
// The namespace should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens,
// and should start and end with an alphanumeric character.

// The namespace should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens,
// and should start and end with an alphanumeric character.
// +required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:XValidation:rule=`!format.dns1123Label().validate(self).hasValue()`,message="the value must consist of only lowercase alphanumeric characters and hyphens"
Namespace string `json:"namespace"`
}

// Server defines the schema for a server that runs per instance of CoreDNS.
type Server struct {
// name is required and specifies a unique name for the server. Name must comply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,55 @@ spec:
type: object
type: array
type: object
nodeServices:
description: |-
nodeServices specifies a list of service objects for which host level resolvable entries should be added.
Services in this list will be added to /etc/hosts on each node in the cluster by the node resolver.
When not specified, only the default image registry service is resolvable.
Services in this list will be added in addition to the default "image-registry.openshift-image-registry.svc" service.
The default image registry service cannot be removed.
For each service reference, entries will be created using the format "<name>.<namespace>.svc"
and an alias with the CLUSTER_DOMAIN suffix of cluster.local will also be added.
items:
description: DNSNodeService represents a Kubernetes service by name
and namespace for node services.
properties:
name:
description: |-
name is the name of the service.
The name should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens,
and should start with an alphabetic character and end with an alphanumeric character.
maxLength: 63
minLength: 1
type: string
x-kubernetes-validations:
- message: a DNS-1035 label must consist of lower case alphanumeric
characters or '-', start with an alphabetic character, and
end with an alphanumeric character
rule: '!format.dns1035Label().validate(self).hasValue()'
namespace:
description: |-
namespace is the namespace of the service.
The namespace should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens,
and should start and end with an alphanumeric character.
maxLength: 63
minLength: 1
type: string
x-kubernetes-validations:
- message: the value must consist of only lowercase alphanumeric
characters and hyphens
rule: '!format.dns1123Label().validate(self).hasValue()'
required:
- name
- namespace
type: object
maxItems: 20
minItems: 1
type: array
x-kubernetes-list-map-keys:
- name
- namespace
x-kubernetes-list-type: map
operatorLogLevel:
default: Normal
description: |-
Expand Down
21 changes: 21 additions & 0 deletions operator/v1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,55 @@ spec:
type: object
type: array
type: object
nodeServices:
description: |-
nodeServices specifies a list of service objects for which host level resolvable entries should be added.
Services in this list will be added to /etc/hosts on each node in the cluster by the node resolver.
When not specified, only the default image registry service is resolvable.
Services in this list will be added in addition to the default "image-registry.openshift-image-registry.svc" service.
The default image registry service cannot be removed.
For each service reference, entries will be created using the format "<name>.<namespace>.svc"
and an alias with the CLUSTER_DOMAIN suffix of cluster.local will also be added.
items:
description: DNSNodeService represents a Kubernetes service by name
and namespace for node services.
properties:
name:
description: |-
name is the name of the service.
The name should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens,
and should start with an alphabetic character and end with an alphanumeric character.
maxLength: 63
minLength: 1
type: string
x-kubernetes-validations:
- message: a DNS-1035 label must consist of lower case alphanumeric
characters or '-', start with an alphabetic character, and
end with an alphanumeric character
rule: '!format.dns1035Label().validate(self).hasValue()'
namespace:
description: |-
namespace is the namespace of the service.
The namespace should consist of at most 63 characters, and of only lowercase alphanumeric characters and hyphens,
and should start and end with an alphanumeric character.
maxLength: 63
minLength: 1
type: string
x-kubernetes-validations:
- message: the value must consist of only lowercase alphanumeric
characters and hyphens
rule: '!format.dns1123Label().validate(self).hasValue()'
required:
- name
- namespace
type: object
maxItems: 20
minItems: 1
type: array
x-kubernetes-list-map-keys:
- name
- namespace
x-kubernetes-list-type: map
operatorLogLevel:
default: Normal
description: |-
Expand Down
Loading