Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headless svc forwarding behaviour changed for sts with single pod #133

Closed
onmomo opened this issue Jul 6, 2020 · 4 comments
Closed

headless svc forwarding behaviour changed for sts with single pod #133

onmomo opened this issue Jul 6, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@onmomo
Copy link

onmomo commented Jul 6, 2020

We noticed that kubefwd 14.x behaves differently for forwarding headless services forwarding to a single sts container

apiVersion: v1
kind: Service
metadata:
  name: kafka-headless-svc
spec:
  ports:
    - port: 9092
      name: broker
  clusterIP: None
  selector:
    app: kafka-sts
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: kafka-sts
  labels:
    app: kafka-sts
spec:
  serviceName: kafka-headless-svc
  podManagementPolicy: OrderedReady
  replicas: 1
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: kafka-sts
    spec:
      containers:
      - name: kafka-sts
        image: "confluentinc/cp-kafka:5.0.1"
        imagePullPolicy: "IfNotPresent"
        ports:
        - containerPort: 9092
          name: kafka        
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: HOST_IP
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
        - name: "KAFKA_LISTENER_SECURITY_PROTOCOL_MAP"
          value: "PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT"    
        command:
        - sh
        - -exc
        - |
          export KAFKA_BROKER_ID=${HOSTNAME##*-} 
          export KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka-sts-${HOSTNAME##*-}.kafka-headless-svc:9092,EXTERNAL://${HOST_IP}:$((31090 + ${KAFKA_BROKER_ID})) && \
          exec /etc/confluent/docker/run          

kubefwd 1.13.1

INFO[13:29:28] Forwarding: kafka-headless-svc:9092 to pod kafka-sts-0:9092 
INFO[13:29:28] Forwarding: kafka-sts-0.kafka-headless-svc:9092 to pod kafka-sts-0:9092 

kubefwd 14.2

INFO[14:06:42] Port-Forward: kafka-headless-svc:9092 to pod kafka-sts-0:9092 
INFO[14:06:42] Port-Forward: kafka-headless-svc:9092 to pod kafka-sts-0:9092 

If the kafka-sts is scaled to 2 with 14.2, it will result in:

INFO[14:06:24] Port-Forward: kafka-headless-svc:9092 to pod kafka-sts-0:9092 
INFO[14:06:24] Port-Forward: kafka-sts-0.kafka-headless-svc:9092 to pod kafka-sts-0:9092 
INFO[14:06:24] Port-Forward: kafka-sts-1.kafka-headless-svc:9092 to pod kafka-sts-1:9092 

in 14.2, this is probably caused because of this check https://github.com/txn2/kubefwd/blob/1.14.2/cmd/kubefwd/services/services.go#L431
and this statement: https://github.com/txn2/kubefwd/blob/1.14.2/cmd/kubefwd/services/services.go#L458

Our apps are configured to use kafka-sts-0.kafka-headless-svc:9092 and therefore fail with 14.2.
We should be able to fix it while using kafka-headless-svc:9092 instead but we are wondering if this is the new way to go or an issue?

@cjimti
Copy link
Member

cjimti commented Jul 6, 2020

This is a bug introduced in 1.14. The last few contributions have caused some issues I need to unwind. I am scheduling some time to work on this in the next two weeks.

Thank you for raising this issue.

@calmkart
Copy link
Contributor

calmkart commented Jul 7, 2020

fix in #134
@onmomo

cjimti added a commit that referenced this issue Jul 7, 2020
FIX: fix a bug for issue #133 (when sts scale to replicas 1)
@onmomo
Copy link
Author

onmomo commented Jul 7, 2020

@calmkart @cjimti thanks a lot and keep it up!

@cjimti
Copy link
Member

cjimti commented Oct 27, 2020

Fixed in 1.17.2

@cjimti cjimti closed this as completed Oct 27, 2020
D3-LucaPiombino pushed a commit to CodeCoil/kubefwd that referenced this issue Jun 13, 2024
FIX: fix a bug for issue txn2#133 (when sts scale to replicas 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants