ubuntu16.04 docker kubernetes(k8s) istio 安装

版本:

  docker: 19.03.5

  kubernetes: 1.17.0

  istio: 1.4.3

步骤一:给ubuntu换源

https://www.cnblogs.com/lfri/p/10612037.html

步骤二:装docker

sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce=5:19.03.5~3-0~ubuntu-xenial
sudo docker --version

https://www.cnblogs.com/jiyang2008/p/9014960.html

步骤三:装kubernetes(k8s)

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 6A030B21BA07F4FB
sudo apt-add-repository "deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main"
sudo apt update
sudo apt install -y kubelet kubeadm kubectl
kubeadm config images list

显示需要拉取的Images,如果提示权限,前面加sudo

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.17.0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.17.0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.17.0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.17.0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.4.3-0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.6.5
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.17.0 k8s.gcr.io/kube-apiserver:v1.17.0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.17.0 k8s.gcr.io/kube-controller-manager:v1.17.0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.17.0 k8s.gcr.io/kube-scheduler:v1.17.0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.17.0 k8s.gcr.io/kube-proxy:v1.17.0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.4.- k8s.gcr.io/etcd:3.4.-
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.6. k8s.gcr.io/coredns:1.6.

执行Init

kubeadm init --kubernetes-version=v1.17.0 --pod-network-cidr 192.168.0.0/

出现cgroupd有关错误:

cd /etc/docker
sudo touch daemon.json
sudo vim daemon.json // 添加内容:
{
"exec-opts":["native.cgroupdriver=systemd"]
}
sudo service docker restart
sudo systemctl status docker

出现swap有关错误:

swapoff -a

再次执行init命令:

ubuntu16.04 docker kubernetes(k8s) istio 安装

按照提示添加:

ubuntu16.04 docker kubernetes(k8s) istio 安装

执行完继续执行:

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl get pod -n kube-system  // 查看状态

ubuntu16.04 docker kubernetes(k8s) istio 安装

解决coredns的CrashLoopBackOff状态:

sudo vim /etc/resolv.conf
将nameserver的值改为8.8.8.8

ubuntu16.04 docker kubernetes(k8s) istio 安装

systemctl daemon-reload
service docker restart
# 耐心等待几分钟

ubuntu16.04 docker kubernetes(k8s) istio 安装

步骤四:安装istio

我是直接安装的最新版本

mkdir istio
cd istio
curl -L https://git.io/getLatestIstio | sh -

下载速度很慢,建议...

下载完后在istio目录下会有个istio-1.4.3文件夹

ubuntu16.04 docker kubernetes(k8s) istio 安装

vim /etc/profile

ubuntu16.04 docker kubernetes(k8s) istio 安装

添加上面提示的路径。

source /etc/profile
echo $PATH
istioctl verify-install

ubuntu16.04 docker kubernetes(k8s) istio 安装

查看版本:

istioctl version --remote=false

ubuntu16.04 docker kubernetes(k8s) istio 安装

将istio镜像部署到k8s:

在istio-1.4.3目录下输入:

kubectl apply install/kubernetes/istio-demo.yaml

k8s和istio安装成功!

深入学习:

https://preliminary.istio.io/zh/docs/examples/bookinfo/

问题:

1、重启后会遇到istioctl命令失效问题:

source /etc/profile    再来一遍就好了

2、coredns又变成CrashLoopBackOff状态

  再次重新执行一遍上面的解决方案

暂时采取上述方案解决,永久解决的方案待续...(2020-1-13)

参考:

https://blog.csdn.net/weixin_42711936/article/details/96897915

https://blog.csdn.net/weixin_42711936/article/details/97041456

https://blog.csdn.net/weixin_42711936/article/details/99311796

https://blog.csdn.net/weixin_34378767/article/details/92211061

https://www.cnblogs.com/liuluopeng/p/12098071.html

表示万分感谢!

上一篇:MySQL主从复制部署


下一篇:LVS实现负载均衡原理及安装配置