Setup a ip ro workaround for cluste IPs

This commit is contained in:
Aleksandr Didenko 2016-07-05 12:43:14 +02:00
parent 6ec957a255
commit 21f1c82fb0
2 changed files with 7 additions and 7 deletions

View file

@ -27,5 +27,5 @@ if [ "$deploy_res" -eq "0" ]; then
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
ansible-playbook -i $INVENTORY playbooks/ipro_for_cluster_ips.yaml
fi

View file

@ -1,9 +1,9 @@
# 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
- name: Get kube service net
shell: grep KUBE_SERVICE_ADDRESSES /etc/kubernetes/kube-apiserver.env | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}\b"
register: kube_service_addresses
run_once: true
- hosts: all
tasks:
@ -11,11 +11,11 @@
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 ""
shell: ip ro ls | grep "^{{ hostvars[groups['kube-master'][0]]['kube_service_addresses']['stdout'] }}" || echo ""
register: local_route
- name: Clean up route
shell: ip ro del {{ hostvars[groups['kube-master'][0]]['dnsmasq_ip']['stdout'] }} || true
shell: ip ro del {{ hostvars[groups['kube-master'][0]]['kube_service_addresses']['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 }}
shell: ip ro add {{ hostvars[groups['kube-master'][0]]['kube_service_addresses']['stdout'] }} via {{ local_ip.stdout }}
when: local_route.stdout.find('{{ local_ip.stdout }}') == -1