From 7dd8fd9fbb2c41d3d0986d0daf3ba7547f662152 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Fri, 22 Jan 2021 23:54:12 +0800 Subject: [PATCH] remove dependency: netaddr --- docs/setup/00-planning_and_overall_intro.md | 2 +- roles/cluster-addon/tasks/main.yml | 9 +++++++++ roles/cluster-addon/vars/main.yml | 3 --- roles/deploy/tasks/main.yml | 6 ------ roles/kube-master/tasks/main.yml | 9 +++++++++ roles/kube-master/vars/main.yml | 3 --- roles/kube-node/tasks/main.yml | 7 +++++++ roles/kube-node/vars/main.yml | 3 --- roles/kube-ovn/tasks/main.yml | 7 +++++++ roles/kube-ovn/vars/main.yml | 1 - 10 files changed, 33 insertions(+), 17 deletions(-) diff --git a/docs/setup/00-planning_and_overall_intro.md b/docs/setup/00-planning_and_overall_intro.md index c92695d..f267537 100644 --- a/docs/setup/00-planning_and_overall_intro.md +++ b/docs/setup/00-planning_and_overall_intro.md @@ -63,7 +63,7 @@ apt-get install git python-pip -y yum install git python-pip -y # pip安装ansible(国内如果安装太慢可以直接用pip阿里云加速) pip install pip --upgrade -i https://mirrors.aliyun.com/pypi/simple/ -pip install ansible netaddr==0.7.19 -i https://mirrors.aliyun.com/pypi/simple/ +pip install ansible -i https://mirrors.aliyun.com/pypi/simple/ ``` - 3.2 在ansible控制端配置免密码登录 diff --git a/roles/cluster-addon/tasks/main.yml b/roles/cluster-addon/tasks/main.yml index 3a328f6..f90b753 100644 --- a/roles/cluster-addon/tasks/main.yml +++ b/roles/cluster-addon/tasks/main.yml @@ -10,6 +10,15 @@ connection: local run_once: true +- name: 注册变量 DNS_SVC_IP + shell: echo {{ SERVICE_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+2}' + register: DNS_SVC_IP + +- name: 设置变量 CLUSTER_DNS_SVC_IP + set_fact: CLUSTER_DNS_SVC_IP={{ DNS_SVC_IP.stdout }} + +- debug: var="CLUSTER_DNS_SVC_IP" + - import_tasks: coredns.yml when: '"coredns" not in pod_info.stdout and dns_install == "yes"' diff --git a/roles/cluster-addon/vars/main.yml b/roles/cluster-addon/vars/main.yml index 7235d76..e3c603b 100644 --- a/roles/cluster-addon/vars/main.yml +++ b/roles/cluster-addon/vars/main.yml @@ -1,6 +1,3 @@ -# 设置 dns svc ip (这里选用 SERVICE_CIDR 中第2个IP) -CLUSTER_DNS_SVC_IP: "{{ SERVICE_CIDR | ipaddr('net') | ipaddr(2) | ipaddr('address') }}" - # coredns_offline: "coredns_{{ corednsVer }}.tar" diff --git a/roles/deploy/tasks/main.yml b/roles/deploy/tasks/main.yml index 056905d..2a70311 100644 --- a/roles/deploy/tasks/main.yml +++ b/roles/deploy/tasks/main.yml @@ -78,9 +78,3 @@ line: 'source <(kubectl completion bash)' when: "procs.stdout|int > 50" ignore_errors: true - -- name: pip install netaddr - pip: - name: netaddr - when: "procs.stdout|int > 50" - ignore_errors: true diff --git a/roles/kube-master/tasks/main.yml b/roles/kube-master/tasks/main.yml index a55086a..063a32b 100644 --- a/roles/kube-master/tasks/main.yml +++ b/roles/kube-master/tasks/main.yml @@ -7,6 +7,15 @@ - kubectl tags: upgrade_k8s +- name: 注册变量 KUBERNETES_SVC_IP + shell: echo {{ SERVICE_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+1}' + register: KUBERNETES_SVC_IP + tags: change_cert + +- name: 设置变量 CLUSTER_KUBERNETES_SVC_IP + set_fact: CLUSTER_KUBERNETES_SVC_IP={{ KUBERNETES_SVC_IP.stdout }} + tags: change_cert + - name: 创建 kubernetes 证书签名请求 template: src=kubernetes-csr.json.j2 dest={{ cluster_dir }}/ssl/kubernetes-csr.json tags: change_cert diff --git a/roles/kube-master/vars/main.yml b/roles/kube-master/vars/main.yml index a6029e2..da3d3b8 100644 --- a/roles/kube-master/vars/main.yml +++ b/roles/kube-master/vars/main.yml @@ -1,6 +1,3 @@ # etcd 集群服务地址列表, 根据etcd组成员自动生成 TMP_ENDPOINTS: "{% for h in groups['etcd'] %}https://{{ h }}:2379,{% endfor %}" ETCD_ENDPOINTS: "{{ TMP_ENDPOINTS.rstrip(',') }}" - -# 设置 dns svc ip (这里选用 SERVICE_CIDR 中第1个IP) -CLUSTER_KUBERNETES_SVC_IP: "{{ SERVICE_CIDR | ipaddr('net') | ipaddr(1) | ipaddr('address') }}" diff --git a/roles/kube-node/tasks/main.yml b/roles/kube-node/tasks/main.yml index 465b50e..6a92fb4 100644 --- a/roles/kube-node/tasks/main.yml +++ b/roles/kube-node/tasks/main.yml @@ -33,6 +33,13 @@ - name: 准备 cni配置文件 template: src=cni-default.conf.j2 dest=/etc/cni/net.d/10-default.conf +- name: 注册变量 DNS_SVC_IP + shell: echo {{ SERVICE_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+2}' + register: DNS_SVC_IP + +- name: 设置变量 CLUSTER_DNS_SVC_IP + set_fact: CLUSTER_DNS_SVC_IP={{ DNS_SVC_IP.stdout }} + - name: 创建kubelet的配置文件 template: src=kubelet-config.yaml.j2 dest=/var/lib/kubelet/config.yaml tags: upgrade_k8s, restart_node diff --git a/roles/kube-node/vars/main.yml b/roles/kube-node/vars/main.yml index 03d788f..e596a53 100644 --- a/roles/kube-node/vars/main.yml +++ b/roles/kube-node/vars/main.yml @@ -1,6 +1,3 @@ -# 设置 dns svc ip (这里选用 SERVICE_CIDR 中第2个IP) -CLUSTER_DNS_SVC_IP: "{{ SERVICE_CIDR | ipaddr('net') | ipaddr(2) | ipaddr('address') }}" - # 设置 APISERVER 地址 KUBE_APISERVER: "{%- if inventory_hostname in groups['kube_master'] -%} \ https://{{ inventory_hostname }}:6443 \ diff --git a/roles/kube-ovn/tasks/main.yml b/roles/kube-ovn/tasks/main.yml index 59b3d59..03c9677 100644 --- a/roles/kube-ovn/tasks/main.yml +++ b/roles/kube-ovn/tasks/main.yml @@ -5,6 +5,13 @@ - /opt/kube/images - /opt/kube/kube-ovn +- name: 注册变量 ovn_default_gateway + shell: echo {{ CLUSTER_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+1}' + register: ovn_default_gateway + +- name: 设置变量 kube_ovn_default_gateway + set_fact: kube_ovn_default_gateway={{ ovn_default_gateway.stdout }} + - name: 配置 crd.yaml 文件 template: src=crd.yaml.j2 dest=/opt/kube/kube-ovn/crd.yaml diff --git a/roles/kube-ovn/vars/main.yml b/roles/kube-ovn/vars/main.yml index 453cf76..1105454 100644 --- a/roles/kube-ovn/vars/main.yml +++ b/roles/kube-ovn/vars/main.yml @@ -1,4 +1,3 @@ kube_ovn_default_cidr: "{{ CLUSTER_CIDR }}" -kube_ovn_default_gateway: "{{ CLUSTER_CIDR | ipaddr('net') | ipaddr(1) | ipaddr('address') }}" kube_ovn_node_switch_cidr: 100.64.0.0/16 kube_ovn_enable_mirror: true