kubespray安装kubernetes

基于kubespray安装k8s集群,使用分支是v2.4.0。

https://github.com/kubernetes-incubator/kubespray/tree/v2.4.0

安装的版本是

kubernetes v1.9.2

etcd v3.2.4

calico v2.5.0

docker v1.13

前提是

Ansible v2.4 (or newer) and python-netaddr

Jinja 2.9 (or newer)

target servers must have access to the Internet

target servers are configured to allow IPv4 forwarding.

ssh key must be copied to all the servers

disable your firewall

阿里云买了三台按需云服务器,cents 7.4系统

yum update.

3.10.0-693.17.1.el7.x86_64

CentOS Linux release 7.4.1708 (Core)

47.91.217.39(公) 172.31.19.31(私有)

47.75.4.12(公) 172.31.19.29(私有) (ansible host)

47.91.213.83(公)172.31.19.30(私有)

1、登入三台机器关闭防火墙(阿里机器默认没有开启防火墙,依赖于外部的安全组)

hostnamectl set-hostname localhost

systemctl stop firewalld

systemctl disable firewalld

swapoff -a

2、登入ansible host

yum install -y epel-release

yum install -y python-pip python-netaddr ansible git

pip install --upgrade Jinja2

ssh-keygen

ssh-copy-id root@172.31.19.29

ssh-copy-id root@172.31.19.30

ssh-copy-id root@172.31.19.31

git clone https://github.com/kubernetes-incubator/kubespray.git

cd kubespray

git checkout v2.4.0 -b myv2.4.0

cp inventory/inventory.example inventory/inventory.cfg

修改inventory

vi inventory/inventory.cfg

[all]

node1 ansible_ssh_host=172.31.19.29 ip=172.31.19.29

node2 ansible_ssh_host=172.31.19.30 ip=172.31.19.30

node3 ansible_ssh_host=172.31.19.31 ip=172.31.19.31

[kube-master]

node1

node2

node3

[etcd]

node1

node2

node3

[kube-node]

node1

node2

node3

[k8s-cluster:children]

kube-node

kube-master

备份并修改安装的配置

cp inventory/group_vars/all.yml inventory/group_vars/all.yml.bak

cp inventory/group_vars/k8s-cluster.yml inventory/group_vars/k8s-cluster.yml.bak

vi inventory/group_vars/all.yml

bootstrap_os: centos

vi inventory/group_vars/k8s-cluster.yml

dashboard_enabled: false

kube_api_pwd: “hello-world8888”

###修改下载的包,将国外下载慢的包,改成用阿里的

vi roles/download/defaults/main.yml

etcd_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/etcd"

calicoctl_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/ctl"

calico_node_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/node"

calico_cni_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/cni"

calico_policy_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/kube-policy-controller"

calico_rr_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/routereflector"

hyperkube_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/hyper-kube"

pod_infra_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/pause-amd64"

nginx_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/nginx"

kubedns_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/k8s-dns-kube-dns-amd64"

dnsmasq_nanny_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/k8s-dns-dnsmasq-nanny-amd64"

dnsmasq_sidecar_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/k8s-dns-sidecar-amd64"

kubednsautoscaler_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/cluster-proportional-autoscaler-amd64"

vi roles/kubernetes-apps/ansible/defaults/main.yml

kubedns_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/k8s-dns-kube-dns-amd64"

dnsmasq_nanny_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/k8s-dns-dnsmasq-nanny-amd64"

dnsmasq_sidecar_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/k8s-dns-sidecar-amd64"

kubednsautoscaler_image_repo: "registry.cn-hangzhou.aliyuncs.com/linkcloud/cluster-proportional-autoscaler-amd64"

部署

ansible-playbook -b -i inventory/inventory.cfg cluster.yml --flush-cache


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装Kubernetes Node需要以下步骤: 1. 首先,确保你的操作系统满足Kubernetes的最低要求。Kubernetes支持多种操作系统,包括Linux、Windows和MacOS。你可以选择适合你的操作系统版本。 2. 安装Docker:Kubernetes使用Docker来创建和管理容器。因此,在安装Kubernetes之前,你需要先安装Docker。根据你的操作系统,可以参考Docker官方文档进行安装。 3. 安装KubernetesKubernetes提供了多种安装方式,包括二进制文件安装、包管理器安装和使用工具自动化安装等。你可以根据自己的需求选择适合的安装方式。 - 二进制文件安装:这是最基本的安装方式,需要手动下载Kubernetes的二进制文件,并将其添加到系统的PATH环境变量中。然后,你需要配置Kubernetes的各种组件,如kubelet、kube-proxy等。 - 包管理器安装:一些Linux发行版提供了预编译的Kubernetes软件包,可以通过包管理器进行安装。例如,对于Ubuntu,你可以使用apt-get命令进行安装。 - 自动化安装:如果你想简化安装过程,可以使用一些自动化工具,如kubeadm、kubespray等。这些工具可以帮助你自动化地部署和配置Kubernetes集群。 4. 配置Kubernetes Node:安装完成后,你需要对Kubernetes Node进行一些配置。主要包括设置节点的名称、IP地址、容器运行时等。这些配置可以通过编辑kubelet的配置文件或使用命令行参数来完成。 5. 启动Kubernetes Node:完成配置后,你可以启动Kubernetes Node,并验证它是否成功加入到Kubernetes集群中。你可以使用kubectl命令来查看节点的状态和信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值