安裝k8s-1master多node節點

卸載比較新的18.3版本,安裝17.03版本node

刪除舊版本
 
 

  sudo yum remove docker \
  docker-client \
  docker-client-latest \
  docker-common \
  docker-latest \
  docker-latest-logrotate \
  docker-logrotate \
  docker-selinux \
  docker-engine-selinux \
  docker-enginelinux

   sudo yum install -y yum-utils device-mapper-persistent-data lvm2git

   sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repogithub

 yum install -y --setopt=obsoletes=0 \
docker-ce-17.03.2.ce-1.el7.centos.x86_64 \
docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch
/ect/docker/json: { "registry-mirrors": [ "https://iv7stq00.mirror.aliyuncs.com" ], "graph": "/opt/docker", "hosts": [ "tcp://0.0.0.0:2375", "unix:///var/run/docker.sock" ] } 新版本存儲root目錄是參數 data-root 舊版本爲 graph

安裝k8s以前的準備工做docker

關閉防火牆
systemctl stop firewalld.service
systemctl disable firewalld.service
永久關閉SELinux
vim /etc/selinux/config
SELINUX=disabled
同步集羣系統時間
yum -y install ntp
ntpdate 0.asia.pool.ntp.org
重啓機器
reboot
  關閉SWAP  
  swapoff -a
 

安裝yum源json

#阿里雲yum源:
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    yum clean all
    yum makecache
#docker yum源
    cat >> /etc/yum.repos.d/docker.repo <<EOF
    [docker-repo]
    name=Docker Repository
    baseurl=http://mirrors.aliyun.com/docker-engine/yum/repo/main/centos/7
    enabled=1
    gpgcheck=0
    EOF
#kubernetes yum源
    cat >> /etc/yum.repos.d/kubernetes.repo <<EOF
    [kubernetes]
    name=Kubernetes
    baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
    enabled=1
    gpgcheck=0
    EOF

yum -y install docker kubeadm kubelet kubectl

 

下載k8s鏡像腳本執行vim

images=(kube-proxy-amd64:v1.11.0 kube-scheduler-amd64:v1.11.0 kube-controller-manager-amd64:v1.11.0 kube-apiserver-amd64:v1.11.0
etcd-amd64:3.2.18 coredns:1.1.3 pause-amd64:3.1 kubernetes-dashboard-amd64:v1.8.3 k8s-dns-sidecar-amd64:1.14.9 k8s-dns-kube-dns-amd64:1.14.9
k8s-dns-dnsmasq-nanny-amd64:1.14.9 )
for imageName in ${images[@]} ; do
docker pull keveon/$imageName
docker tag keveon/$imageName k8s.gcr.io/$imageName
docker rmi keveon/$imageName
done
# 我的新加的一句,V 1.11.0 必加
docker tag da86e6ba6ca1 k8s.gcr.io/pause:3.1

docker pull registry.cn-hangzhou.aliyuncs.com/pycf/flannel:v0.10.0-amd64

  docker tag registry.cn-hangzhou.aliyuncs.com/pycf/flannel:v0.10.0-amd64 quay.io/coreos/flannel:v0.10.0-amd64
  docker rmi -f registry.cn-hangzhou.aliyuncs.com/pycf/flannel:v0.10.0-amd64centos

 

啓動master節點api

kubeadm init --kubernetes-version=1.11.0 --token-ttl 0 --pod-network-cidr=10.244.0.0/16
root export KUBECONFIG=/etc/kubernetes/admin.conf

安裝網絡插件網絡


vim /etc/sysctl.conf,添加如下內容 net.ipv4.ip_forward=1 net.bridge.bridge-nf-call-iptables=1 net.bridge.bridge-nf-call-ip6tables=1 修改後,及時生效 sysctl -p
安裝flannel網絡插件
wget https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml

kubectl apply -f kube-flannel.yml
 
 
 

添加node節點

systemctl start kubelet
kubeadm join 10.211.55.6:6443 --token 63nuhu.quu72c0hl95hc82m --discovery-token-ca-cert-hash sha256:3971ae49e7e5884bf191851096e39d8e28c0b77718bb2a413638057da66ed30a

 安裝Dashboard 

下載 https://github.com/gh-Devin/kubernetes-dashboard 文件到新建目錄ds下
在ds目錄下新建文件dashboard-admin.yaml 內容以下:
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: kubernetes-dashboard
  labels:
    k8s-app: kubernetes-dashboard
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: kubernetes-dashboard
  namespace: kube-system

kubectl -n kube-system create -f . 啓動 訪問 master:30090

相關文章
相關標籤/搜索