cat >> /etc/hosts <
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
sed -ri 's#(SELINUX=).*#\1disabled#' /etc/selinux/config
setenforce 0
systemctl disable firewalld && systemctl stop firewalld
cat < /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward=1
vm.max_map_count=262144
EOF
modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf
curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
cat < /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm package-key.gpg
EOF
yum clean all && yum makecache
yum install docker-ce -y
mkdir -p /etc/docker
vi /etc/docker/daemon.json
{
"registry-mirrors": ["http://f1361db2.m.daocloud.io"]
}
systemctl enable docker && systemctl start docker
docker ps
docker version
yum install -y kubelet-1.16.2 kubeadm-1.16.2 kubectl-1.16.2 --disableexcludes=kubernetes
kubeadm version
systemctl enable kubelet
mkdir ~/k8s-install && cd ~/k8s-install
vi kubeadm.yaml
########################################
apiVersion: kubeadm.k8s.io/v1beta2
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 192.168.89.10
bindPort: 6443
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: jackie001
taints:
- effect: NoSchedule
key: node-role.kubernetes.io/master
---
apiServer:
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: v1.16.2
networking:
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}
########################################
#################修改一下配置内容##########
advertiseAddress: 192.168.89.10 # 改为k8s_master内网ip
kubernetesVersion: v1.16.2 #修改K8S版本
podSubnet: 10.244.0.0/16 #添加pod网段,设置容器内网络
imageRepository: registry.aliyuncs.com/google_containers #修改阿里云镜像
########################################
kubeadm config print init-defaults > kubeadm.yaml
kubeadm config images list --config kubeadm.yaml
kubeadm config images pull --config kubeadm.yaml
docker images|grep aliyun
kubeadm init --config kubeadm.yaml
#####安装成功后出现该文字信息
############安装成功后出现该文字信息#################
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.89.10:6443 --token abcdef.0123456789abcdef \
--discovery-token-ca-cert-hash sha256:de68b9b6003e2dcdc51877c66ff4e6b9c8741b265d5797fabdb43aa76d7b606f
##########################################################################
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get pod -n kube-system
kubectl get pods
kubectl get nodes
kubectl get pods -A
kubectl get nodes -owide
......好多指令不打了 俺想下班呜呜呜呜
kubeadm join 192.168.89.10:6443 --token abcdef.0123456789abcdef \
--discovery-token-ca-cert-hash sha256:f78b5772ed94954473d1f89243ac67f02318b37abba9ca4fd7115b1c0f2b7676
wget https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml
vim kube-flannel.yml
进去后输入“:190”
- --iface=ens192
docker pull quay.io/coreos/flannel:v0.11.0-amd64
#显示节点详细信息#kubectl get nodes -owide!
kubectl get pods -A
#K8S的配置 组件非常多 可以利用namespace,进行分类查看#
kubectl create -f kube-flannel.yml
kubectl get pod -n kube-system
kubectl get nodes
kubectl get pods -A