<p>I created a gossip cluster in AWS using <strong>kops</strong>, which means my cluster name is  ending with <strong>k8s.local</strong> (clusters.test.k8s.local to be exected ),
All is working fine until I tried to create a deployment where the pod name needs to be with a domain at the end (api-manager.iot.test.co.nz).</p>

<p>I know that it is not authorized to create pods that are not standing in the requirements os this regex:</p>

<pre><code>'[a-z]([-a-z0-9]*[a-z0-9])?'
</code></pre>

<p>Is there a way I can do that?</p>

<p>I tried adding hostname under template->spec but it has the same restrictions (the regex).</p>

<p>This is my deployment YAML file:</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  labels:
  name: api-manager
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: api-manager
    spec:
      volumes:
       - name: api-manager-efs
         persistentVolumeClaim:
          claimName: pvc-apim
      containers:
      - image: api-manager:2.1.0
        name: api-manager.iot.test.co.nz
        ports:
        - name: porta 
          containerPort: 9763
        - name: portb
          containerPort: 9443         
        env:
        - name: SLEEP
          value: "30"

        volumeMounts:
        - name: api-manager-efs
          mountPath: /home/wso2carbon/wso2am-2.1.0/repository 
</code></pre>

Shahar Hamuzim Rajuan
<p>after a lot of struggling,
This is my solution:</p>

<p><a href="http://kubernetes%20manual" rel="nofollow noreferrer">https://kubernetes.io/blog/2017/04/configuring-private-dns-zones-upstream-nameservers-kubernetes/</a></p>

<p>1.) create a <strong>dnsmasq</strong> with this your domain configuration inside, you will have to attach a cluster IP which must be in the range of your k8s cluster that you use.</p>

<p>These are the yaml files I created for that:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: dnsmasq
  labels:
    app: dnsmasq
data:
  dnsmasq.conf: |+
    user=root
    #dnsmasq config, for a complete example, see:
    #  http://oss.segetech.com/intra/srv/dnsmasq.conf
    #log all dns queries
    log-queries
    #dont use hosts nameservers
    no-resolv
    #use google as default nameservers
    server=8.8.4.4
    server=8.8.8.8
    #serve all .company queries using a specific nameserver
    server=/company/10.0.0.1
    #explicitly define host-ip mappings
    address=/api-manager.iot.test.vector.co.nz/100.64.53.55

apiVersion: v1
kind: Service
metadata:
  labels:
    app: dnsmasq
  name: dnsstub
spec:
  type: "{{.Values.Service.serviceType}}"
  clusterIP: 100.68.140.187
  ports:
   - port: {{ .Values.Service.serviceports.port }}
     protocol: UDP
  selector:
    app: dnsmasq


---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: dnsmasq
spec:
  replicas: {{ .Values.Deployment.replicaCount }}
  template:
    metadata:
      labels:
        app: dnsmasq
    spec:
      containers:
      - name: dnsmasq
        image:  dnsmasq:1.0.2
        ports:
           - containerPort: {{ .Values.Deployment.ports.containerport }}
             protocol: UDP
        volumeMounts:
        - name: etc
          mountPath: /etc/dnsmasq.conf
          subPath: dnsmasq.conf
      imagePullSecrets:
        - name: mprestg-credentials
      volumes:
      - name: etc
        configMap:
          name: dnsmasq
      dnsPolicy: Default
</code></pre>

<p>2.) Create a kube-dns config-map with stubDomain:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-dns
  namespace: kube-system
data:
  stubDomains: |
    {"iot.test.vector.co.nz": ["100.68.140.187"]}
</code></pre>

<p>3.) Add the static IP that we defined in our dns configuration to out service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: api-manager
  labels:
    app: api-manager
    tier: apim
spec:
  ports:
  - port: 9763
    name: porta
    targetPort: 9763

  selector:
    app: api-manager
  type: LoadBalancer
  clusterIP: 100.64.53.55
</code></pre>
