调整集群内api服务地址和dns服务地址设置方式

v3.3
gjmzj 2022-12-16 09:55:24 +08:00
parent 452c79e42e
commit a5ab2d94a0
6 changed files with 9 additions and 25 deletions

View File

@ -3,15 +3,6 @@
register: pod_info
tags: force_change_certs
- 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 or CHANGE_CA|bool'

View File

@ -1 +1,4 @@
# default values
# coredns 服务地址根据SERVICE_CIDR 设置,默认选择网段第二个地址
CLUSTER_DNS_SVC_IP: "{{ SERVICE_CIDR.split('.')[0] }}.{{ SERVICE_CIDR.split('.')[1] }}.{{ SERVICE_CIDR.split('.')[2] }}.{{ SERVICE_CIDR.split('.')[3]|int + 2 }}"

View File

@ -14,15 +14,6 @@
- kube-scheduler.kubeconfig
tags: force_change_certs
- 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, force_change_certs
- name: 设置变量 CLUSTER_KUBERNETES_SVC_IP
set_fact: CLUSTER_KUBERNETES_SVC_IP={{ KUBERNETES_SVC_IP.stdout }}
tags: change_cert, force_change_certs
- name: 创建 kubernetes 证书签名请求
template: src=kubernetes-csr.json.j2 dest={{ cluster_dir }}/ssl/kubernetes-csr.json
tags: change_cert, force_change_certs

View File

@ -1,3 +1,6 @@
# etcd 集群服务地址列表, 根据etcd组成员自动生成
TMP_ENDPOINTS: "{% for h in groups['etcd'] %}https://{{ h }}:2379,{% endfor %}"
ETCD_ENDPOINTS: "{{ TMP_ENDPOINTS.rstrip(',') }}"
# kubernetes.default.svc 地址根据SERVICE_CIDR 设置为网段的第一个地址
CLUSTER_KUBERNETES_SVC_IP: "{{ SERVICE_CIDR.split('.')[0] }}.{{ SERVICE_CIDR.split('.')[1] }}.{{ SERVICE_CIDR.split('.')[2] }}.{{ SERVICE_CIDR.split('.')[3]|int + 1 }}"

View File

@ -23,13 +23,6 @@
- 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

View File

@ -3,3 +3,6 @@ KUBE_APISERVER: "https://127.0.0.1:{{ SECURE_PORT }}"
# cgroup driver
CGROUP_DRIVER: "systemd"
# coredns 服务地址根据SERVICE_CIDR 设置,默认选择网段第二个地址
CLUSTER_DNS_SVC_IP: "{{ SERVICE_CIDR.split('.')[0] }}.{{ SERVICE_CIDR.split('.')[1] }}.{{ SERVICE_CIDR.split('.')[2] }}.{{ SERVICE_CIDR.split('.')[3]|int + 2 }}"