diff --git a/deploy-k8s.kargo.sh b/deploy-k8s.kargo.sh index d1c14e13b..16696fbf5 100755 --- a/deploy-k8s.kargo.sh +++ b/deploy-k8s.kargo.sh @@ -26,4 +26,6 @@ if [ "$deploy_res" -eq "0" ]; then ansible-playbook -i $INVENTORY playbooks/kubedns.yaml echo "Setting up kubedashboard..." ansible-playbook -i $INVENTORY playbooks/kubedashboard.yaml + echo "Setting up ip route work-around for DNS clusterIP availability..." + ansible-playbook -i $INVENTORY playbooks/ipro_for_dnsmasq.yaml fi diff --git a/playbooks/ipro_for_dnsmasq.yaml b/playbooks/ipro_for_dnsmasq.yaml new file mode 100644 index 000000000..eb4324c21 --- /dev/null +++ b/playbooks/ipro_for_dnsmasq.yaml @@ -0,0 +1,21 @@ +# FXIME: add persistent routing rule +- hosts: kube-master + tasks: + - name: Get DNS clusterIP + shell: kubectl get svc --namespace kube-system dnsmasq --template=\{\{.spec.clusterIP\}\} + register: dnsmasq_ip + run_once: true +- hosts: all + tasks: + - name: Get local IP + shell: "calicoctl status | grep IP: | awk '{print $2}'" + register: local_ip + - name: Get route + shell: ip ro ls | grep "^{{ hostvars[groups['kube-master'][0]]['dnsmasq_ip']['stdout'] }}" || echo "" + register: local_route + - name: Clean up route + shell: ip ro del {{ hostvars[groups['kube-master'][0]]['dnsmasq_ip']['stdout'] }} || true + when: local_route.stdout.find('{{ local_ip.stdout }}') == -1 + - name: Setup route + shell: ip ro add {{ hostvars[groups['kube-master'][0]]['dnsmasq_ip']['stdout'] }} via {{ local_ip.stdout }} + when: local_route.stdout.find('{{ local_ip.stdout }}') == -1