74 lines
2.1 KiB
YAML
74 lines
2.1 KiB
YAML
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
---
|
|
- name: Enable recursive queries for coredns
|
|
become: false
|
|
shell: |
|
|
tee > /tmp/coredns_configmap.yaml <<EOF
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: coredns
|
|
namespace: kube-system
|
|
data:
|
|
Corefile: |
|
|
.:53 {
|
|
errors
|
|
health {
|
|
lameduck 5s
|
|
}
|
|
header {
|
|
response set ra
|
|
}
|
|
ready
|
|
kubernetes cluster.local in-addr.arpa ip6.arpa {
|
|
pods insecure
|
|
fallthrough in-addr.arpa ip6.arpa
|
|
ttl 30
|
|
}
|
|
prometheus :9153
|
|
forward . 8.8.8.8 {
|
|
max_concurrent 1000
|
|
}
|
|
cache 30
|
|
loop
|
|
reload
|
|
loadbalance
|
|
}
|
|
EOF
|
|
kubectl apply -f /tmp/coredns_configmap.yaml
|
|
kubectl rollout restart -n kube-system deployment/coredns
|
|
kubectl rollout status -n kube-system deployment/coredns
|
|
when: inventory_hostname in (groups['primary'] | default([]))
|
|
|
|
- name: Give coredns time to restart
|
|
pause:
|
|
seconds: 30
|
|
when: inventory_hostname in (groups['primary'] | default([]))
|
|
|
|
- name: Get coredns rollout restart status
|
|
become: false
|
|
shell: |
|
|
kubectl rollout status -n kube-system deployment/coredns
|
|
when: inventory_hostname in (groups['primary'] | default([]))
|
|
|
|
- name: Use coredns as default DNS resolver
|
|
copy:
|
|
src: files/cluster_resolv.conf
|
|
dest: /etc/resolv.conf
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when: inventory_hostname in (groups['k8s_cluster'] | default([]))
|
|
...
|