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

write HostAliases to hosts file #45148

Merged
merged 1 commit into from
May 1, 2017

Conversation

evie404
Copy link
Contributor

@evie404 evie404 commented Apr 29, 2017

What this PR does / why we need it: using the PodSpec's HostAliases, we write entries into the Kubernetes-managed hosts file.

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

Special notes for your reviewer:
Previous PRs in this series:

Release note:

Enable `Pod.spec.hostAliases` to add entries into the Kubernetes-managed hosts file.

@thockin @yujuhong

Thanks for reviewing!

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 29, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @rickypai. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 29, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Apr 29, 2017
123.45.67.89 baz
456.78.90.123 park
456.78.90.123 doo
456.78.90.123 boo
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we add validation that there are not duplicate hostnames in case someone adds:

[]v1.HostAlias{
	{IP: "123.45.67.89", Hostnames: []string{"foo", "bar"}},
	{IP: "456.78.90.123", Hostnames: []string{"foo", "bar"}},
}

which results in

123.45.67.89	foo
123.45.67.89	bar
456.78.90.123	foo
456.78.90.123	bar

Choose a reason for hiding this comment

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

And shouldn't we validate for proper IPv4 IPs? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think dups is fine - it's your own fault.

// write each IP/hostname pair as an entry into hosts file
for _, hostAlias := range hostAliases {
for _, hostname := range hostAlias.Hostnames {
buffer.WriteString(fmt.Sprintf("%s\t%s\n", hostAlias.IP, hostname))
Copy link
Member

Choose a reason for hiding this comment

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

Comment that this was previously validated to be a valid IP address and hostname?

123.45.67.89 baz
456.78.90.123 park
456.78.90.123 doo
456.78.90.123 boo
Copy link
Member

Choose a reason for hiding this comment

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

I think dups is fine - it's your own fault.

@thockin
Copy link
Member

thockin commented May 1, 2017

@k8s-bot ok to test
/approve

@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 May 1, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 1, 2017
@feiskyer
Copy link
Member

feiskyer commented May 1, 2017

LGTM

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feiskyer, rickypai, thockin

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
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented May 1, 2017

@rickypai: The following test(s) failed:

Test name Commit Details Rerun command
Jenkins unit/integration 407fe8b link @k8s-bot unit test this

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 45110, 45148)

@k8s-github-robot k8s-github-robot merged commit 08606b5 into kubernetes:master May 1, 2017
@yujuhong
Copy link
Contributor

yujuhong commented May 1, 2017

@rickypai can you also add a node e2e test for this feature? Thanks.

@evie404
Copy link
Contributor Author

evie404 commented May 1, 2017 via email

@yujuhong
Copy link
Contributor

yujuhong commented May 1, 2017

@rickypai, we usually patch the release branches for bugs or security issues. Your PRs added a new feature (w/ API changes), so I'd advise against back porting this.

/cc @enisoc, the 1.6 patch manager(?)
)

@evie404 evie404 deleted the rpai/use_host_aliases branch May 2, 2017 17:39
@evie404
Copy link
Contributor Author

evie404 commented May 2, 2017

No problem. I can understand the release complexity because it involves an API addition, although users won't be affected unless they actually take advantage of the new field. If they do, it's likely because they need to address #43632 #44473 or the like.

I can also just follow the build guide into doing an internal release for ourselves until 1.7 lands. I'll write a node e2e test per recommendation in #43632

@thockin
Copy link
Member

thockin commented Jun 6, 2017

@rickypai we need tomake sure we get docs for this for 1.7, too.

@kubernetes/sig-docs-maintainers

@evie404
Copy link
Contributor Author

evie404 commented Jun 7, 2017

re: documentation, i'm thinking either adding notes about HostAliases in https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ or as a separate page under "Services, Load Balancing, and Networking"

@devin-donnelly
Copy link

devin-donnelly commented Jun 7, 2017 via email

k8s-github-robot pushed a commit that referenced this pull request Jun 7, 2017
Automatic merge from submit-queue (batch tested with PRs 43005, 46660, 46385, 46991, 47103)

add e2e node test for Pod hostAliases feature

**What this PR does / why we need it**: adds node e2e test for #45148 

tests requested in #43632 (comment)

**Release note**:
```release-note
NONE
```

@yujuhong @thockin
@evie404
Copy link
Contributor Author

evie404 commented Jun 14, 2017

i went with a separate page to give room for more details. kubernetes/website#4080

@chenopis
Copy link

@rickypai That works for me.

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 Denotes a PR that will be considered when it comes time to generate release notes. 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.

Provide a way to add entries to /etc/hosts