mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Adding new PodSpec field called setHostnameAsFQDN and SetHostnameAsFQDN gate
These changes add a new field, called setHostnameAsFQDN, to the PodSpec. This field is a bool that will be used to indicate whether we would like FQDN be set as hostname or not. This is PART1 of the changes to enable KEP #1797 and addresses #91036
This commit is contained in:
parent
e6214389ca
commit
4112d8db20
@ -438,6 +438,12 @@ func dropDisabledFields(
|
|||||||
// does not specify any values for these fields.
|
// does not specify any values for these fields.
|
||||||
podSpec.PreemptionPolicy = nil
|
podSpec.PreemptionPolicy = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !utilfeature.DefaultFeatureGate.Enabled(features.SetHostnameAsFQDN) && !setHostnameAsFQDNInUse(oldPodSpec) {
|
||||||
|
// Set SetHostnameAsFQDN to nil only if feature is disabled and it is not used
|
||||||
|
podSpec.SetHostnameAsFQDN = nil
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dropDisabledRunAsGroupField removes disabled fields from PodSpec related
|
// dropDisabledRunAsGroupField removes disabled fields from PodSpec related
|
||||||
@ -720,3 +726,11 @@ func multiplePodIPsInUse(podStatus *api.PodStatus) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setHostnameAsFQDNInUse returns true if any pod's spec defines setHostnameAsFQDN field.
|
||||||
|
func setHostnameAsFQDNInUse(podSpec *api.PodSpec) bool {
|
||||||
|
if podSpec == nil || podSpec.SetHostnameAsFQDN == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return *podSpec.SetHostnameAsFQDN
|
||||||
|
}
|
||||||
|
@ -2693,6 +2693,12 @@ type PodSpec struct {
|
|||||||
// If not specified, the pod will not have a domainname at all.
|
// If not specified, the pod will not have a domainname at all.
|
||||||
// +optional
|
// +optional
|
||||||
Subdomain string
|
Subdomain string
|
||||||
|
// If true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default).
|
||||||
|
// In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname).
|
||||||
|
// In Windows containers, this means setting the registry value of hostname for the registry key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters to FQDN.
|
||||||
|
// If a pod does not have FQDN, this has no effect.
|
||||||
|
// +optional
|
||||||
|
SetHostnameAsFQDN *bool
|
||||||
// If specified, the pod's scheduling constraints
|
// If specified, the pod's scheduling constraints
|
||||||
// +optional
|
// +optional
|
||||||
Affinity *Affinity
|
Affinity *Affinity
|
||||||
|
@ -592,6 +592,13 @@ const (
|
|||||||
//
|
//
|
||||||
// Enables usage of any object for volume data source in PVCs
|
// Enables usage of any object for volume data source in PVCs
|
||||||
AnyVolumeDataSource featuregate.Feature = "AnyVolumeDataSource"
|
AnyVolumeDataSource featuregate.Feature = "AnyVolumeDataSource"
|
||||||
|
|
||||||
|
// owner: @javidiaz
|
||||||
|
// alpha: v1.19
|
||||||
|
//
|
||||||
|
// Allow setting the Fully Qualified Domain Name (FQDN) in the hostname of a Pod. If a Pod does not
|
||||||
|
// have FQDN, this feature has no effect.
|
||||||
|
SetHostnameAsFQDN featuregate.Feature = "SetHostnameAsFQDN"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -683,6 +690,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
|||||||
ExternalPolicyForExternalIP: {Default: true, PreRelease: featuregate.GA}, // remove in 1.20
|
ExternalPolicyForExternalIP: {Default: true, PreRelease: featuregate.GA}, // remove in 1.20
|
||||||
AnyVolumeDataSource: {Default: false, PreRelease: featuregate.Alpha},
|
AnyVolumeDataSource: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
DefaultPodTopologySpread: {Default: false, PreRelease: featuregate.Alpha},
|
DefaultPodTopologySpread: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
SetHostnameAsFQDN: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
|
||||||
// inherited features from generic apiserver, relisted here to get a conflict if it is changed
|
// inherited features from generic apiserver, relisted here to get a conflict if it is changed
|
||||||
// unintentionally on either side:
|
// unintentionally on either side:
|
||||||
|
@ -3055,6 +3055,13 @@ type PodSpec struct {
|
|||||||
// +listMapKey=topologyKey
|
// +listMapKey=topologyKey
|
||||||
// +listMapKey=whenUnsatisfiable
|
// +listMapKey=whenUnsatisfiable
|
||||||
TopologySpreadConstraints []TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty" patchStrategy:"merge" patchMergeKey:"topologyKey" protobuf:"bytes,33,opt,name=topologySpreadConstraints"`
|
TopologySpreadConstraints []TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty" patchStrategy:"merge" patchMergeKey:"topologyKey" protobuf:"bytes,33,opt,name=topologySpreadConstraints"`
|
||||||
|
// If true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default).
|
||||||
|
// In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname).
|
||||||
|
// In Windows containers, this means setting the registry value of hostname for the registry key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters to FQDN.
|
||||||
|
// If a pod does not have FQDN, this has no effect.
|
||||||
|
// Default to false.
|
||||||
|
// +optional
|
||||||
|
SetHostnameAsFQDN *bool `json:"setHostnameAsFQDN,omitempty" protobuf:"varint,35,opt,name=setHostnameAsFQDN"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnsatisfiableConstraintAction string
|
type UnsatisfiableConstraintAction string
|
||||||
|
Loading…
Reference in New Issue
Block a user