initialDelaySeconds value from configMap

396 views Asked by At

I have multiple services and their probes are configured in the same way. I would like to extract common values like initialDelaySeconds, periodSeconds etc for livenessProbe into configMap. Is it possible?

When I create a configMap like this:

data:
  liveness-endpoint: /actuator/health/liveness
  liveness-initialDelaySeconds: 60
  liveness-periodSeconds: 5

and try to reference it in probe like this:

  livenessProbe:
    httpGet:
      path: liveness-endpoint
      port: http-api
    initialDelaySeconds: liveness-initialDelaySeconds
    periodSeconds: liveness-periodSeconds

kubernetes complain, that configMap must have only Strings, so I'm changing it to

  liveness-initialDelaySeconds: "60"

and then it complains that probe must use Integer, not String.

As you see, I can reference port for probe, so probably there is a way to define those int values, but how?

1

There are 1 answers

0
Akin Ozer On BEST ANSWER

Kubernetes doesn't allow configMap usage in yaml files. Basically it needs to know before configMap even loads, you can only use configMaps as volumes and environment variables.

Also ports can be string because you can name the ports in pod, svc definitions and then reference that in liveness, readiness probes. But periodSeconds is just plain old integer value only.