Skip to content

Commit

Permalink
Merge pull request #11 from paradeum-team/jyliu
Browse files Browse the repository at this point in the history
feat: add node 支持ubuntu
  • Loading branch information
ss75710541 authored Mar 2, 2022
2 parents cc7fab1 + c596d64 commit 00762e3
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 8 deletions.
3 changes: 3 additions & 0 deletions ansible.hosts.ha.publicnetwork.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pod_subnet=10.128.0.0/16
helm_binary_md5=e4500993ba21e5e6bdfbc084b4342025
helm_binary_url=https://pnode.solarfs.io/dn/file/{{helm_binary_md5}}/helm-v3.6.0-linux-amd64.tar.gz

# os id, centos|ubuntu
OS_ID="centos"

[install]
master1.solarfs.k8s

Expand Down
3 changes: 3 additions & 0 deletions ansible.hosts.ha.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pod_subnet=10.128.0.0/16
helm_binary_md5=e4500993ba21e5e6bdfbc084b4342025
helm_binary_url=https://pnode.solarfs.io/dn/file/{{helm_binary_md5}}/helm-v3.6.0-linux-amd64.tar.gz

# os id, centos|ubuntu
OS_ID="centos"

[install]
master1.solarfs.k8s

Expand Down
3 changes: 3 additions & 0 deletions ansible.hosts.ha.vip.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ ingress_nodeport_https=32443
helm_binary_md5=e4500993ba21e5e6bdfbc084b4342025
helm_binary_url=https://pnode.solarfs.io/dn/file/{{helm_binary_md5}}/helm-v3.6.0-linux-amd64.tar.gz

# os id, centos|ubuntu
OS_ID="centos"

[install]
master1.solarfs.k8s

Expand Down
13 changes: 8 additions & 5 deletions ansible.hosts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ pod_subnet=10.128.0.0/16
helm_binary_md5=24b16800f8c7f44b5dd128e3355ecf1b
helm_binary_url=https://pnode.solarfs.io/dn/file/{{helm_binary_md5}}/helm-v3.6.3-linux-amd64.tar.gz

# os id, centos|ubuntu
OS_ID="centos"

[install]
master1.kuggatest.k8s
master1.solarfs.k8s

[masters]
master1.kuggatest.k8s ansible_host=172.16.195.211
master1.solarfs.k8s ansible_host=172.16.195.211

[nodes]
infra1.kuggatest.k8s ansible_host=172.16.3.85
node1.kuggatest.k8s ansible_host=172.16.128.250
node2.kuggatest.k8s ansible_host=172.16.214.182
infra1.solarfs.k8s ansible_host=172.16.3.85
node1.solarfs.k8s ansible_host=172.16.128.250

[new_nodes]
#node2.solarfs.k8s ansible_host=172.16.214.182 OS_ID="ubuntu"
4 changes: 4 additions & 0 deletions roles/host-init/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
- name: restart network
service: name=network state=restarted
become: yes

- name: restart resolved
service: name=resolved state=restarted
become: yes
49 changes: 49 additions & 0 deletions roles/host-init/tasks/apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
- name: clean repo cache
command: apt clean && apt update
ignore_errors: yes
tags: aptrepo

- name: Add kubernetes repo key
apt_key:
url: https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg
state: present

- name: Install kubernetes repo
shell: echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

- name: Add docker repo key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
keyring: /usr/share/keyrings/docker-archive-keyring.gpg
state: present

- name: Install docker repo
shell: echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

- name: Install base tools
apt:
name:
- wget
- net-tools
- dnsutils
- bash-completion
- telnet
- curl
- lrzsz
- jq
- linux-tools-common
- strace
- vim
- iotop
- dnsmasq
- iproute2
- nfs-common
- python3-selinux
- policycoreutils
- apt-transport-https
- ca-certificates
- gnupg
- lsb-release
update_cache: yes
tags: install-base-tools

29 changes: 29 additions & 0 deletions roles/host-init/tasks/docker.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# centos uninstall docker
- name: uninstall podman
yum:
name:
- runc
state: absent
autoremove: true
when: OS_ID == "centos"

# centos install docker
- name: Install docker ce
yum:
name:
Expand All @@ -15,6 +18,32 @@
- docker-ce
- docker-ce-cli
tags: docker
when: OS_ID == "centos"

# ubuntu uninstall docker
- name: uninstall docker
apt:
name:
- docker
- docker-engine
- docker.io
- containerd
- runc
state: absent
autoremove: true
when: OS_ID == "ubuntu"

# ubuntu install docker
- name: Install docker ce
apt:
name:
- lvm2
- containerd.io
- docker-ce
- docker-ce-cli
update_cache: yes
tags: docker
when: OS_ID == "ubuntu"

- name: Create /etc/docker directory
file:
Expand Down
13 changes: 13 additions & 0 deletions roles/host-init/tasks/installKubeadm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
- kubectl-{{k8s_version}}
- bash-completion
tags: kubeadm
when: OS_ID == "centos"

- name: Install kubeadm kubelet kubectl
apt:
name:
- kubelet={{k8s_version}}-00
- kubeadm={{k8s_version}}-00
- kubectl={{k8s_version}}-00
- bash-completion
update_cache: yes
tags: kubeadm
when: OS_ID == "ubuntu"

- name: Kubectl completion bash
shell: "kubectl completion bash >/etc/bash_completion.d/kubectl"
Expand All @@ -15,6 +27,7 @@
template: src=kubelet.j2 dest=/etc/sysconfig/kubelet owner=root group=root mode=644 backup=yes
notify: restart kubelet
tags: kubeadm
when: OS_ID == "centos"

- name: Enable service kubelet and start
service:
Expand Down
12 changes: 12 additions & 0 deletions roles/host-init/tasks/ipvs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
- conntrack
- libseccomp
tags: ipvs
when: OS_ID == "centos"

- name: Install ipvsadm
apt:
name:
- ipvsadm
- ipset
- sysstat
- conntrack
- libseccomp-dev
tags: ipvs
when: OS_ID == "ubuntu"

- name: Modprode Kernel Module for IPVS
modprobe:
Expand Down
6 changes: 5 additions & 1 deletion roles/host-init/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
# CentOS #
# ########
- include: yum.yml
when: OS_ID == "centos"
- include: apt.yml
when: OS_ID == "ubuntu"
- include: selinux.yml
when: OS_ID == "centos"
- include: ulimit.yml
- include: ipvs.yml
- include: sysctl.yml
Expand All @@ -21,7 +25,7 @@
- include: apiServerDns.yml
when: master_vip is defined
- include: resolv.yml
when: public_network_node == False
when: public_network_node == False and OS_ID == "centos"
- include: publicInterface.yml
when: public_network_node == True
- include: reboot.yml
Expand Down
6 changes: 6 additions & 0 deletions roles/host-init/tasks/update.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
- name: yum update
command: yum update -y
tags: yum-update
when: OS_ID == "centos"

- name: apt upgrade
apt:
only_upgrade: yes
when: OS_ID == "ubuntu"
2 changes: 1 addition & 1 deletion roles/k8s-masters/templates/kube-dns.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ cache-size=10000
bind-dynamic
min-port=1024
interface={{LOCAL_ENNAME}}
except-interface=lo
#except-interface=lo
# End of config
2 changes: 1 addition & 1 deletion roles/k8s-nodes/templates/kube-dns.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ cache-size=10000
bind-dynamic
min-port=1024
interface={{LOCAL_ENNAME}}
except-interface=lo
#except-interface=lo
# End of config

0 comments on commit 00762e3

Please sign in to comment.