wurstmeister / kafka-docker

Dockerfile for Apache Kafka
http://wurstmeister.github.io/kafka-docker/
Apache License 2.0
6.89k stars 2.74k forks source link

Invalid value tcp://10.0.35.234:9092 for configuration port: Not a number of type INT #122

Open aliakhtar opened 7 years ago

aliakhtar commented 7 years ago

I'm following http://www.defuze.org/archives/351-running-a-zookeeper-and-kafka-cluster-with-kubernetes-on-aws.html in order to deploy Kafka on Kubernetes.

This is what my configuration looks like:

containers:
        - name: kafka
          image: wurstmeister/kafka
          ports:
            - containerPort: 9092
          env:
            - name: KAFKA_ADVERTISED_PORT
              value: "9092"
            - name: KAFKA_ADVERTISED_HOST_NAME
              value: kafka
            - name: KAFKA_ZOOKEEPER_CONNECT
              value: zk1:2181,zk2:2181,zk3:2181
            - name: KAFKA_CREATE_TOPICS
              value: test:1:1

The hostname kafka is resolved internally to the IP of the kafka service, which in this case is 10.0.35.234.

When I run this, the container crashes. These are the logs I see:

awk: cmd. line:1: Unexpected token
creating topics: test:1:1
[2016-09-15 17:00:09,293] FATAL  (kafka.Kafka$)
org.apache.kafka.common.config.ConfigException: Invalid value tcp://10.0.35.234:9092 for configuration port: Not a number of type INT
    at org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:670)
    at org.apache.kafka.common.config.ConfigDef.parse(ConfigDef.java:418)
    at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:55)
    at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:759)
    at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:743)
    at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:740)
    at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:28)
    at kafka.Kafka$.main(Kafka.scala:58)
    at kafka.Kafka.main(Kafka.scala)

After this, it fails while creating the topic because replication factor = 1 and brokers = 0.

Why is it using tcp://10.0.35.234:9092 as the value of the port?

emosbaugh commented 7 years ago

after some digging around i believe this has to do with kubernetes writing an env var KAFKA_... and then getting overwritten in the config file with the following code in start-kafka.sh. i would try renaming things other than kafka.

for VAR in `env`
do
  if [[ $VAR =~ ^KAFKA_ && ! $VAR =~ ^KAFKA_HOME ]]; then
    kafka_name=`echo "$VAR" | sed -r "s/KAFKA_(.*)=.*/\1/g" | tr '[:upper:]' '[:lower:]' | tr _ .`
    env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"`
    if egrep -q "(^|^#)$kafka_name=" $KAFKA_HOME/config/server.properties; then
        sed -r -i "s@(^|^#)($kafka_name)=(.*)@\2=${!env_var}@g" $KAFKA_HOME/config/server.properties #note that no config values may contain an '@' char
    else
        echo "$kafka_name=${!env_var}" >> $KAFKA_HOME/config/server.properties
    fi
  fi
done
it-svit commented 7 years ago

Seems that if you have service called kafka, kubernetes creates environment variable called KAFKA_PORT="tcp://x.x.x.x:9092"

it-svit commented 7 years ago

Yes, when I changed a name of service from 'kafka' to 'kafka-cluster' it stopped crashing.

alexyarochkin commented 7 years ago

I added in my docker-compose file (i'm using kompose up to deploy my cluster). And it looks like solved the issue. environment: KAFKA_PORT: 9092

Or in *-deployment.yaml try to add:

    - name: KAFKA_PORT
        value: "9092"
spicysomtam commented 6 years ago

I hit this issue too. In Openshift that uses kubernetes. My openshift service was renamed to kafkaa and it solved the problem.

abitrolly commented 6 years ago

Same here. Had to rename kubernetes service from kafka to something else.

timm088 commented 6 years ago

You can use unset KAFKA_PORT as per the detail listed here https://github.com/confluentinc/cp-docker-images/issues/388 then you wont have the issue (and wont need to rename the service)

Unfortunately, until start scripts stop failure on the setting on KAFKA_PORT and/or kafka startup stops recognising this as an ENVVAR it should use at startup, workaround will have to remain in place

abhishekkarigar commented 5 years ago

add this to environment in docker-compose .yml KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE

meetchandan commented 4 years ago

can anyone please share the docker-compose for kafka? Even after renaming to kafka-cluster or kafkaa and then running on kubernetes, I am getting the same error shared above.

org.apache.kafka.common.config.ConfigException: Invalid value tcp://10.106.136.1:9092 for configuration port: Not a number of type INT @spicysomtam

meetchandan commented 4 years ago

never mind, I solved it by adding KAFKA_PORT env variable

lauvinson commented 4 years ago

是的,当我将服务名称从“ kafka”更改为“ kafka-cluster”时,它不再崩溃。

great

kapekost commented 3 years ago

for eks.yaml files that env var can't be INT, but worked by setting the

RPalejiya commented 3 years ago

Seems that if you have service called kafka, kubernetes creates environment variable called KAFKA_PORT="tcp://x.x.x.x:9092"

This is fix for me too.