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

NodeLocalDNS operator #59

Merged
merged 10 commits into from
Jun 29, 2020
Merged

Conversation

somtochiama
Copy link
Member

@somtochiama somtochiama commented Jun 4, 2020

This is for the localnodedns operator

  • Boilerplate
  • Ensure it runs out of the cluster
  • Ensure it runs in-cluster
  • Golden file tests

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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 cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jun 4, 2020
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 4, 2020
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 4, 2020
@somtochiama somtochiama changed the title Local-node-dns-cache operator [WIP] Local-node-dns-cache operator Jun 4, 2020
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 4, 2020
@dholbach
Copy link
Member

dholbach commented Jun 5, 2020

/uncc
/cc @stealthybox

@k8s-ci-robot k8s-ci-robot requested review from stealthybox and removed request for dholbach June 5, 2020 07:46
@somtochiama somtochiama changed the title [WIP] Local-node-dns-cache operator Local-node-dns-cache operator Jun 11, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 11, 2020
@somtochiama
Copy link
Member Author

/assign @stealthybox

Copy link
Contributor

@rajansandeep rajansandeep left a comment

Choose a reason for hiding this comment

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

This is a really good start!
I have added some general queries in the review

o.Spec.DNSIP = "169.254.20.10"
}

if o.Spec.ClusterIP == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, we can try to fetch the Cluster IP from the kube-dns service.
kubectl get svc kube-dns -n kube-system -o jsonpath={.spec.clusterIP}

If we are unable to determine, then we can use the default value.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are similar functions in the coredns-operators for finding the ClusterIP and DNS Domain for a cluster. Maybe we could reuse it? Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we should start to create a shared library of these functions. I think probably in kubebuilder-declarative-pattern, because if e.g. the DNS team takes on ownership of this operator this repo may eventually end up pretty empty :-)

I think we can do this in a follow on PR, if you'd like. (You can add a TODO here so we don't forget)

COPY channels/ channels/
USER nonroot:nonroot

ENTRYPOINT ["/manager"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: newline

Copy link
Contributor

Choose a reason for hiding this comment

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

This file is auto-generated I believe - is this a bug in our kubebuilder plugin?

Copy link
Member Author

Choose a reason for hiding this comment

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

I doubt. I edit the file somewhere along the line. But I will generate a new operator and check, to be sure

@@ -0,0 +1 @@
package controllers
Copy link
Contributor

Choose a reason for hiding this comment

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

The test file seems empty. How are the golden test files generated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, That was a mistake

reload
loop
bind 169.254.20.10 10.96.0.10
forward . __PILLAR__CLUSTER__DNS__ {
Copy link
Contributor

Choose a reason for hiding this comment

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

The __PILLAR__CLUSTER__DNS__ placeholder values should probably be generated properly

Nvm, looks like the automatically updated Corefile values reflected only in the logs as per https://github.com/kubernetes/dns/blob/9903307a652efd77d5de40fdab3bfcd468fd1c74/cmd/node-cache/app/configmap.go#L67

reload
loop
bind 169.254.20.10 10.96.0.10
forward . __PILLAR__UPSTREAM__SERVERS__ {
Copy link
Contributor

Choose a reason for hiding this comment

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

The __PILLAR__UPSTREAM__SERVERS__ placeholder values should probably be generated properly

Nvm, looks like the automatically updated Corefile values reflected only in the logs as per https://github.com/kubernetes/dns/blob/9903307a652efd77d5de40fdab3bfcd468fd1c74/cmd/node-cache/app/configmap.go#L67

path: Corefile.base
---
apiVersion: app.k8s.io/v1beta1
kind: Application
Copy link
Contributor

Choose a reason for hiding this comment

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

Does node-local-cache need/use an application?

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually thought all addons needed an application. What qualifies an addon to use an application?

Copy link
Contributor

@justinsb justinsb Jun 19, 2020

Choose a reason for hiding this comment

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

We don't require an application.

I think it's a good idea to have one, it means we have a consistent object that groups the addon contents. Some UIs (for example GKE's) will display Applications nicely.

I know sig-apps is having some debates about Application, but until we have something better, I think we want something, so let's use an Application. If something better comes along, we can then easily replace Applications with new-thing!

Copy link
Contributor

Choose a reason for hiding this comment

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

Aah, makes sense. I should add one for the coredns operator then.

COPY channels/ channels/
USER nonroot:nonroot

ENTRYPOINT ["/manager"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is auto-generated I believe - is this a bug in our kubebuilder plugin?

path: Corefile.base
---
apiVersion: app.k8s.io/v1beta1
kind: Application
Copy link
Contributor

@justinsb justinsb Jun 19, 2020

Choose a reason for hiding this comment

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

We don't require an application.

I think it's a good idea to have one, it means we have a consistent object that groups the addon contents. Some UIs (for example GKE's) will display Applications nicely.

I know sig-apps is having some debates about Application, but until we have something better, I think we want something, so let's use an Application. If something better comes along, we can then easily replace Applications with new-thing!

operator: "Exists"
containers:
- name: node-cache
image: k8s.gcr.io/k8s-dns-node-cache:1.15.13
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to be annoying feedback, so I'm sorry in advance...

Should we name it "LocalNodeDNS" or "NodeLocalDNS" or "DNSNodeCache"? We want to be consistent with other names.

I've always personally called in NodeLocalDNS. We should probably pick whatever name is most commonly used (with luck, that will be LocalNodeDNS!).

The names inside the code don't matter as much as the CRD name - it's the CRD name that users will interact with.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the "official" name is NodeLocalDNS (I'm using https://github.com/kubernetes/kubernetes/tree/release-1.18/cluster/addons/dns/nodelocaldns as reference), so I think we should follow that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think NodeLocalDNS is the one that is most commonly use. Should I manually change all occurrences of the name(I think this is error-prone) or generate a new operator with the new name.

o := object.(*api.LocalNodeDNS)
kubeProxyMode, err := findKubeProxyMode(ctx, mgr.GetClient())
if err != nil {
fmt.Println("Error determining kube-proxy mode: Defaulting to iptables")
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, use logging functions over stdout / stderr. So either klog.Warningf("error determining kube-proxy mode...) or log.Log("error determining kube-proxy mode....

You also should include the error, otherwise it's really hard for someone that sees the log to know what went wrong; for example:

klog.Warningf("error determining kube-proxy mode, defaulting to iptables: %v", err)

I think log has a dedicated helper:

log.Error(err, "error determining kube-proxy mode, defaulting to iptables")

Logging in kubernetes is generally in flux right now; we're moving to structured logging (log) but doing so by adding it to klog (I think) https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/1602-structured-logging

o.Spec.DNSIP = "169.254.20.10"
}

if o.Spec.ClusterIP == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we should start to create a shared library of these functions. I think probably in kubebuilder-declarative-pattern, because if e.g. the DNS team takes on ownership of this operator this repo may eventually end up pretty empty :-)

I think we can do this in a follow on PR, if you'd like. (You can add a TODO here so we don't forget)

@justinsb
Copy link
Contributor

This looks good @somtochiama (and thanks @rajansandeep for the reviews!).

I apologize for this, but we should figure out what name we want to use. I think the most common terms were LocalNodeDNS or LocalNodeDNSCache based on some basic google searching; but if we can justify the existing name then that's fine too!

@somtochiama somtochiama changed the title Local-node-dns-cache operator NodeLocalDNS operator Jun 28, 2020
@justinsb
Copy link
Contributor

Thanks for renaming - for other tweaks (e.g. sharing functions that you've now put into the kubebuilder-declarative-pattern library :-) ) I think we can merge + iterate

/aprpove
/lgtm

@justinsb
Copy link
Contributor

/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 29, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb, SomtochiAma

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 29, 2020
@k8s-ci-robot k8s-ci-robot merged commit 7353066 into kubernetes-sigs:master Jun 29, 2020
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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants