diff --git a/example/config.yml b/example/config.yml index 024bd85..d330ca9 100644 --- a/example/config.yml +++ b/example/config.yml @@ -34,9 +34,13 @@ K8S_VER: "__k8s_ver__" K8S_NODENAME: "{%- if k8s_nodename != '' -%} \ {{ k8s_nodename|replace('_', '-')|lower }} \ {%- else -%} \ - {{ inventory_hostname }} \ + {{ inventory_hostname|replace('.', '-') }} \ {%- endif -%}" +# use 'K8S_NODENAME' to set hostname +ENABLE_SETTING_HOSTNAME: true + + ############################ # role:etcd ############################ diff --git a/ezdown b/ezdown index 0399499..f504f25 100755 --- a/ezdown +++ b/ezdown @@ -93,6 +93,7 @@ available OSes: ubuntu_18 to download package of Ubuntu 18.04 ubuntu_20 to download package of Ubuntu 20.04 ubuntu_22 to download package of Ubuntu 22.04 + ubuntu_24 to download package of Ubuntu 24.04 examples: ./ezdown -P ubuntu_22 EOF diff --git a/roles/prepare/tasks/main.yml b/roles/prepare/tasks/main.yml index c6cd7e0..ee8053d 100644 --- a/roles/prepare/tasks/main.yml +++ b/roles/prepare/tasks/main.yml @@ -42,6 +42,13 @@ regexp: 'easzlab.io.local' line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local" +# 设置节点hostname,calico 网络组件要求每个节点不一样的hostname +- name: 设置节点 hostname + hostname: + name: "{{ K8S_NODENAME }}" + use: systemd + when: "ENABLE_SETTING_HOSTNAME|bool" + # 设置节点名称{{ K8S_NODENAME }} /etc/hosts 解析 # 1.先确保第一个主节点做好解析 - name: 设置 k8s_nodename 在 master[0] 节点 /etc/hosts 地址解析