bitnami / containers

Bitnami container images
https://bitnami.com
Other
3.05k stars 4.41k forks source link

ETCDCTL_API=2 not working #67840

Closed jocafi closed 1 day ago

jocafi commented 4 weeks ago

Name and Version

docker.io/bitnami/etcd:3.5.13

What architecture are you using?

amd64

What steps will reproduce the bug?

To reproduce the error, deploy the docker containers below on any swarm environment:

First, create the network: docker network create --driver overlay net-postgres

services:
  etcd1:
    image: docker.io/bitnami/etcd:3.5.13
    hostname: 'etcd1'
    networks:
      - net-postgres
    environment:
      #https://github.com/bitnami/containers/tree/main/bitnami/etcd
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_NAME=etcd1
      - ETCDCTL_API=2
      - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://etcd1:2380
      - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
      - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
      - ETCD_ADVERTISE_CLIENT_URLS=http://etcd1:2379
      - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster
      - ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380
      - ETCD_INITIAL_CLUSTER_STATE=new
    deploy:
      replicas: 1
      placement:
        constraints:
          - "node.role==manager"

  ## Add the curl service
  # curl http://etcd1:2379/v2/keys/message -XPUT -d value="Hello world"
  curl:
    image: curlimages/curl:latest
    hostname: 'curl'
    command: tail -f /dev/null
    networks:
      - net-postgres

networks:
  net-postgres:
    external: true

Enter into the 'curl' container. For example:

docker exec -it baf4e89159d0 sh

Show the version:

$ curl -L http://etcd1:2379/version
{"etcdserver":"3.5.13","etcdcluster":"3.5.0"}

Try some v2 commands described at https://etcd.io/docs/v2.3/api/ Example:

$ curl http://etcd1:2379/v2/keys/message -XPUT -d value="Hello world"
404 page not found

Here is also another example of how to reproduce the error: https://github.com/zalando/spilo/issues/995

What is the expected behavior?

When using the option ETCDCTL_API=2, the etcd server should be compatible with the v2 API as described at https://hub.docker.com/r/bitnami/etcd and https://etcd.io/docs/v2.3/api/

What do you see instead?

I get HTTP-Status 404: 404 page not found

migruiz4 commented 3 weeks ago

Hi @jocafi,

Several things to consider about your use case:

As mentioned, by adding ETCD_ENABLE_V2=true to the etcd container you should be able to use the /v2 API:

~ $ curl http://etcd1:2379/v2/keys
{"action":"get","node":{"dir":true}}
jocafi commented 2 weeks ago

Many thanks @migruiz4 for the detailed explanation.

I replaced "ETCDCTL_API=2" by "ETCD_ENABLE_V2=true" and it worked. Now I do not get the error "404 page not found".

Please update the documentation at https://hub.docker.com/r/bitnami/etcd

My error comes from the information there. There is not mention about "ETCD_ENABLE_V2" and "ETCDCTL_API" seems no to work.

Feel free to close this ticket. Thanks again!