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

Set cluster DNS correctly in case of nodelocal dns cache #3879

Conversation

nysthee
Copy link
Contributor

@nysthee nysthee commented Dec 11, 2018

Set the cluster_dns appropriately in case nodelocaldns is enabled.
Follow up of #3861

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 11, 2018
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 11, 2018
@woopstar
Copy link
Member

There is one more bug:

https://github.com/kubernetes-sigs/kubespray/pull/3861/files#diff-f4a83b1729e5db14f3ab49f94d10e406R12

clusterIP should be accodingly to the dns mode:

{% if dns_mode in ['kubedns', 'coredns', 'coredns_dual'] %}
clusterIP: "{{ skydns_server }}"
{% elif dns_mode == 'dnsmasq_kubedns' %}
clusterIP: "{{ dnsmasq_dns_server }}"
{% elif dns_mode == 'manual' %}
clusterIP: "{{ manual_dns_server }}"
{% else %}

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 11, 2018
@woopstar
Copy link
Member

ci check this

@woopstar
Copy link
Member

Sorry, it should not be enabled by default yet. Can you switch back

@woopstar
Copy link
Member

Syntax error ;)

@nysthee nysthee force-pushed the bug/overwrite-cluster-dns-in-case-of-nodelocaldns branch from 9b77181 to 9e6ace6 Compare December 11, 2018 11:00
@woopstar
Copy link
Member

9e6ace6 got removed in your latest commit

@nysthee
Copy link
Contributor Author

nysthee commented Dec 11, 2018

Ok I am obviously doing something wrong with the if check in the vars. Any examples.
Regarding default. Weird it shows likes this but in git commit's its now showing this change is reverted.

@nysthee nysthee force-pushed the bug/overwrite-cluster-dns-in-case-of-nodelocaldns branch from 80a1492 to 65a4956 Compare December 11, 2018 17:48
@nysthee
Copy link
Contributor Author

nysthee commented Dec 11, 2018

ci check this

@nysthee nysthee force-pushed the bug/overwrite-cluster-dns-in-case-of-nodelocaldns branch from 65a4956 to 9f5758b Compare December 11, 2018 17:53
@nysthee
Copy link
Contributor Author

nysthee commented Dec 11, 2018

@woopstar can you check again please?

@woopstar
Copy link
Member

TASK [kubernetes/node : Write kubelet config file (kubeadm)] *******************
task path: /kargo-ci/kubernetes-sigs-kubespray/roles/kubernetes/node/tasks/main.yml:32
Tuesday 11 December 2018  18:32:51 +0000 (0:00:00.130)       0:23:59.514 ****** 
fatal: [k8s-39770198-133069148-3]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'nodelocaldns_ip' is undefined"}
fatal: [k8s-39770198-133069148-1]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'nodelocaldns_ip' is undefined"}
fatal: [k8s-39770198-133069148-2]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'nodelocaldns_ip' is undefined"}

@woopstar woopstar self-assigned this Dec 12, 2018
@woopstar
Copy link
Member

failed: [k8s-39836923-133487652-1] (item=nodelocaldns-config.yml) => {"attempts": 4, "changed": false, "item": {"changed": true, "checksum": "d8902c7843760e4e2c7c972dc72098df46933c47", "dest": "/etc/kubernetes/nodelocaldns-config.yml", "diff": [], "failed": false, "gid": 0, "group": "root", "invocation": {"module_args": {"_original_basename": "nodelocaldns-config.yml.j2", "attributes": null, "backup": false, "checksum": "d8902c7843760e4e2c7c972dc72098df46933c47", "content": null, "delimiter": null, "dest": "/etc/kubernetes/nodelocaldns-config.yml", "directory_mode": null, "follow": false, "force": true, "group": null, "local_follow": null, "mode": null, "owner": null, "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/home/travis/.ansible/tmp/ansible-tmp-1544622076.96-21926197592337/source", "unsafe_writes": null, "validate": null}}, "item": {"file": "nodelocaldns-config.yml", "name": "nodelocaldns", "type": "configmap"}, "md5sum": "57898d53b3518ee30dbad1b06b7a116e", "mode": "0644", "owner": "root", "secontext": "system_u:object_r:etc_t:s0", "size": 1078, "src": "/home/travis/.ansible/tmp/ansible-tmp-1544622076.96-21926197592337/source", "state": "file", "uid": 0}, "msg": "error running kubectl (/usr/local/bin/kubectl --namespace=kube-system apply --force --filename=/etc/kubernetes/nodelocaldns-config.yml) command (rc=1), out='', err='error: error parsing /etc/kubernetes/nodelocaldns-config.yml: error converting YAML to JSON: yaml: line 17: did not find expected key\n'"}

@woopstar
Copy link
Member

ping @nysthee

@nysthee nysthee force-pushed the bug/overwrite-cluster-dns-in-case-of-nodelocaldns branch from ea9794d to 012fe65 Compare January 7, 2019 21:49
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 7, 2019
@nysthee nysthee force-pushed the bug/overwrite-cluster-dns-in-case-of-nodelocaldns branch from 03212a5 to 40f568d Compare January 9, 2019 16:37
@woopstar
Copy link
Member

any news on this?

@nysthee
Copy link
Contributor Author

nysthee commented Jan 21, 2019 via email

@dannyk81
Copy link
Contributor

FYI, the following PR kubernetes/dns#286 is required to ensure the nodelocaldns network interface is created in a deterministic way.

This seems to affect only CoreOS based deployments at this point, but still better to to use this once it's released.

@dannyk81
Copy link
Contributor

dannyk81 commented Jan 24, 2019

@nysthee I've taken this PR for a spin and I think I can help with the config interpolation issues.

The following diff fixed the issue for me and allowed the proper rendering of the configuration file:

diff --git a/roles/kubernetes-apps/ansible/tasks/nodelocaldns.yml b/roles/kubernetes-apps/ansible/tasks/nodelocaldns.yml
index 1d50fa21..62801e71 100644
--- a/roles/kubernetes-apps/ansible/tasks/nodelocaldns.yml
+++ b/roles/kubernetes-apps/ansible/tasks/nodelocaldns.yml
@@ -2,13 +2,13 @@
 - name: Kubernetes Apps | set up necessary nodelocaldns parameters
   set_fact:
     clusterIP: >-
-      {% if dns_mode in ['kubedns', 'coredns', 'coredns_dual'] %}
-          "{{ skydns_server }}"
-      {% elif dns_mode == 'dnsmasq_kubedns' %}
-          "{{ dnsmasq_dns_server }}"
-      {% elif dns_mode == 'manual' %}
-          "{{ manual_dns_server }}"
-      {% endif %}
+      {%- if dns_mode in ['kubedns', 'coredns', 'coredns_dual'] -%}
+      {{ skydns_server }}
+      {%- elif dns_mode == 'dnsmasq_kubedns' -%}
+      {{ dnsmasq_dns_server }}
+      {%- elif dns_mode == 'manual' -%}
+      {{ manual_dns_server }}
+      {%- endif -%}
     secondaryclusterIP: "{{ skydns_server_secondary }}"


@@ -23,17 +23,17 @@
   register: nodelocaldns_manifests
   vars:
     forwardTarget: >-
-      {%- if secondaryclusterIP is defined and dns_mode == 'coredns_dual' %}
-          {{ clusterIP }} {{ secondaryclusterIP }}
+      {%- if secondaryclusterIP is defined and dns_mode == 'coredns_dual' -%}
+      {{ clusterIP }} {{ secondaryclusterIP }}
       {%- else -%}
-          {{ clusterIP }}
-      {%- endif %}
+      {{ clusterIP }}
+      {%- endif -%}
     upstreamForwardTarget: >-
-      {%- if resolvconf_mode == 'host_resolvconf' and upstream_dns_servers is defined and upstream_dns_servers|length > 0 %}
-        {{ upstream_dns_servers|join(' ') }}
-      {%- else %}
-        /etc/resolv.conf
-      {%- endif %}
+      {%- if resolvconf_mode == 'host_resolvconf' and upstream_dns_servers is defined and upstream_dns_servers|length > 0 -%}
+      {{ upstream_dns_servers|join(' ') }}
+      {%- else -%}
+      /etc/resolv.conf
+      {%- endif -%}
   when:
     - enable_nodelocaldns == True
     - inventory_hostname == groups['kube-master'] | first

I hope this can help move this PR a long, would ❤️ to see this merged as we desperately need this functionality.

@woopstar
Copy link
Member

@nysthee Can we move along ? :)

@nysthee nysthee force-pushed the bug/overwrite-cluster-dns-in-case-of-nodelocaldns branch from 40f568d to 1193d40 Compare January 28, 2019 20:09
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 28, 2019
@nysthee
Copy link
Contributor Author

nysthee commented Jan 28, 2019

Thanks a lot @dannyk81 !!! I integrated your fix and will continue. 🤞

@dannyk81
Copy link
Contributor

Thanks a lot @dannyk81 !!! I integrated your fix and will continue. 🤞

my pleasure! I've been doing some testing with this on a new cluster and so far things look really good 😄

@nysthee
Copy link
Contributor Author

nysthee commented Jan 28, 2019

@nysthee Can we move along ? :)

Yes please review the pr.

@woopstar
Copy link
Member

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nysthee, woopstar

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 Jan 29, 2019
@k8s-ci-robot k8s-ci-robot merged commit 68fd7e3 into kubernetes-sigs:master Jan 29, 2019
LuckySB pushed a commit to southbridgeio/kubespray that referenced this pull request Feb 17, 2019
…sigs#3879)

* Set cluster DNS correctly in case of nodelocal dns cache

* Pass in cluster_ip based on dns mode

* Disable nodelocaldns by default

* Fix syntax error

* Fix syntax issue

* Add nodelocadns ip to vars of node installation

* Change location of nodelocaldns_ip

* Try to remove newlines from jinja template

* Add debug for config file

* Move parameter logic outside of template

* Adapt templates after feedback

* Remove debugging
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/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.

5 participants