問題一:先嘗試了docker-ce的安裝,再學習kubernetes,發現包沖突,安裝不上了。
# yum install -y etcd kubernetes Error: docker-ce-cli conflicts with 2:docker-1.13.1-94.gitb2f74b2.el7.centos.x86_64 Error: docker-ce conflicts with 2:docker-1.13.1-94.gitb2f74b2.el7.centos.x86_64
原因:
安裝kubernetes之前已經安裝了docker
解決方法:卸載docker服務
卸載docker:yum remove -y 'rpm -qa |grep docker'
刪除容器鏡像:rm -rf /var/lib/docker
docker 卸載
使用yum安裝docker(安裝過程可以參照linux 安裝docker),如需卸載docker可以按一下步驟操作:
1、查看當前docker狀態

如果是運行狀態則停掉,設置過systemctl enable docker 自啟動的,還需要
systemctl stop docker
systemctl disable docker
2、查看yum安裝的docker文件包
yum list installed |grep docker

查看docker相關的rpm源文件
rpm -qa |grep docker

3、刪除所有安裝的docker文件包
yum -y remove docker-*.x86_64

其他的docker相關的安裝包同樣刪除操作,刪完之后可以再查看下docker rpm源
rpm -qa |grep docker

4、刪除docker的鏡像文件,默認在/var/lib/docker目錄下

刪除上述的docker目錄
rm -rf /var/lib/docker

到此docker卸載就完成了
再次安裝kubernetes,安裝成功,而且會自動安裝docker
問題二:
2.1
# etcdctl mk /atomic.io/network/config '{"Network":"192.168.3.4/16"}'
Error: client: etcd cluster is unavailable or misconfigured; error #0: dial tcp 127.0.0.1:2379: connect: connection refused; error #1: dial tcp 127.0.0.1:4001: connect: connection refused
error #0: dial tcp 127.0.0.1:2379: connect: connection refused
error #1: dial tcp 127.0.0.1:4001: connect: connection refused
原因:
如果出現如上的錯誤,是因為ETCD_LISTEN_CLIENT_URLS參數沒有配置http://127.0.0.1:2379而導致的
解決方法:
將 # /etc/etcd/etcd.conf 中的ETCD_LISTEN_CLIENT_URLS參數改為:
ETCD_LISTEN_CLIENT_URLS="http://127.0.0.1:2379"
2.2
# etcdctl mk /atomic.io/network/config '{"Network":"192.168.3.4/16"}'
Error: dial tcp 192.168.3.4:2379: connect: connection refused
原因:
ETCD_LISTEN_CLIENT_URLS參數沒有配置本地ip “http://192.168.3.4:2379” 而導致的
解決方法:
將 # /etc/etcd/etcd.conf 中的ETCD_LISTEN_CLIENT_URLS參數改為: ETCD_LISTEN_CLIENT_URLS="http://192.168.37.49:2379,http://127.0.0.1:2379"
問題三:啟動docker服務失敗
# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/docker.service.d
└─flannel.conf
Active: failed (Result: exit-code) since Tue 2019-06-25 11:16:41 CST; 4min 15s ago
Docs: http://docs.docker.com
Process: 20982 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 20982 (code=exited, status=1/FAILURE)
Jun 25 11:16:41 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Jun 25 11:16:41 localhost.localdomain dockerd-current[20982]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file:...rom file: 1500)
Jun 25 11:16:41 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jun 25 11:16:41 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jun 25 11:16:41 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Jun 25 11:16:41 localhost.localdomain systemd[1]: docker.service failed.
原因是: 安裝kubernets之前安裝過的docker殘留文件影響了kubernets安裝的docker啟動 解決方法: 將/etc/docker/daemon.json刪除,重新啟動即可。
問題四:創建k8s管理mysql的pod時:
# kubectl create -f mysql.yaml error: error validating "mysql.yaml": error validating data: couldn't find type: v1beta1.Deployment; if you choose to ignore these errors, turn validation off with --validate=false
原因:
kubectl 的版本是1.5版本的
# kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
解決方法:
將mysql.yaml腳本中的 “ apiVersion: apps/v1beta1 ” 改為 “apiVersion: extensions/v1beta1 ” 即可
不同的apiversion解釋: apps API組將是v1部署類型所在的位置 . apps/v1beta1 版本已在1.6.0中添加,因此如果您有1.5.x客戶端或服務器,則仍應使用 extensions/v1beta1 版本 . apps/v1beta1 和 extensions/v1beta1 部署類型相同,但在通過 apps API創建時,會使用一些改進的默認值

