-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
KEP-4762: Allows setting any FQDN as the pod's hostname #4768
base: master
Are you sure you want to change the base?
Conversation
HirazawaUi
commented
Jul 18, 2024
- One-line PR description: Allows users to set any FQDN as the hostname of a pod
- Issue link: Allows setting any FQDN as the pod's hostname #4762
- Other comments:
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: HirazawaUi The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
||
This can ultimately simplify `Kubelet` as it can remove legacy behavior, but it means teaching the `kube-apiserver` about the `cluster-suffix`. | ||
|
||
However, it is challenging to find an existing or grace way to pass the `kube-apiserver`’s configuration options in the REST or default logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned here, during the POC, I was unable to find a good method to pass the kube-apiserver configuration options to the default or REST logic, so I listed it as an alternative. I'd really appreciate any suggestions on this. If there are any ways I haven’t thought of to pass the kube-apiserver configuration options, I will revise it to be our main solution and list the current solution as an alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing the cluster-domain
as an argument to the ApiServer
and generating the actualPodHostname
in the REST based on the hostname
in the PodSpec
, the setHostnameAsFQDN
field, and the ApiServer's cluster-domain args
, the POC can be found here:
This is one of the options I envisioned. Although it’s not good, I still pushed the code and hope to get more feedback.
615fb45
to
e219291
Compare
|
||
## Summary | ||
|
||
This proposal allows users to set arbitrary Fully Qualified Domain Name (FQDN) as the hostname of a pod, introduces a new field `actualPodHostname` for the podSpec, which, if set, will always be respected by the Kubelet (otherwise it will fall back to legacy behavior), and no longer cares about the `hostname` as well as the `setHostnameAsFQDN` values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a new field?
this will make this more complicated than it is today, no?
why is not an alternative to allow to relax the validation of the current pod.spec.hostname
field to be able to set a fqdn there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, adding it will make everything more complex, but now we will create DNS records based on the hostname
field in podSpec
. If we set the FQDN in the hostname, it is undoubtedly a disruption to the existing behavior.
ref: https://github.com/kubernetes/kubernetes/blob/e1aa8197eddd277fb82be0b8bbc2ba2b4ca67af7/pkg/controller/endpoint/endpoints_controller.go#L439-L441
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is disruptive? are those controllers not copying the field verbatim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we set the hostname
field in the podSpec
to an FQDN, such as www.google.com
, and also set the subdomain
field, we end up with an FQDN hostname that appends the cluster-suffix
, resulting in www.google.com.subdomain.default.svc.cluster.local
. Additionally, we get a DNS record for www.google.com.subdomain.default.svc.cluster.local
. I believe this does not align with our current design patterns, and it also can't meet our current needs.
Of course, we can also state that when the hostname
in the podSpec
is set to an FQDN, we can ignore the subdomain
field. I will add this to the Alternatives section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... or to keep the current hostname
and be able to override or omit the default.svc.cluster.local
part , right ? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, added.
8728dcf
to
d935541
Compare
/cc @thockin |
keps/sig-network/4762-allow-arbitrary-fqdn-as-pod-hostname/README.md
Outdated
Show resolved
Hide resolved
9daccf9
to
18d6ffd
Compare
5a59d1f
to
12dc314
Compare
12dc314
to
f2c3e30
Compare
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
ping @thockin |
|
||
This is not a standard Kubernetes use case; it is undoubtedly in conflict with the current pod's potential DNS records, and using it will bring more confusion to users. Moreover, we are not sure how much it can help traditional services that can benefit from being migrated to Kubernetes. | ||
|
||
## Alternatives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
people can use an init container, no?
apiVersion: v1
kind: Pod
metadata:
name: myapp-fqdn
labels:
app.kubernetes.io/name: MyApp
spec:
containers:
- name: myapp-container
image: busybox:1.28
command: ['sh', '-c', 'echo "Hostname $(hostname) fqdn $(hostname -f)" && sleep 3600']
initContainers:
- name: init-myservice
image: busybox:1.28
command: ['sh', '-c', "hostname mypod.fqdn.com"]
securityContext:
privileged: true
$ kubectl apply -f init-hostname.yaml
pod/myapp-fqdn created
$ kubectl logs pod/myapp-fqdn
Defaulted container "myapp-container" out of: myapp-container, init-myservice (init)
Hostname mypod.fqdn.com fqdn mypod.fqdn.com <----
I think the effort and complexity this introduces is not giving enough benefit , specially if there is an alternative
This is not a standard Kubernetes use case; it is undoubtedly in conflict with the current pod's potential DNS records, and using it will bring more confusion to users. Moreover, we are not sure how much it can help traditional services that can benefit from being migrated to Kubernetes. | ||
|
||
## Alternatives | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per #4768 (comment), let's list several alternatives including that one (it's good if each has its own subheading).
Remember that actions like "write documentation for…" are valid alternatives.