this Docker version is not on the list of validated versions: 19.03.5. Latest validated version: 18.09
关闭swap
swapoff -a
vim /etc/fstab
#UUID=d214c3f8-e09e-43bc-bd6b-4332a008cd98 /boot xfs defaults 0 0
#/dev/mapper/centos-swap swap swap defaults 0 0
https://www.jianshu.com/p/6f3268ce642f
系统初始化
关闭防火墙,selinux,基于主机名访问(dns或者dns),同步时间(时间不一致,集群运行异常,如不能启动),关闭swap分区
# 关掉 selinux
setenforce 0
sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
# 关掉防火墙
systemctl stop firewalld
systemctl disable firewalld
#关闭swap
swapoff -a
####
echo "vm.swappiness = 0">> /etc/sysctl.conf
swapoff -a && swapon -a
sysctl -p
#开启转发的参数,根据实际报错情况开启,一般有如下三项
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
#加载内核配置
sysctl --system /etc/sysctl.d/k8s.conf
# 加载ipvs相关内核模块
# 如果重新开机,需要重新加载
modprobe ip_vs
modprobe ip_vs_rr
modprobe ip_vs_wrr
modprobe ip_vs_sh
modprobe nf_conntrack_ipv4
lsmod | grep ip_vs
安装virtualbox
安装docker
# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装 Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# Step 4: 开启Docker服务
sudo service docker start
注意:其他注意事项在下面的注释中
# 官方软件源默认启用了最新的软件,您可以通过编辑软件源的方式获取各个版本的软件包。例如官方并没有将测试版本的软件源置为可用,你可以通过以下方式开启。同理可以开启各种测试版本等。
# vim /etc/yum.repos.d/docker-ce.repo
# 将 [docker-ce-test] 下方的 enabled=0 修改为 enabled=1
#
# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
# Loading mirror speeds from cached hostfile
# Loaded plugins: branch, fastestmirror, langpacks
# docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
# docker-ce.x86_64 17.03.1.ce-1.el7.centos @docker-ce-stable
# docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
# Available Packages
# Step2 : 安装指定版本的Docker-CE: (VERSION 例如上面的 17.03.0.ce.1-1.el7.centos)
# sudo yum -y install docker-ce-[VERSION]
# 注意:在某些版本之后,docker-ce安装出现了其他依赖包,如果安装失败的话请关注错误信息。例如 docker-ce 17.03 之后,需要先安装 docker-ce-selinux。
# yum list docker-ce-selinux- --showduplicates | sort -r
# sudo yum -y install docker-ce-selinux-[VERSION]
# 通过经典网络、VPC网络内网安装时,用以下命令替换Step 2中的命令
# 经典网络:
# sudo yum-config-manager --add-repo http://mirrors.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo
# VPC网络:
# sudo yum-config-manager --add-repo http://mirrors.could.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo
查看最新的版本号
wget http://storage.googleapis.com/kubernetes-release/release/stable.txt
安装kubectl使用最新的版本号
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=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 kubectl
---
wget "https://storage.googleapis.com/kubernetes-release/release/v1.15.1/bin/linux/amd64/kubectl" -O "/usr/local/bin/kubectl"
cp kubectl /usr/local/bin/
chmod +x /usr/local/bin/kubectl
通过 curl 命令安装 kubectl 可执行文件
通过以下命令下载 kubectl 的最新版本:
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
若需要下载特定版本的 kubectl,请将上述命令中的 $(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) 部分替换成为需要下载的 kubectl 的具体版本即可。
例如,如果需要下载用于 Linux 的 v1.17.0 版本,需要使用如下命令:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl
修改所下载的 kubectl 二进制文件为可执行模式。
chmod +x ./kubectl
将 kubectl 可执行文件放置到你的 PATH 目录下。
sudo mv ./kubectl /usr/local/bin/kubectl
https://kubernetes.io/zh/docs/tasks/tools/install-kubectl/
自动开启 kubectl 自动补全
yum install bash-completion -y
echo "source <(kubectl completion bash)" >> ~/.bashrc
安装minikube
首先记住阿里云发布的minikube地址
https://github.com/AliyunContainerService/minikube
查看最新版本
https://github.com/kubernetes/minikube/releases
#查看是否支持虚拟化
egrep -q 'vmx|svm' /proc/cpuinfo && echo yes || echo no
#下载安装
curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.2.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
从1.5.0版本开始,Minikube缺省使用本地最好的驱动来创建Kubernetes本地环境
minikube start
#virtualbox启动
minikube start --vm-driver=virtualbox
#start a new cluster
minikube start -p <name>
#增加内存
minikube config set memory 4096
minikube config set vm-driver none
#不用虚拟化
minikube start --vm-driver=none
minikube status
#登录虚拟机
~ minikube ssh
~ minikube stop
~ minikube delete
#重置,重置之后会清理所有缓存的镜像,重头开始
rm-rf~/.minikube
#打开Kubernetes控制台
minikube dashboard
minikube dashboard --url
kubectl run nginx --image=nginx --port=8080
# see the pod states by running
kubectl get po -A
kubectl cluster-info
kubectl get pods --all-namespaces
kubectl cluster-info
kubectl cluster-info dump
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version.
Use kubectl run --generator=run-pod/v1 or kubectl create instead.
https://blog.csdn.net/weixin_43695104/article/details/100703437
https://kubernetes.io/zh/docs/tasks/tools/install-minikube/
https://minikube.sigs.k8s.io/docs/start/linux/
启动minikube
vm-driver为none 默认为:virtualbox
镜像下载使用docker国内源
minikube start --vm-driver=none --registry-mirror=https://registry.docker-cn.com
Temporary Error: unexpected response code: 503
解决方案:
根据 minikube dashboard returns 503 error on macOS 的答案,删除 minikube:
minikube delete -p minikube
重启启动,好了。
minikube 在 运行 dashboard 时 报错 exec: "xdg-open"
需要安抓如下依赖:
yum install xdg-utils
xdg-open: no method available for opening
- 添加集群对外访问代理:
nohub kubectl proxy --port=[需要暴露的端口号] --address='[服务器IP]' --accept-hosts='^[外部访问服务器的IP]$' >/dev/null 2>&1&
例如:
nohup kubectl proxy --port=8088 --address='10.30.80.200' --accept-hosts='^192.168.1.(\d)+$' >/dev/null 2>&1&
k8s.gcr.io国内无法连接解决方法
https://www.jianshu.com/p/d6848c711436
k8s.gcr.io国内无法连接解决方法
[WARNING Swap]: running with swap on is not supported. Please disable swap
[WARNING FileExisting-socat]: socat not found in system path
[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 19.03.5. Latest validated version: 18.09
[WARNING Hostname]: hostname "minikube" could not be reached
[WARNING Hostname]: hostname "minikube": lookup minikube on 114.114.114.114:53: no such host
[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...
解决
[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1
echo "1" >/proc/sys/net/bridge/bridge-nf-call-iptables
kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"
https://segmentfault.com/a/1190000020478007
🤹 Configuring local host environment ...
⚠️ The 'none' driver provides limited isolation and may reduce system security and reliability.
⚠️ For more information, see:
👉 https://github.com/kubernetes/minikube/blob/master/docs/vmdriver-none.md
⚠️ kubectl and minikube configuration will be stored in /root
⚠️ To use kubectl or minikube commands as your own user, you may
⚠️ need to relocate them. For example, to overwrite your own settings:
▪ sudo mv /root/.kube /root/.minikube $HOME
▪ sudo chown -R $USER $HOME/.kube $HOME/.minikube
💡 This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
⌛ Verifying: apiserver proxy etcd scheduler controller dns
检验是否能用
#打开控制台
minikube dashboard
kubectl run nginx --image=nginx --port=8080
kubectl get pod
https://www.jianshu.com/nb/40066919
https://kubernetes.io/zh/docs/setup/learning-environment/#minikube-%e5%8a%9f%e8%83%bd
https://my.oschina.net/u/228832/blog/3079150
https://www.cnblogs.com/linguoguo/p/10619460.html
https://yq.aliyun.com/articles/221687
网友评论