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

Two services with the same name but in different namespaces in k8s are mapped to a single service in consul #139

Closed
ishustava opened this issue Sep 23, 2019 · 3 comments · Fixed by #160
Assignees
Labels
area/sync Related to catalog sync type/bug Something isn't working

Comments

@ishustava
Copy link
Contributor

consul-helm chart version: branch master
Deployed to AWS EKS

Issue

If I create two services with the same name but in different namespaces in k8s, consul registers them as two instances under the same name.

For example, I have an ngnix service in the default and foo namespaces.
Screen Shot 2019-09-23 at 10 27 17 AM

Screen Shot 2019-09-23 at 10 30 05 AM

Consul would then load balance between those two services if I use consul as DNS.

kubectl port-forward consul-consul-server-0 5000:8600 &
$ dig -p 5000 @127.0.0.1 +tcp nginx.service.consul

; <<>> DiG 9.10.6 <<>> -p 5000 @127.0.0.1 +tcp nginx.service.consul
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47981
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 3
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;nginx.service.consul.		IN	A

;; ANSWER SECTION:
nginx.service.consul.	0	IN	CNAME	ac0771705dcc411e997eb02853705779-27038583.us-east-2.elb.amazonaws.com.

;; ADDITIONAL SECTION:
nginx.service.consul.	0	IN	TXT	"external-source=kubernetes"
nginx.service.consul.	0	IN	TXT	"external-source=kubernetes"

;; Query time: 326 msec
;; SERVER: 127.0.0.1#5000(127.0.0.1)
;; WHEN: Mon Sep 23 10:38:13 PDT 2019
;; MSG SIZE  rcvd: 210


~:
$ dig -p 5000 @127.0.0.1 +tcp nginx.service.consul

; <<>> DiG 9.10.6 <<>> -p 5000 @127.0.0.1 +tcp nginx.service.consul
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2446
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 3
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;nginx.service.consul.		IN	A

;; ANSWER SECTION:
nginx.service.consul.	0	IN	CNAME	a3f17333edcaf11e997eb02853705779-1573697906.us-east-2.elb.amazonaws.com.

;; ADDITIONAL SECTION:
nginx.service.consul.	0	IN	TXT	"external-source=kubernetes"
nginx.service.consul.	0	IN	TXT	"external-source=kubernetes"

;; Query time: 315 msec
;; SERVER: 127.0.0.1#5000(127.0.0.1)
;; WHEN: Mon Sep 23 10:38:15 PDT 2019
;; MSG SIZE  rcvd: 212

Desired behavior

Sync should disambiguate between services deployed to different namespaces.

@ishustava ishustava added type/bug Something isn't working area/sync Related to catalog sync labels Sep 23, 2019
@filintod
Copy link

Yes this is true. I try to mitigate it by adding a tag for namespace so at least I can target it differently (kind of weird to put the namespace before the service name though) but don't see how this can get resolved as consul does not have a knowledge of namespaces unless it is added to consul code somehow.

@jasonliu747
Copy link

jasonliu747 commented Oct 22, 2019

@lkysow Hey Luke, I think it really is a bug if consul officially supported k8s. The only workaround so far is by combining namespace and service name. Dose consul plan to take a look of this issue?

@lkysow
Copy link
Member

lkysow commented Oct 23, 2019

Hi @jasonliu747 yes it's on our roadmap to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sync Related to catalog sync type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants