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

kubeadm: Create dnsIP by selecting the tenth IP from k8s svc CIDR #51990

Merged
merged 1 commit into from Nov 16, 2017

Conversation

madhukar32
Copy link
Contributor

@madhukar32 madhukar32 commented Sep 6, 2017

What this PR does / why we need it:

Creates dnsIP by selecting the ninth IP from k8s svc cluster IP, instead of appending 0 to the k8s svcIP string.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #51997

Special notes for your reviewer:
This is helpful when we have service cluster range CIDR as 10.87.116.64/26 (for example), previously this would have failed while parsing the dnsIP, as we used to append a 0 to the k8s svc clusterIP string. This will get the same dnsIP 10.96.0.10 for very widely used service cluster range CIDR 10.96.0.0/12

Release note:

None

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 6, 2017
@k8s-github-robot k8s-github-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Sep 6, 2017
@madhukar32
Copy link
Contributor Author

/assign @krousey

}
dnsIP := svcIP.To4()
dnsIP[3] += 9
Copy link
Member

Choose a reason for hiding this comment

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

Why adding 9?

Copy link
Contributor Author

@madhukar32 madhukar32 Sep 6, 2017

Choose a reason for hiding this comment

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

Just to stick with dnsIP which is being assigned today.

Assuming that svcIP is 10.96.0.1 with the above logic the user will get dnsIP as 10.96.0.10. This is the same IP which a k8s user is getting today. Open for any other suggestion

Copy link
Member

Choose a reason for hiding this comment

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

@madhukar32 Well, I think this will result in a conflict. We cannot guarantee 10.96.0.10 has been reserved only for dnsIP. It could be a svcIP, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dixudx: Ok I am new to k8s so I might be completely wrong, please correct me.

We create this dnsIP in the above code(which is the svcIP for kube-dns svc) and then go and create the actual service here. After kube-dns svc is created it will be actually reserved for kube-dns svc only. Until and unless it is forcefully deleted. So we are pretty much reserving an IP today also isn't it?

Copy link
Member

Choose a reason for hiding this comment

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

@madhukar32 Also this value will exceed 255, right? What's more, dnsIP consumes ip resources from service ip pool, which means we can only create half of services as before. This may cause big trouble for large cluster upgrading.

I think we'd better avoid such hard-coded way.

Copy link
Contributor Author

@madhukar32 madhukar32 Sep 6, 2017

Choose a reason for hiding this comment

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

@dixudx: On the value, I have cross verified that it will not exceed 255 https://play.golang.org/p/KlUAsNrzFJhttps://play.golang.org/p/KlUAsNrzFJ
Just to clarify here, when I say dnsIP its the service clusterIP of kube-dns svc and it is suppose to be from service ip pool.

Copy link
Contributor

Choose a reason for hiding this comment

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

The 9th ip will only have the same behaviour when the service ip is .1 (but is most consistent this solution than the one we have now)

Copy link
Member

Choose a reason for hiding this comment

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

please use "k8s.io/kubernetes/pkg/registry/core/service/ipallocator".GetIndexedIP(svcSubnet, 10) or similar for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@luxas: Thanks! Thats a good idea, will update the commit

@luxas
Copy link
Member

luxas commented Sep 6, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 6, 2017
@kevin-wangzefeng
Copy link
Member

/retest

@madhukar32 madhukar32 changed the title kubeadm: Create dnsIP by selecting the ninth IP from k8s svc clusterIP kubeadm: Create dnsIP by selecting the tenth IP from k8s svc CIDR Sep 7, 2017
@madhukar32
Copy link
Contributor Author

/retest

@madhukar32
Copy link
Contributor Author

@kubernetes/sig-cluster-lifecycle-pr-reviews /assign @luxas

@k8s-ci-robot k8s-ci-robot added the sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. label Sep 8, 2017
@k8s-ci-robot
Copy link
Contributor

@madhukar32: Reiterating the mentions to trigger a notification:
@kubernetes/sig-cluster-lifecycle-pr-reviews.

In response to this:

@kubernetes/sig-cluster-lifecycle-pr-reviews /assign @luxas

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@luxas luxas left a comment

Choose a reason for hiding this comment

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

Please add --service-subnet to the kubeadm phase addons kube-dns flag with this change...

@madhukar32
Copy link
Contributor Author

@luxas: 👍 Have added --service-cidr flag for kubeadm phase addons kube-dns. Similar to the one we have for kubeadm init

@madhukar32
Copy link
Contributor Author

/retest

@madhukar32 madhukar32 force-pushed the get_dns_ip branch 3 times, most recently from 0f5714e to 54c882f Compare September 13, 2017 03:00
@madhukar32
Copy link
Contributor Author

/retest

@madhukar32
Copy link
Contributor Author

@luxas: Could you please review this once again. Have added --service-cidr flag for kubeadm phase addons kube-dns

@mattymo
Copy link

mattymo commented Sep 14, 2017

@madhukar32 Thanks for this PR! It will make the mandatory kubedns useful when using a custom service subnet.

@madhukar32
Copy link
Contributor Author

@luxas : Could you please review this

@madhukar32
Copy link
Contributor Author

CC @kubernetes/sig-cluster-lifecycle-pr-reviews

@k8s-ci-robot
Copy link
Contributor

@madhukar32: Reiterating the mentions to trigger a notification:
@kubernetes/sig-cluster-lifecycle-pr-reviews

In response to this:

CC @kubernetes/sig-cluster-lifecycle-pr-reviews

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 18, 2017
@luxas
Copy link
Member

luxas commented Nov 8, 2017

@madhukar32 If you rebase this PR I can look at it and approve it

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 14, 2017
@madhukar32
Copy link
Contributor Author

@luxas have rebased this PR. Could you please review now

Copy link
Member

@luxas luxas left a comment

Choose a reason for hiding this comment

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

Thanks @madhukar32!
This basically looks good to me, but please fix the small nit and add an unit test while you do improve the code here :)

func getDNSIP(client clientset.Interface) (net.IP, error) {
k8ssvc, err := client.CoreV1().Services(metav1.NamespaceDefault).Get("kubernetes", metav1.GetOptions{})
// getDNSIP returns a dnsIP, which is 10th IP in svcSubnet CIDR range
func getDNSIP(cfg *kubeadmapi.MasterConfiguration) (net.IP, error) {
Copy link
Member

Choose a reason for hiding this comment

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

while you're here, please add an unit test for this function

Copy link
Member

Choose a reason for hiding this comment

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

and a nit: I'd prefer if you only passed serviceSubnet string here, not the full cfg object

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 15, 2017
@madhukar32
Copy link
Contributor Author

@luxas thanks for reviewing, have taken care of your comments. Could you please check now?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2017
Copy link
Member

@luxas luxas left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve no-issue

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: luxas, madhukar32

Associated issue: 51997

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 15, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 55798, 49579, 54862, 55188, 51990). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 4060d23 into kubernetes:master Nov 16, 2017
@madhukar32 madhukar32 deleted the get_dns_ip branch November 21, 2017 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubeadm init fails if service CIDR range ends with a non-zero IP
9 participants