Kubernetes - specify externalips in configmap Kubernetes - specify externalips in configmap kubernetes kubernetes

Kubernetes - specify externalips in configmap


There are two problems here:

  1. 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:

    apiVersion: v1kind: ConfigMapmetadata:  name: externalips  namespace: defaultdata:  external-ips.list: |    externalips:    - 1.2.3.4    - 2.3.4.5    - 3.4.5.6
  2. I don't think it's possible to refer to a configmap that you created to template a service spec. 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.

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 once and then use it to multiplex all your HTTP services inside the cluster. This way you manage IPs for only one service anyway.


ffledgling's answer is correct, but I think "external-ips.list" confuses a little bit.

This is what should look like the configmap yaml file:

apiVersion: v1kind: ConfigMapmetadata:  name: externalips  namespace: defaultdata:  externalips: |    ips:    - 1.2.3.4    - 2.3.4.5    - 3.4.5.6

So, "externalips", "ips", "external-ips.list" can be anything as those are just keys.