<p>I have a Kubernetes cluster (external ips: 1.2.3.4, 2.3.4.5, 3.4.5.6)
I want to host a docker registry on this cluster on port 5000. Now to enable this I did a test with externalips, which works. This makes nginx available on port 85.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx-extip
spec:
  type: ClusterIP
  ports:
  - name: http
    protocol: TCP
    port: 85
    targetPort: 80
  selector:
    app: nginx-extip
  externalIPs:
  - 1.2.3.4
  - 2.3.4.5
  - 3.4.5.6
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-extip
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx-extip
    spec:
      containers:
      - name: nginx-extip-server
        image: nginx
        ports:
        - containerPort: 80
</code></pre>

<p>Now to reuse the externalip config I want to put this into a configmap. So all yamls can just reference the configmap and we don't have to manually update the externalips when they change. How can I put an array of ips into the configmap?</p>

<p>My current (not working) configmap:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: externalips
  namespace: default
data:
  externalips:
  - 1.2.3.4
  - 2.3.4.5
  - 3.4.5.6
</code></pre>

<p>The error I get:</p>

<pre><code>error: error validating "static-ips-configmap.yml": error validating data: 
ValidationError(ConfigMap.data.externalips): invalid type for
io.k8s.api.core.v1.ConfigMap.data: got "array", expected "string";
if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>

<p>How can I put these IP's into a configmap?</p>

<p>There are two problems here:</p>

<ol>
<li><p>There is a syntax error in the creation of the configmap itself. Config map expects you to list a bunch of files and their contents, so the correct syntax would look something like this:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: externalips
  namespace: default
data:
  external-ips.list: |
    externalips:
    - 1.2.3.4
    - 2.3.4.5
    - 3.4.5.6
</code></pre></li>
<li><p>I don't think it's possible to refer to a configmap that you created to <em>template a service spec</em>. So even if you managed to create the configmap correctly, you still wouldn't be able to reuse it as part of different service definitions.</p></li>
</ol>

<p>You need an out-of-band templating system that you can use to add these external IPs to services. Alternatively, use an ingress control, that you have to configure with external IPs <em>once</em> and then use it to multiplex all your HTTP services inside the cluster. This way you manage IPs for only one service anyway.</p>
