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

Rewrite services being injected to k8s to be lowercase because K8S DNS implementation sucks #110

Closed
ejmarten opened this issue Jun 26, 2019 · 3 comments · Fixed by #149
Closed
Labels
area/sync Related to catalog sync type/bug Something isn't working

Comments

@ejmarten
Copy link

I have my external consul doing a two way sync with my k8s (v1.15.0) service registry/coreDNS,
On inspecting the log for the consul-sync-catalog pod, I see an entry like the following for each service registered in consul with uppercase characters.

I jumped in the external-dns channel in k8s slack, and was told that kubernetes does not support uppercase names.

Well crud. Now I have to either write a wrapper for k8s-consul, create a docker image with a non-standard coredns binary that supports the rewrite plugin, or hotfix hundreds of consul services...

Guess which one I refuse to do?

2019-06-26T19:55:09.033Z [WARN ] to-k8s/sink: error creating service: name=consul-ORDER-API error="Service "consul-ORDER-API" is invalid: [metadata.name: Invalid value: "consul-ORDER-API": a DNS-1035 label must consist of lower case alphanumeric characters or '-', st
art with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is 'a-z?'), spec.externalName: Invalid value: "ORDER-API.service.cluster.local": a DNS-1123 subdomain must consist
of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is 'a-z0-9?(.a-z0-9?)*')]"

I'm working on a workaround, but this is most definitely a bug, I'll share my results if I figure it out.

image

@lkysow
Copy link
Member

lkysow commented Jun 27, 2019

I think we'll have to register them as lower case then. Note that in Consul registering services is case sensitive (you can have two services foo and FOO hashicorp/consul#5707) but then most of the endpoints like consul DNS will only return one of them.

@lkysow lkysow added the type/bug Something isn't working label Jun 27, 2019
@ejmarten
Copy link
Author

This might work. I'll test and submit a PR if it does.

[root@dev]# grep -rl ToLower catalog/from-consul/source.go
catalog/from-consul/source.go
[root@dev]# grep -rn ToLower catalog/from-consul/source.go
72: services[s.Prefix+name] = fmt.Sprintf("%s.service.%s", strings.ToLower("name"), strings.ToLower("s.Domain"))

@ejmarten
Copy link
Author

ejmarten commented Jul 3, 2019

That compiled and seemed to work, but running it in a pod logs:
"Bad substitution"

...

@lkysow lkysow added the area/sync Related to catalog sync label Sep 18, 2019
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.

2 participants