以下内容介绍Ubuntu 18.04操作系统 + Kuberntes 1.11.1 + Istio 1.0组合的部署,实现起来不难,下面为具体步骤。
1.安装Docker #准备软件源 sudo apt install docker.io sudo systemctl enable docker 确保kubelet使用的cgroup driver 与 Docker的一致。要么使用下面的方法更新 Docker: cat << EOF > /etc/docker/daemon.json { "exec-opts": ["native.cgroupdriver=systemd"] } EOF 然后重启Docker服务,运行: sudo systemctl daemon-reload sudo systemctl restart docker 请参考详细介绍在Ubuntu 18.04 LTS下docker容器的安装一文:https://ywnz.com/linuxjc/2220.html
2.Kubernetes 1.11.1安装 按照以下步骤操作: curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main" #安装基础支持软件 sudo apt install kubeadm kubectl kubelet #关闭磁盘交换 sudo swapoff -a #清除防火墙设置 sudo iptables -F #设置域名 sudo hostnamectl set-hostname kubernetes-master #初始化环境,注意这个版本号一定要指定(否则会挂起)。 #指定使用CoreDNS作为名称服务,可以不指定--feature-gates CoreDNS=true,则使用默认的kubedns服务。 sudo kubeadm init --kubernetes-version=v1.11.1 --pod-network-cidr=10.244.0.0/16 --feature-gates CoreDNS=true #创建用户配置文件 mkdir -p $HOME/.kube kubernetes-master:~$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config kubernetes-master:~$ sudo chown $(id -u):$(id -g) $HOME/.kube/config #安装网络 kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml #启用主控机同时作为工作节点 kubectl taint nodes --all node-role.kubernetes.io/master- #查看结果 kubectl get pods --all-namespaces
3.Kubernetes 1.11.1安装有两个问题 1].目前kubernetes还没有Ubuntu 18.04的编好的版本,用的Ubuntu 16.04 xenial的二进制文件。 2].上面的cloud.google的key会出错,使用下面的方法来获取: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 6A030B21BA07F4FB 然后执行sudo apt update及其后面的安装步骤。
4.提前拉取容器镜像 目前kubernetes最新版本是1.11.1,可以从我做的镜像库上拉取: echo "" echo "====================================================" echo "Pull Kubernetes 1.11.1 Images from aliyuncs.com ..." echo "====================================================" echo "" MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings ## 拉取镜像 docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver-amd64:v1.11.1 docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager-amd64:v1.11.1 docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler-amd64:v1.11.1 docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy-amd64:v1.11.1 docker pull ${MY_REGISTRY}/k8s-gcr-io-etcd-amd64:3.2.18 docker pull ${MY_REGISTRY}/k8s-gcr-io-pause-amd64:3.1 docker pull ${MY_REGISTRY}/k8s-gcr-io-coredns:1.1.3 ## 添加Tag docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver-amd64:v1.11.1 k8s.gcr.io/kube-apiserver-amd64:v1.11.1 docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler-amd64:v1.11.1 k8s.gcr.io/kube-scheduler-amd64:v1.11.1 docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager-amd64:v1.11.1 k8s.gcr.io/kube-controller-manager-amd64:v1.11.1 docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy-amd64:v1.11.1 k8s.gcr.io/kube-proxy-amd64:v1.11.1 docker tag ${MY_REGISTRY}/k8s-gcr-io-etcd-amd64:3.2.18 k8s.gcr.io/etcd-amd64:3.2.18 docker tag ${MY_REGISTRY}/k8s-gcr-io-pause-amd64:3.1 k8s.gcr.io/pause-amd64:3.1 docker tag ${MY_REGISTRY}/k8s-gcr-io-coredns:1.1.3 k8s.gcr.io/coredns:1.1.3 echo "" echo "====================================================" echo "Pull Kubernetes 1.11.0 Images FINISHED." echo "into registry.cn-hangzhou.aliyuncs.com/openthings, " echo "by openthings@https://my.oschina.net/u/2306127." echo "====================================================" echo "" 把上面的内容保存为脚本文件,运行即可。 然后再去运行kubeadm init进行集群的初始化工作。
5.然后安装Istio 1.0 Istio 1.0快速安装到Kubernetes集群的方法如下: 下载: $ curl -L https://git.io/getLatestIstio | sh - 或者: wget https://github.com/istio/istio/releases/download/1.0.0/istio-1.0.0-linux.tar.gz 设置路径: export PATH=$PWD/bin:$PATH 下载镜像: docker pull docker.io/istio/proxyv2:1.0.0 docker pull docker.io/istio/proxy_init:1.0.0 docker pull docker.io/istio/sidecar_injector:1.0.0 docker pull docker.io/istio/galley:1.0.0 docker pull docker.io/istio/mixer:1.0.0 docker pull docker.io/istio/pilot:1.0.0 docker pull docker.io/istio/citadel:1.0.0 或者,从Aliytun下载镜像: echo "" echo "====================================================" echo "Pull Istio 1.0.0 Images from aliyuncs.com ..." echo "====================================================" echo "" echo "docker tag to openthings ..." ## 添加Tag for registry.cn-hangzhou.aliyuncs.com/openthings MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings echo "" echo "====================================================" echo "" ## Pull镜像 echo "" echo "1./istio-proxyv2:1.0.0" docker pull ${MY_REGISTRY}/istio-proxyv2:1.0.0 docker tag ${MY_REGISTRY}/istio-proxyv2:1.0.0 docker.io/istio/proxyv2:1.0.0 echo "" echo "2.istio-proxy_init:1.0.0" docker pull ${MY_REGISTRY}/istio-proxy_init:1.0.0 docker tag ${MY_REGISTRY}/istio-proxy_init:1.0.0 docker.io/istio/proxy_init:1.0.0 echo "" echo "3.istio-sidecar_injector:1.0.0" docker pull ${MY_REGISTRY}/istio-sidecar_injector:1.0.0 docker tag ${MY_REGISTRY}/istio-sidecar_injector:1.0.0 docker.io/istio/sidecar_injector:1.0.0 echo "" echo "4.istio-galley:1.0.0" docker pull ${MY_REGISTRY}/istio-galley:1.0.0 docker tag ${MY_REGISTRY}/istio-galley:1.0.0 docker.io/istio/galley:1.0.0 echo "" echo "5.istio-mixer:1.0.0" docker pull ${MY_REGISTRY}/istio-mixer:1.0.0 docker tag ${MY_REGISTRY}/istio-mixer:1.0.0 docker.io/istio/mixer:1.0.0 echo "" echo "6.istio-pilot:1.0.0" docker pull ${MY_REGISTRY}/istio-pilot:1.0.0 docker tag ${MY_REGISTRY}/istio-pilot:1.0.0 docker.io/istio/pilot:1.0.0 echo "" echo "7.istio/citadel:1.0.0" docker pull ${MY_REGISTRY}/istio-citadel:1.0.0 docker tag ${MY_REGISTRY}/istio-citadel:1.0.0 docker.io/istio/citadel:1.0.0 echo "" echo "Extra=========================================" echo "8.coreos-hyperkube:v1.7.6_coreos.0" docker pull ${MY_REGISTRY}/coreos-hyperkube:v1.7.6_coreos.0 docker tag ${MY_REGISTRY}/coreos-hyperkube:v1.7.6_coreos.0 quay.io/coreos/hyperkube:v1.7.6_coreos.0 echo "" echo "9.prom-prometheus:latest" docker pull ${MY_REGISTRY}/prom-prometheus:latest docker tag ${MY_REGISTRY}/prom-prometheus:latest docker.io/prom/prometheus:latest echo "" echo "10.statsd-exporter:latest" docker pull ${MY_REGISTRY}/statsd-exporter:latest docker tag ${MY_REGISTRY}/statsd-exporter:latest prom/statsd-exporter:latest echo "" echo "====================================================" echo "Push Istio 1.0.0 Images FINISHED." echo "into registry.cn-hangzhou.aliyuncs.com/openthings, " echo "by openthings@https://my.oschina.net/u/2306127." echo "====================================================" echo "" 安装: helm template install/kubernetes/helm/istio --name istio --namespace istio-system > ./istio.yaml kubectl create namespace istio-system kubectl create -f ./istio.yaml
6.Kubenetes服务不启动问题 1].重启系统后,发现kubelet服务没有起来,首先检查: nano /etc/fstab #注释掉里面的swap一行。 2].然后在 /etc/systemd/system/kubelet.service.d/10-kubeadm.conf 文件加入KUBELET_CGROUP_ARGS和KUBELET_EXTRA_ARGS参数,注意在启动参数中也要加入,如下: [Service] Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=systemd" Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false" ExecStart= ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHZ_ARGS $KUBELET_CADVISOR_ARGS $KUBELET_CERTIFICATE_ARGS $KUBELET_CGROUP_ARGS $KUBELET_EXTRA_ARGS 3].最后重启kubelet服务,运行: systemctl daemon-reload systemctl restart kubelet
相关主题 |