标签:节点 save .com bec isa proc 版本 基础环境 hub
节点网络:192.168.0.0/24
Service网络:10.96.0.0/12
Pod网络:10.244.0.0/16(flannel默认)
1. 基于主机名解析
# vim /etc/hosts
192.168.0.8 master.dongfei.tech master
192.168.0.9 node01.dongfei.tech node01
192.168.0.10 node02.dongfei.tech node02
2. 关闭firewalld
# systemctl disable firewalld
# systemctl stop firewalld
3. 关闭selinux
# vim /etc/selinux/config
SELINUX=disabled
# setenforce 0
# reboot
4. 时间同步
# yum install chrony
# vim /etc/chrony.conf
server ntp.aliyun.com iburst
stratumweight 0
driftfile /var/lib/chrony/drift
rtcsync
makestep 10 3
bindcmdaddress 127.0.0.1
bindcmdaddress ::1
keyfile /etc/chrony.keys
commandkey 1
generatecommandkey
logchange 0.5
logdir /var/log/chrony
# systemctl enable chronyd
# systemctl start chronyd
# chronyc
chronyc> waitsync #手动同步
# vim /etc/yum.repos.d/docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
# yum localinstall http://mirrors.aliyun.com/centos-vault/7.3.1611/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm -y
# yum list docker-ce --showduplicates |sort -r #列出docker可用版本
# yum install -y --setopt=obsoletes=0 docker-ce-17.12.1.ce-1.el7.centos
# systemctl start docker
# systemctl enable docker
# docker load < k8s-images-1.11.1.tar
# docker image ls
k8s.gcr.io/kube-proxy-amd64 v1.11.1
k8s.gcr.io/kube-scheduler-amd64 v1.11.1
k8s.gcr.io/kube-apiserver-amd64 v1.11.1
k8s.gcr.io/kube-controller-manager-amd64 v1.11.1
k8s.gcr.io/coredns 1.1.3
k8s.gcr.io/etcd-amd64 3.2.18
k8s.gcr.io/pause 3.1
#!/bin/bash
k8s='kube-apiserver-amd64:v1.11.1
kube-controller-manager-amd64:v1.11.1
kube-scheduler-amd64:v1.11.1
kube-proxy-amd64:v1.11.1
pause:3.1
etcd-amd64:3.2.18
coredns:1.1.3'
for i in $k8s; do docker pull k8s.gcr.io/$i; done
docker save $(docker images | grep -v REPOSITORY | awk 'BEGIN{OFS=":";ORS=" "}{print $1,$2}') -o k8s-images-1.11.1.tar
# vim /etc/sysctl.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
# sysctl -p
# cat /proc/sys/net/bridge/bridge-nf-call-iptables
# cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
# cat /proc/sys/net/ipv4/ip_forward
1、配置yum源并安装k8s
# vim /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes Repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
# yum list kubeadm --showduplicates |sort -r
# yum install kubelet-1.11.1-0 kubeadm-1.11.1-0 kubectl-1.11.1-0 -y
2、初始化kubernetes_master
# systemctl enable kubelet
# vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false"
# kubeadm init --kubernetes-version=v1.11.1 --pod-network-cidr=10.224.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
kubeadm join 192.168.0.8:6443 --token 8zzav4.06acl9bocom2ee77 --discovery-token-ca-cert-hash sha256:31c20527733b81e0ab20daafe6a3f34e8d4b9da899dd0e1e6f6a47ec455e6d55
3、配置kubectl认证
# mkdir -p $HOME/.kube
# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# chown $(id -u):$(id -g) $HOME/.kube/config
# kubectl get componentstatus #查看组件状态
# kubectl get cs
4、部署flannel
# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
# kubectl get nodes
# kubectl get pods -n kube-system
1、安装kubeadm和kubelet
# yum list kubeadm --showduplicates |sort -r
# yum install kubelet-1.11.1-0 kubeadm-1.11.1-0 -y
# systemctl enable kubelet
# vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false"
2、将node加入集群(以下信息从master初始化完成后打印到屏幕的信息获取)
# kubeadm join 192.168.0.8:6443 --token 8zzav4.06acl9bocom2ee77 --discovery-token-ca-cert-hash sha256:31c20527733b81e0ab20daafe6a3f34e8d4b9da899dd0e1e6f6a47ec455e6d55 --ignore-preflight-errors=Swap
3、master上查看nodes状态
# kubectl get nodes
# kubectl get pods -n kube-system -o wide
标签:节点 save .com bec isa proc 版本 基础环境 hub
原文地址:https://www.cnblogs.com/L-dongf/p/10294385.html