mirror of https://github.com/k3s-io/k3s
Merge pull request #5830 from vmarmol/hostname
Cap container hostname length to 63 chars.pull/6/head
commit
d0b468f4b0
|
@ -765,13 +765,20 @@ func (kl *Kubelet) runContainer(pod *api.Pod, container *api.Container, podVolum
|
||||||
binds := makeBinds(container, podVolumes)
|
binds := makeBinds(container, podVolumes)
|
||||||
exposedPorts, portBindings := makePortsAndBindings(container)
|
exposedPorts, portBindings := makePortsAndBindings(container)
|
||||||
|
|
||||||
|
// TODO(vmarmol): Handle better.
|
||||||
|
// Cap hostname at 63 chars (specification is 64bytes which is 63 chars and the null terminating char).
|
||||||
|
const hostnameMaxLen = 63
|
||||||
|
containerHostname := pod.Name
|
||||||
|
if len(containerHostname) > hostnameMaxLen {
|
||||||
|
containerHostname = containerHostname[:hostnameMaxLen]
|
||||||
|
}
|
||||||
opts := docker.CreateContainerOptions{
|
opts := docker.CreateContainerOptions{
|
||||||
Name: dockertools.BuildDockerName(dockertools.KubeletContainerName{GetPodFullName(pod), pod.UID, container.Name}, container),
|
Name: dockertools.BuildDockerName(dockertools.KubeletContainerName{GetPodFullName(pod), pod.UID, container.Name}, container),
|
||||||
Config: &docker.Config{
|
Config: &docker.Config{
|
||||||
Cmd: container.Command,
|
Cmd: container.Command,
|
||||||
Env: envVariables,
|
Env: envVariables,
|
||||||
ExposedPorts: exposedPorts,
|
ExposedPorts: exposedPorts,
|
||||||
Hostname: pod.Name,
|
Hostname: containerHostname,
|
||||||
Image: container.Image,
|
Image: container.Image,
|
||||||
Memory: container.Resources.Limits.Memory().Value(),
|
Memory: container.Resources.Limits.Memory().Value(),
|
||||||
CPUShares: milliCPUToShares(container.Resources.Limits.Cpu().MilliValue()),
|
CPUShares: milliCPUToShares(container.Resources.Limits.Cpu().MilliValue()),
|
||||||
|
|
Loading…
Reference in New Issue