使用kubeadm快速部署Kubernetes集群

master:192.168.248.130
node10:192.168.248.10
node20:192.168.248.20

#关闭防火墙,swap,selinux
#设置iptables
iptables
cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
#添加阿里云kubernetes源
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF
#master安装 kubelet kubeadm kubectl
yum install kubelet kubeadm kubectl --disableexcludes=kubernetes -y
#查看所需镜像
[root@master ~]# kubeadm config images list
k8s.gcr.io/kube-apiserver:v1.23.3
k8s.gcr.io/kube-controller-manager:v1.23.3
k8s.gcr.io/kube-scheduler:v1.23.3
k8s.gcr.io/kube-proxy:v1.23.3
k8s.gcr.io/pause:3.6
k8s.gcr.io/etcd:3.5.1-0
k8s.gcr.io/coredns/coredns:v1.8.6
#国内k8s.gcr.io访问不到这里使用阿里镜像
[root@master ~]# cat kubeadm.sh 
#!/bin/bash
for i in `kubeadm config images list`; do 
  imageName=${i#k8s.gcr.io/}
  docker pull registry.aliyuncs.com/google_containers/$imageName
  docker tag registry.aliyuncs.com/google_containers/$imageName k8s.gcr.io/$imageName
  docker rmi registry.aliyuncs.com/google_containers/$imageName
done;
#可以自己下载所需版本自己打标签
[root@master ~]# docker image ls
REPOSITORY                           TAG       IMAGE ID       CREATED        SIZE
k8s.gcr.io/kube-apiserver            v1.23.3   f40be0088a83   2 weeks ago    135MB
k8s.gcr.io/kube-scheduler            v1.23.3   99a3486be4f2   2 weeks ago    53.5MB
k8s.gcr.io/kube-proxy                v1.23.3   9b7cc9982109   2 weeks ago    112MB
k8s.gcr.io/kube-controller-manager   v1.23.3   b07520cd7ab7   2 weeks ago    125MB
k8s.gcr.io/etcd                      3.5.1-0   25f8c7f3da61   3 months ago   293MB
k8s.gcr.io/coredns/coredns           v1.8.6    a4ca41631cc7   4 months ago   46.8MB
k8s.gcr.io/pause                     3.6       6270bb605e12   5 months ago   683kB

#master,node 安装docker配置国内镜像
#略
#kubeadm安装kubernetes
kubeadm init --kubernetes-version=v1.23.3 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16
  --kubernetes-version:选择特定的Kubernetes版本(默认为“stable-1”)
  --service-cidr:为服务的VIP指定使用的IP地址范围(默认为“10.96.0.0/12”)
  --pod-network-cidr:指定Pod网络的IP地址范围。如果设置,则将自动为每个节点分配CIDR。

#根据提示执行
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/admin.conf
#安装网络插件calico
kubectl apply -f "https://docs.projectcalico.org/manifests/calico.yaml"

#master安装可视化工具

#node安装 kubelet kubeadm
yum install kubelet kubeadm --disableexcludes=kubernetes -y
#node拉取镜像
#略
#加入到master节点
kubeadm join 192.168.248.130:6443 --token h0kbhm.fa1rr945b519nf9d \
    --discovery-token-ca-cert-hash sha256:f65aec48d285e8bc4260b291910022a21561926bf4daf3743a9a14c1702d5ab3
#查看节点状态
[root@master ~]# kubectl get nodes
NAME     STATUS   ROLES                  AGE    VERSION
master   Ready    control-plane,master   123m   v1.23.3
node10   Ready    <none>                 59m    v1.23.3
node20   Ready    <none>                 58m    v1.23.3
[root@master ~]# kubectl get pods -A
NAMESPACE     NAME                                       READY   STATUS    RESTARTS      AGE
kube-system   calico-kube-controllers-566dc76669-gt8bw   1/1     Running   0             64m
kube-system   calico-node-cgjrp                          1/1     Running   0             59m
kube-system   calico-node-dq9xc                          1/1     Running   0             64m
kube-system   calico-node-nqpwn                          1/1     Running   0             59m
kube-system   coredns-64897985d-9wplb                    1/1     Running   0             123m
kube-system   coredns-64897985d-q5hfb                    1/1     Running   0             123m
kube-system   etcd-master                                1/1     Running   1 (97m ago)   123m
kube-system   kube-apiserver-master                      1/1     Running   2 (97m ago)   123m
kube-system   kube-controller-manager-master             1/1     Running   1 (97m ago)   123m
kube-system   kube-proxy-lm5vk                           1/1     Running   1 (97m ago)   123m
kube-system   kube-proxy-mdrmr                           1/1     Running   0             59m
kube-system   kube-proxy-xzm5x                           1/1     Running   0             59m
kube-system   kube-scheduler-master                      1/1     Running   1 (97m ago)   123m

安装kuboard

kuboard安装

部署应用

[root@master ~]# kubectl get pods -n test
NAME                             READY   STATUS    RESTARTS   AGE
cloud-busybox-55499bb447-9smlz   1/1     Running   0          38m
mysql-9b877f47-4mbkx             1/1     Running   0          30m
myweb-64d9d9df66-86qmx           1/1     Running   0          26m
myweb-64d9d9df66-cdb8b           1/1     Running   0          26m

WX20220213-135239@2x.png

WX20220213-135208@2x.png

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇