第一次搭建kubernetes經歷

1.準備部署環境
master 192.168.40.162
node 192.168.40.220node

2.下載部署包(從192.168.40.33複製部署包)
scp /opt/kylincloud2_2.0_ft2000_v0.0.1.13_20200511.tar.gz root@192.168.40.162:/opt/mysql

3.免密認證
經過192.168.40.192對192.168.40.162及192.168.40.220作免密認證,即master節點對自身及全部node節點作免密認證
(1)ssh-keygen -t rsa
(2)cat id_rsa.pub>>authorized_keys
(3)chmod 710 authorized_keys
(4)scp -r authorized_keys root@192.168.40.220:~/.sshsql

4.時間同步
(1)ntpdate 192.168.40.253(此命令分別執行在master及node)
將192.168.40.162和192.168.40.220統一與192.168.40.253時間保持一致,即master及全部節點保持統一一致時間
(2)hwclock -w(此命令分別執行在master及node)
將軟件時間寫入硬件時間,硬件時間是BIOS的時間docker

5.根據需求修改default.yaml文件bootstrap

示例一:(所有配置內容)
install_path: /opt/cms/kylincloud2 #安裝目錄api

modules:
etcd: etcd-3.3.13
docker: docker-17.03
kube: kube-1.14.2
keepalived: keepalived-1.3.5
cni: cni-arm64
cfssl: cfssl-1.3.2dom

cluster info

clustername: kubernetes-phk
clusteruser: kubernetes-adminssh

docker_registry

registry:
domain: kylincloud2.hub
admin_password: Harbor12345
db:
host: mysql
port: 3306
user: root
passwd: root123
clair_password: passwordide

ntp

ntpserver: 192.168.40.253ui

nfs 不能註釋,永遠爲最新的nfs服務端信息

nfs_server: 192.168.40.253
src_path: /mnt/nfs/testphk
storage: 192.168.40.253:/mnt/nfs/testphk /nas nfs defaults 0 1
mount_path: /nas

etcd cluster name

etcdname: kube-etcd

head -c 16 /dev/urandom | od -An -t x | tr -d ' '

bootstrap_token: c30302226d4b810e08731702d3890f51
ui_url: ui.kylincloud2.hub

head -c 32 /dev/urandom | base64

encryption_token: d/FP5wCz8lV9s+bU1tnvsuj9C4hZWZRcMVud18E0LMc=

cloudapiserver

dnsserver: 192.168.40.32
dnsport: 9999

NET

vip: 192.168.40.33 #單控模式爲 master的ip,多控模式下爲虛擬ip,跟集羣同網段且不被佔用

oldvip: 192.168.17.222 #默認註釋掉,當使用 --ip參數時須要將歷史的vip地址寫入

virtual_router_id: 88 #keepalived 集羣通訊的心跳值,確保不跟網段中其餘keepalived集羣的心跳值一致便可
service:
cidr: 10.10.0.0/16
DNS_ip: 10.10.1.10
cluster_domain: cluster.local
pod_net:
cidr: 10.244.0.0/16

部署模式爲單控,以及多控不須要lvs的時候註釋

lvs:

- name: lvs-1

ip: 192.168.40.207

state: MASTER

- name: lvs-2

ip: 192.168.40.208

state: BACKUP

master:

  • name: master1
    ip: 192.168.40.33 #第一個ip必須是執行腳本所在的機器

- name: master2

ip: 192.168.40.161

- name: master3

ip: 192.168.40.162

nodes:

  • name: node-1
    ip: 192.168.40.34
    label: rack=bgpt

- name: node-2

ip: 192.168.40.223

label: rack=bgpt1

- name: node-3

ip: 192.168.40.35

label: rack=bgpt1

- name: node-4

ip: 192.168.40.224

label: rack=bgpt

- name: node-5

ip: 192.168.40.207

label: rack=bgpt

- name: node-6

ip: 192.168.40.208

label: rack=bgpt1

新加計算節點,初次部署註釋便可

addnodes:

- name: node-3

ip: 192.168.40.35

label: rack=bgpt

- name: node-4

ip: 192.168.40.208

label: rack=bgpt1

示例二:(本次部署所需配置)
install_path: /opt/cms/kylincloud2 #安裝目錄

modules:
etcd: etcd-3.3.13
docker: docker-17.03
kube: kube-1.14.2
keepalived: keepalived-1.3.5
cni: cni-arm64
cfssl: cfssl-1.3.2

cluster info

clustername: kubernetes
clusteruser: kubernetes-admin

docker_registry

registry:
domain: kylincloud2.hub
admin_password: Harbor12345
db:
host: mysql
port: 3306
user: root
passwd: root123
clair_password: password

ntp

ntpserver: 192.168.40.253

nfs 不能註釋,永遠爲最新的nfs服務端信息

nfs_server: 192.168.40.253
src_path: /mnt/nfs/testphk
storage: 192.168.40.253:/mnt/nfs/testphk /nas nfs defaults 0 1
mount_path: /nas

etcd cluster name

etcdname: kube-etcd

head -c 16 /dev/urandom | od -An -t x | tr -d ' '

bootstrap_token: c30302226d4b810e08731702d3890f51
ui_url: ui.kylincloud2.hub

head -c 32 /dev/urandom | base64

encryption_token: d/FP5wCz8lV9s+bU1tnvsuj9C4hZWZRcMVud18E0LMc=

cloudapiserver

dnsserver: 192.168.40.162
dnsport: 9999

NET

vip: 192.168.40.162 #單控模式爲 master的ip,多控模式下爲虛擬ip,跟集羣同網段且不被佔用

oldvip: 192.168.17.222 #默認註釋掉,當使用 --ip參數時須要將歷史的vip地址寫入

virtual_router_id: 41 #keepalived 集羣通訊的心跳值,確保不跟網段中其餘keepalived集羣的心跳值一致便可
service:
cidr: 10.10.0.0/16
DNS_ip: 10.10.1.10
cluster_domain: cluster.local
pod_net:
cidr: 10.244.0.0/16

master:

  • name: master1
    ip: 192.168.40.162 #第一個ip必須是執行腳本所在的機器
    nodes:
  • name: node-1
    ip: 192.168.40.220
    label: rack=bgpt

6.開始部署
./install --master

7.驗證部署是否成功 kubectl get po -A -o wide

相關文章
相關標籤/搜索