mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Merge pull request #61890 from dims/better-specify-dhcp-domain-for-hostname
Automatic merge from submit-queue (batch tested with PRs 61871, 61890, 61786). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.
Specify DHCP domain for hostname
**What this PR does / why we need it**:
In 9a8c6db448
, we looked at the hostname
in the metadata service and used '.' as the delimiter to chop off the
dhcp_domain (specified in nova.conf). However administrators need to
better control the dhcp domain better as there may be a '.' in the host
name itself. So let's introduce a config option that we can use and
default it to what nova uses when dhcp_domain is not specified which is
"novalocal"
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #
**Special notes for your reviewer**:
**Release note**:
```release-note
new dhcp-domain parameter to be used for figuring out the hostname of a node
```
This commit is contained in:
commit
7a1e44456f
@ -121,6 +121,7 @@ type RouterOpts struct {
|
||||
type MetadataOpts struct {
|
||||
SearchOrder string `gcfg:"search-order"`
|
||||
RequestTimeout MyDuration `gcfg:"request-timeout"`
|
||||
DHCPDomain string `gcfg:"dhcp-domain"`
|
||||
}
|
||||
|
||||
// OpenStack is an implementation of cloud provider Interface for OpenStack.
|
||||
@ -233,6 +234,7 @@ func configFromEnv() (cfg Config, ok bool) {
|
||||
cfg.Global.TrustID != "")
|
||||
|
||||
cfg.Metadata.SearchOrder = fmt.Sprintf("%s,%s", configDriveID, metadataID)
|
||||
cfg.Metadata.DHCPDomain = "novalocal"
|
||||
cfg.BlockStorage.BSVersion = "auto"
|
||||
|
||||
return
|
||||
@ -250,6 +252,7 @@ func readConfig(config io.Reader) (Config, error) {
|
||||
cfg.BlockStorage.TrustDevicePath = false
|
||||
cfg.BlockStorage.IgnoreVolumeAZ = false
|
||||
cfg.Metadata.SearchOrder = fmt.Sprintf("%s,%s", configDriveID, metadataID)
|
||||
cfg.Metadata.DHCPDomain = "novalocal"
|
||||
|
||||
err := gcfg.ReadInto(&cfg, config)
|
||||
return cfg, err
|
||||
|
@ -61,6 +61,10 @@ func (i *Instances) CurrentNodeName(ctx context.Context, hostname string) (types
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
domain := "." + i.opts.DHCPDomain
|
||||
if i.opts.DHCPDomain != "" && strings.HasSuffix(md.Hostname, domain) {
|
||||
return types.NodeName(strings.TrimSuffix(md.Hostname, domain)), nil
|
||||
}
|
||||
return types.NodeName(strings.Split(md.Hostname, ".")[0]), nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user