准备:

一台x86 linux主机,2C2G即可,不要安装docker和kubernetes。建议最小化linux系统就行

简单做一个初始化

echo 172.16.0.58 k8s-master k8s-master  >> /etc/hosts

hostnamectl set-hostname k8s-master

swapoff -a  

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

cat >> /etc/security/limits.conf << EOF
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535
EOF

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

sysctl -p

docker源:

yum install -y yum-utils
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast

kubernetes源:

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
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

获取rpm离线包:

yum install --downloadonly --downloaddir=/opt/k8s-offline-package/ docker-ce-18.09.9 docker-ce-cli-18.09.9 containerd.io

yum install --downloadonly --downloaddir=/opt/k8s-offline-package/ kubelet-1.18.1-0 kubeadm-1.18.1-0 kubectl-1.18.1-0

下面是部署k8s,老司机可以跳过,直接看最后:


cd /opt/k8s-offline-package/

#rpm包安装docker和kubelet,kubectl,kubeadm
rpm -ivh *.rpm --nodeps
#启动docker
systemctl start docker
systemctl enable docker
systemctl enable kubelet

#修改cgroups为systemd
mkdir /etc/docker
cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
systemctl restart docker

#初始化k8s
kubeadm init \
  --apiserver-advertise-address=172.16.0.58 \
  --image-repository registry.aliyuncs.com/google_containers \
  --kubernetes-version=v1.18.1 \
  --service-cidr=10.96.0.0/12 \
  --pod-network-cidr=10.244.0.0/16 \
  --ignore-preflight-errors=all

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 calico.yaml

取消master的污点,这样就可以在master部署ingress了

kubectl taint node k8s-master node-role.kubernetes.io/master:NoSchedule-

kubectl apply -f ingress-controller-0.49.yaml

等待所有pod,running或者completed

获取镜像包:

打包本机上的所有镜象

docker save $(docker images | awk '{print $1":"$2}' | sort |uniq | grep -v REPOSITORY) -o all.tar

/opt/k8s-offline-package/下面的rpm包和all.tar镜像包就有了,打包即可

tar -czvf k8s-1.18-offline.tar.gz ./*

k8s1.23离线包 链接:https://pan.baidu.com/s/1ZQ3w1iQa0omjSPXvG-MREQ 
提取码:6goo 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐