consul-k8s icon indicating copy to clipboard operation
consul-k8s copied to clipboard

Option to overwrite the Image Entrypoint in values.yaml

Open Mellywins opened this issue 3 years ago • 2 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Is your feature request related to a problem? Please describe.

I'm trying to store some microservices config in Consul's kv store after the container init. For that i wrote my own entrypoint which executes the old entrypoint, runs a script then returns the old entrypoint to the foreground. But when the pod is up, it's starting with the old entrypoint script. Here are more details to this:

  • Running kubectl describe pods consul-server-0 yields:
Containers:
  consul:
    Container ID:  docker://11b03ece50c2dd0cf9743f74c916701b022ace2ed067fdea164ee60c7a5e1396
    Image:         mellywins/ezyfs-consul:latest
    Image ID:      docker-pullable://mellywins/ezyfs-consul@sha256:9d98a854b44eb40d246d391810ebb1020189ab6a8978e6fee744ace9a2a4b34d
    Ports:         8500/TCP, 8301/TCP, 8301/UDP, 8302/TCP, 8302/UDP, 8300/TCP, 8600/TCP, 8600/UDP
    Host Ports:    0/TCP, 0/TCP, 0/UDP, 0/TCP, 0/UDP, 0/TCP, 0/TCP, 0/UDP
    Command:
      /bin/sh
      -ec
      CONSUL_FULLNAME="consul"
      
      mkdir -p /consul/extra-config
      cp /consul/config/extra-from-values.json /consul/extra-config/extra-from-values.json
      [ -n "${HOST_IP}" ] && sed -Ei "s|HOST_IP|${HOST_IP?}|g" /consul/extra-config/extra-from-values.json
      [ -n "${POD_IP}" ] && sed -Ei "s|POD_IP|${POD_IP?}|g" /consul/extra-config/extra-from-values.json
      [ -n "${HOSTNAME}" ] && sed -Ei "s|HOSTNAME|${HOSTNAME?}|g" /consul/extra-config/extra-from-values.json
      
      exec /usr/local/bin/docker-entrypoint.sh consul agent \
        -advertise="${ADVERTISE_IP}" \
        -bind=0.0.0.0 \
        -bootstrap-expect=1 \
        -client=0.0.0.0 \
        -config-dir=/consul/config \
        -datacenter=dc1 \
        -data-dir=/consul/data \
        -domain=consul \
        -hcl="connect { enabled = true }" \
        -ui \
        -retry-join="${CONSUL_FULLNAME}-server-0.${CONSUL_FULLNAME}-server.${NAMESPACE}.svc:8301" \
        -serf-lan-port=8301 \
        -config-file=/consul/extra-config/extra-from-values.json \
        -server

This command is not the one i wrote. Here is the one that should be there: Link

Feature Description

Add an option in the values.yaml to overwrite the ENTRYPOINT and CMD with new values

Use Case(s)

Using Consul's KV as Config Server.

Mellywins avatar Mar 02 '22 20:03 Mellywins

Hi @Mellywins how many key value pairs do you have? Could you share an example of the type of config you are trying to apply. If you use Consul Service Mesh, we have this neat annotation that allows you apply Key Value pairs as Service Metadata when registering the service: https://www.consul.io/docs/k8s/annotations-and-labels#consul-hashicorp-com-service-meta.

As far as KV, although Consul can be used as a KV, we are no longer actively developing any new features for KV, and typically recommend other KV solutions if you need a dedicated KV.

david-yu avatar Mar 02 '22 21:03 david-yu

Hi @Mellywins how many key value pairs do you have? Could you share an example of the type of config you are trying to apply. If you use Consul Service Mesh, we have this neat annotation that allows you apply Key Value pairs as Service Metadata when registering the service: https://www.consul.io/docs/k8s/annotations-and-labels#consul-hashicorp-com-service-meta.

As far as KV, although Consul can be used as a KV, we are no longer actively developing any new features for KV, and typically recommend other KV solutions if you need a dedicated KV.

Here is an example of a microservice config i'm trying to put in the KV.

{
  "app": {
    "port": 3002,
    "name": "io.ezyfs.api-gateway"
  },
  "caching": {
    "ttl": 5,
    "max": 1000
  },
  "auth": {
    "enableJwtAuth": false
  },
  "databases": {
    "redis": {
      "host": "redis",
      "port": "6379",
      "password": ""
    }
  }
}

Well the point is to create a service mesh, One which i'm not approaching in the right way probably. But i also want to pass some extra information to the KV store that i don't think it's feasible through the annotations.

Mellywins avatar Mar 03 '22 15:03 Mellywins

Will close as we don't intend to support this directly within our Helm chart, although you could possibly find a solution for this on your own by experimenting with the Dockerfile for Consul K8s.

david-yu avatar Aug 30 '22 06:08 david-yu