<p>I need to set a static hostname in a Kubernetes replication controller. Docker supports it with some runtime flags, however, Kubernetes replication controllers don't appear to support it.
The environment: OS - CentOS 6.6
Approach to use sysctl to change the variable kernel.hostname does not work for a K8s replication controller. The host name is not changed.
Use:
sysctl kernel.hostname
to read the current hostname, and
sysctl kernel.hostname=NEW_HOSTNAME</p>

<p>Is it possible to set a hostname in a Kubernetes replication controller?</p>

<p>In 1.7 you can set the hostname directly in the Deployment spec</p>

<pre><code>spec:
  replicas: 1
  template:
    spec:
      hostname: myhostname
      containers:
        ...
</code></pre>

<p><strong>Old Answer</strong></p>

<p>Now that 1.2 has landed, you can set a static hostname in a Replication Controller or Deployment <code>spec</code> using the <code>pod.beta.kubernetes.io/hostname</code> annotation.</p>

<pre><code>spec:
  replicas: 1
  template:
    metadata:
      annotations:
        pod.beta.kubernetes.io/hostname: myhostname
      labels:
        ...
</code></pre>
