8000 Allow custom cluster domain in controller components by arminbuerkle · Pull Request #2950 · linkerd/linkerd2 · GitHub
[go: up one dir, main page]

Skip to content

Allow custom cluster domain in controller components - #2950

Merged
ihcsim merged 7 commits into
linkerd:masterfrom
alfatraining:add-cluster-domain-to-controller
Jul 23, 2019
Merged

ihcsim merged 7 commits into
linkerd:masterfrom
alfatraining:add-cluster-domain-to-controller

Conversation

@arminbuerkle
Copy link
Copy Markdown
Contributor

Splits #2930 into smaller components: Part 1, controller components.

While it's still a lot of changes, most of them are auto generated (proto, .golden) or updating tests so a different domain than cluster.local is used.


I added the cluster.local default domain to the cli/cmd/ pkg, so the .golden files will directly add it to their global configs. Otherwise they'd get initialised with an empty string: {..., "clusterDomain":""}

@arminbuerkle arminbuerkle changed the title Add cluster domain to controller Allow custom cluster domain in controller components Jun 17, 2019
@arminbuerkle
arminbuerkle force-pushed the add-cluster-domain-to-controller branch from f8af8c4 to d30e940 Compare June 17, 2019 13:05
@arminbuerkle
arminbuerkle force-pushed the add-cluster-domain-to-controller branch 2 times, most recently from f874004 to dc1c949 Compare June 24, 2019 20:29
@grampelberg
grampelberg requested a review from ihcsim July 1, 2019 21:35
@ihcsim
ihcsim commented Jul 15, 2019
Copy link
Copy Markdown
Contributor

@arminbuerkle Apologies for unable to get to this sooner. I will start reviewing this today. Meanwhile, can you rebase this branch with master, and resolve the outstanding conflicts? Thanks.

"trust.domain",
false,
"service-name.service-ns.svc.cluster.local",
"service-name.service-ns.svc.mycluster.local",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, this doesn't do anything, right? Consider reverting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeEndpointTranslator calls newEndpointTranslator which then uses GetServiceAndPort to split the domain name into a service and port.

In GetServiceAndPort the domain was hard coded to always use cluster.local which shouldn't be the case and was changed in e67de3b

Comment thread controller/cmd/public-api/main.go Resolved
Comment thread controller/api/public/grpc_server.go Resolved
Comment thread controller/api/public/http_server.go Resolved
Comment thread web/main.go Resolved
Update golden templates

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
The change relaxes the constrains of an authority requiring a
`svc.cluster.local` suffix to only require `svc` as third part.

A unit test could be added though the destination/server and endpoint
watcher already test this behaviour.

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
@arminbuerkle
arminbuerkle force-pushed the add-cluster-domain-to-controller branch from dc1c949 to f0d0ddc Compare July 22, 2019 07:28
@arminbuerkle arminbuerkle left a comment
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long to take get back to this. I'll try to schedule some time to add your suggestions.

"trust.domain",
false,
"service-name.service-ns.svc.cluster.local",
"service-name.service-ns.svc.mycluster.local",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeEndpointTranslator calls newEndpointTranslator which then uses GetServiceAndPort to split the domain name into a service and port.

In GetServiceAndPort the domain was hard coded to always use cluster.local which shouldn't be the case and was changed in e67de3b

Comment thread controller/cmd/public-api/main.go Resolved
Comment thread web/main.go Resolved
Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
@arminbuerkle
arminbuerkle force-pushed the add-cluster-domain-to-controller branch from 0b8dcd5 to fe3788e Compare July 22, 2019 10:55
@ihcsim ihcsim left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes! I did some testing with linkerd upgrade, and noticed that the cluster domain value in the linkerd-config config map turned out as an empty string, if the upgrade was performed on an older version of Linkerd.

To reproduce,

$ linkerd version --client
Client version: stable-2.4.0

$ linkerd install | kubectl apply -f -

$ kubectl -n linkerd get cm linkerd-config -ojsonpath="{.data.global}" | jq .clusterDomain
null # this is correct because the stable-2.4.0 release doesn't support this configuration yet 

$ bin/linkerd version --client
Client version: git-9287eb27

$ bin/linkerd upgrade | kubectl apply -f -

$ kubectl -n linkerd get cm linkerd-config -ojsonpath="{.data.global}" | jq .clusterDomain
"" # this should be cluster.local. Otherwise, all subsequent requests will be using the empty string as the cluster domain

We need to upgrade the upgrade code to account for this. So something like this should work:

diff --git a/cli/cmd/upgrade.go b/cli/cmd/upgrade.go
index 87c544fb..26a5369c 100644
--- a/cli/cmd/upgrade.go
+++ b/cli/cmd/upgrade.go
@@ -219,6 +219,9 @@ func (options *upgradeOptions) validateAndBuild(stage string, k kubernetes.Inter
 	}
 	configs.GetInstall().Flags = options.recordedFlags
 	configs.GetGlobal().OmitWebhookSideEffects = options.omitWebhookSideEffects
+	if configs.GetGlobal().GetClusterDomain() == "" {
+		configs.GetGlobal().ClusterDomain = defaultClusterDomain
+	}
 
 	var identity *installIdentityValues
 	idctx := configs.GetGlobal().GetIdentityContext()

With this change, you should see the linkerd-config config map gets updated correctly:

$ kubectl -n linkerd get cm linkerd-config -ojsonpath="{.data.global}" | jq .clusterDomain
"cluster.local"

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
@arminbuerkle
Copy link
Copy Markdown
Contributor Author

Thank you @ihcsim for testing. Your suggestion indeed fixed that.

@ihcsim ihcsim left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! Thanks again 👍!

@ihcsim
ihcsim merged commit 010efac into linkerd:master Jul 23, 2019
adleong pushed a commit that referenced this pull request Aug 7, 2019
Continue of #2950.

I decided to check for the `clusterDomain` in the config map in web server main for the same reasons as as pointed out here #3113 (comment)

It decouples the server implementations from the config.

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
< 7128 div data-view-component="true" class="tmp-mt-3 flash flash-warn"> Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0