From 21f1c82fb0f7bfaa89f25c766ef5f9585e9e3058 Mon Sep 17 00:00:00 2001 From: Aleksandr Didenko Date: Tue, 5 Jul 2016 12:43:14 +0200 Subject: [PATCH] Setup a ip ro workaround for cluste IPs --- deploy-k8s.kargo.sh | 2 +- ...ro_for_dnsmasq.yaml => ipro_for_cluster_ips.yaml} | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename playbooks/{ipro_for_dnsmasq.yaml => ipro_for_cluster_ips.yaml} (51%) diff --git a/deploy-k8s.kargo.sh b/deploy-k8s.kargo.sh index 16696fbf5..292ca6836 100755 --- a/deploy-k8s.kargo.sh +++ b/deploy-k8s.kargo.sh @@ -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 diff --git a/playbooks/ipro_for_dnsmasq.yaml b/playbooks/ipro_for_cluster_ips.yaml similarity index 51% rename from playbooks/ipro_for_dnsmasq.yaml rename to playbooks/ipro_for_cluster_ips.yaml index eb4324c21..9f2b2fb22 100644 --- a/playbooks/ipro_for_dnsmasq.yaml +++ b/playbooks/ipro_for_cluster_ips.yaml @@ -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