Skip to content

Commit

Permalink
Merge pull request kubernetes#5830 from vmarmol/hostname
Browse files Browse the repository at this point in the history
Cap container hostname length to 63 chars.
  • Loading branch information
brendandburns committed Mar 24, 2015
2 parents 5c40bd6 + 07f928b commit d0b468f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,13 +765,20 @@ func (kl *Kubelet) runContainer(pod *api.Pod, container *api.Container, podVolum
binds := makeBinds(container, podVolumes)
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{
Name: dockertools.BuildDockerName(dockertools.KubeletContainerName{GetPodFullName(pod), pod.UID, container.Name}, container),
Config: &docker.Config{
Cmd: container.Command,
Env: envVariables,
ExposedPorts: exposedPorts,
Hostname: pod.Name,
Hostname: containerHostname,
Image: container.Image,
Memory: container.Resources.Limits.Memory().Value(),
CPUShares: milliCPUToShares(container.Resources.Limits.Cpu().MilliValue()),
Expand Down

0 comments on commit d0b468f

Please sign in to comment.