kubernetes组件、

基本队对象

pod  最小单位

service   跟网络相关

Volume

Namespace

准备工作:

master 

node1  node2

修改主机名:

做本地解析

10.0.0.51   master

10.0.0.56  node-1

10.0.0.186  node-2

关闭swap分区: swapoff -a  临时关闭
 sed -i 's/.*swap.*/#&/' /etc/fstab 永久关闭

开启docker:systemctl start docker   (三个节点全做:scp )
                     systemctl enable docker
 vim /etc/docker/daemon.json

{
  "exec-opts": ["native.cgroupdriver=systemd"]
}

systemctl restart docker

编写脚本: vim kubernetes.sh   (三个节点全做:scp
cat >> /etc/yum.repos.d/kubernetes.repo < [kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
eof
yum -y install kubeadm-1.23.5  kubelet-1.23.5  kubectl-1.23.5 ipvsadm
cat >/etc/sysconfig/kubelet< KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1"
EOF

modprobe br_netfilter
cat >> /etc/sysctl.conf < net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0
eof
sysctl -p

上传1.23.5目录中的所有压缩包

cd 1.23.5

[root@master ~]# cat image_load.sh   (三个节点全做:  scp image_load.sh node-1:/root/1.23.5/)
#!/bin/bash
image_path=`pwd`
for i in `ls "${image_path}" | grep tar`
do
        docker load  < $i
done

master节点初始化: 

kubeadm init --kubernetes-version=1.23.5 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.0.0.220(主节点的IP)

改错:重新初始化:先重置,再初始化

cd

按照提示:
   mkdir -p $HOME/.kube
  cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  chown $(id -u):$(id -g) $HOME/.kube/config
   export KUBECONFIG=/etc/kubernetes/admin.conf

上传: kube-flannel(1).yml
   kubectl apply -f kube-flannel\(1\).yml

在master节点按提示复制到nod-1/node-2: kubeadm join 10.0.0.51:6443 --token w6iurw.k5xu7n0hze7cagni --discovery-token-ca-cert-hash sha256:bc859e0f8194de2f01831d165f5bf7280e083bd0b5000285bc2372d405e24a9d 

改错:vim /etc/sysconfig/kubelet

KUBELET_EXTRA_ARGS="--cgroup-driver=systemd --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1"

安装kuboard(主节点):

kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml   如果不行就换镜像参考官网
kubectl label nodes node-1 k8s.kuboard.cn/role=etcd
  kubectl label nodes node-2 k8s.kuboard.cn/role=etcd

kubectl get pods -n kuboard 

显示running

验证:

ip地址+30080

你可能感兴趣的:(kubernetes,容器,云原生)