标签:mamicode local ipvsadm tom amp repo lin mkdir min
升级系统,安装常用的rpm
yum -y update yum -y install wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake\ libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel\ wget vim ncurses-devel autoconf automake zlib-devel python-devel\ epel-release lrzsz openssh-server socat ipvsadm conntrack bind-utils yum -y install yum-utils device-mapper-persistent-data lvm2
配置k8s 的yum源
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=0
EOF
配置docker 的yum源,及查看支持的docker版本
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum list docker-ce --showduplicates |sort -r
下载18.09版本的docker
yum clean all yum makecache fast yum install -y docker-ce-18.09.9-3.el7 systemctl enable docker && systemctl start docker systemctl status docker
安装k8s 1.16.4
#在k8s-master和k8s-node上安装kubeadm和kubelet
#kubelet设置开机启动 yum install -y kubeadm-1.16.4-0.x86_64 kubelet-1.16.4-0.x86_64 systemctl enable kubelet
手动上传docker镜像到k8s_master和k8s_node节点
正式环境一般都是配置docker harbor 镜像仓库
cd /usr/local/src/ http://download.zhufunin.com/k8s_1.16/addon.tar.gz http://download.zhufunin.com/k8s_1.16/apiserver_1_16.tar.gz http://download.zhufunin.com/k8s_1.16/cordns_1_6_2.tar.gz http://download.zhufunin.com/k8s_1.16/etcd_3_3_15.tar.gz http://download.zhufunin.com/k8s_1.16/kube-controller-manager_1_16.tar.gz http://download.zhufunin.com/k8s_1.16/kube-proxy_1_16.tar.gz http://download.zhufunin.com/k8s_1.16/kube-scheduler_1_16.tar.gz http://download.zhufunin.com/k8s_1.16/kubernetes-dashboard_1_10.tar.gz http://download.zhufunin.com/k8s_1.16/metrics-server-amd64_0_3_1.tar.gz http://download.zhufunin.com/k8s_1.16/pause_3_1.tar.gz http://download.zhufunin.com/k8s_1.16/traefik_1_7_9.tar.gz
#手动解压镜像 docker load -i apiserver_1_16.tar.gz docker load -i cordns_1_6_2.tar.gz docker load -i etcd_3_3_15.tar.gz docker load -i kube-controller-manager_1_16.tar.gz docker load -i kube-proxy_1_16.tar.gz docker load -i kubernetes-dashboard_1_10.tar.gz docker load -i kube-scheduler_1_16.tar.gz docker load -i metrics-server-amd64_0_3_1.tar.gz docker load -i pause_3_1.tar.gz docker load -i traefik_1_7_9.tar.gz docker load -i addon.tar.gz
在k8s_master节点初始化k8s集群
#192.168.124.16为master的IP地址,请根据自己的情况修改
kubeadm init --apiserver-advertise-address 192.168.124.16 --kubernetes-version=v1.16.4 --pod-network-cidr=10.244.0.0/16
在k8s-master节点执行如下,这样才能有权限操作k8s资源
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
把k8s-node节点加入到k8s集群,在node节点操作
#在slave服务器上,跑如下命令 #192.168.124.16为master的IP #token请根据自己的情况做相应的修改 kubeadm join 192.168.124.16:6443 --token fegy3d.0c2ovmf4unkpbssk \ --discovery-token-ca-cert-hash sha256:fde13ccab75a1da4a0bedaa9a66c6ed82eacae63c98f22961f4cea12f3b8c589
在k8s-master节点查看k8s的组员,都是notready
kubectl get nodes
在k8s-master节点安装calico网络插件
kubectl apply -f calico.yaml
在k8s-master节点查看STATUS状态, 应该都是ready状态
kubectl get nodes
在k8s-master节点安装dashboard界面
kubectl apply -f kubernetes-dashboard.yaml
在k8s-master节点安装metrics监控插件
kubectl apply -f metrics.yaml
上面组件都安装之后,kubectl get pods -n kube-system,查看组件安装是否正常,STATUS状态是Running,说明组件正常
kubectl get pods -n kube-system
标签:mamicode local ipvsadm tom amp repo lin mkdir min
原文地址:https://www.cnblogs.com/faberbeta/p/13341070.html