kubeadmin 安装k8s集群

系统设置

  • CentOS Linux release 7.6.1810 (Core)

修改主机名

vim /etc/hostname 
k8s-master
   
hostname -F /etc/hostname

设置本地解析

 vim /etc/hosts
 172.16.227.40    k8s-master
    

关闭防火墙

systemctl disable firewalld

关闭selinux

 sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config

设置启动参数

cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

sysctl --system

安装docker,kubeadm, kubelet and kubectl

安装docker

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install docker-ce-18.06.3.ce-3.el7
systemctl start docker
systemctl enable docker

kubeadm, kubelet and kubectl

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
EOF
yum install -y kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet
# 添加--image-repository参数,默认镜像下载会失败,你懂的
kubeadm init --kubernetes-version=v1.14.2 --pod-network-cidr=10.244.0.0/16 --image-repository registry.aliyuncs.com/google_containers

# docker images 镜像如下:
registry.aliyuncs.com/google_containers/kube-proxy:v1.14.2
registry.aliyuncs.com/google_containers/kube-apiserver:v1.14.2
registry.aliyuncs.com/google_containers/kube-controller-manager:v1.14.2
registry.aliyuncs.com/google_containers/kube-scheduler:v1.14.2
registry.aliyuncs.com/google_containers/coredns:1.3.1
registry.aliyuncs.com/google_containers/etcd:3.3.10 
registry.aliyuncs.com/google_containers/pause:3.1    
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
# 安装网络
kubectl apply -f kube-flannel.yml

#查看集群装填 
kubectl get pods -n kube-system

coredns-8686dcc4fd-2xkmr             1/1     Running   0          4m56s
coredns-8686dcc4fd-6lmlt             1/1     Running   0          4m56s
etcd-k8s-master                      1/1     Running   0          4m3s
kube-apiserver-k8s-master            1/1     Running   0          4m15s
kube-controller-manager-k8s-master   1/1     Running   0          4m1s
kube-flannel-ds-amd64-ptv62          1/1     Running   0          2m33s
kube-proxy-7ffzw                     1/1     Running   0          4m57s
kube-scheduler-k8s-master            1/1     Running   0          4m11s
posted @ 2019-05-20 23:03  以行贱言  阅读(2127)  评论(1编辑  收藏  举报