`
sillycat
  • 浏览: 2527363 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Rancher and k8s 2019(3)Clean Installation on CentOS7

阅读更多
Rancher and k8s 2019(3)Clean Installation on CentOS7

Set Up 3 machines
192.168.56.110     rancher-home
192.168.56.111     rancher-worker1
192.168.56.112     rancher-worker2

Set Up rancher-home
The network config
Go to the network setting directory
> cd /etc/sysconfig/network-scripts/

Open the configuration file, change the last line as follow:
> sudo vi ifcfg-enp0s3
ONBOOT=yes

Enable the second network adapter on VirtualBox, copy and set the configuration file for the second network
> sudo cp ifcfg-enp0s3 ifcfg-enp0s8

> cat ifcfg-enp0s8
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.56.110
NETMASK=255.255.255.0
DEFROUTE=yes

Update the latest software
> sudo yum update

Disable firewall
> sudo systemctl stop firewalld.service
> sudo systemctl disable firewalld.service

Install Docker
> sudo yum install -y yum-utils device-mapper-persistent-data lvm2
> sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Then the install command will work
> sudo yum install docker-ce
> sudo usermod -aG docker $(whoami)
> sudo systemctl enable docker.service
> sudo systemctl start docker.service

Start the Rancker from Docker Image
> mkdir -p ~/tool/rancher-docker
> sudo ln -s /home/carl/tool/rancher-docker /opt/rancher-docker
> sudo ln -s /opt/rancher-docker /opt/rancher

Go to the working directory
> cd /opt/rancher
> mkdir /opt/rancher/rancher_home

Prepare a Makefile there
> cat Makefile
PORT=9090
SSL_PORT=9091
IMAGE=rancher/rancher
TAG=stable
NAME=rancher-$(PORT)
run:
docker run \
-d \
        --restart=unless-stopped \
-p $(PORT):80 \
-p $(SSL_PORT):443 \
-v $(shell pwd)/rancher_home:/var/lib/rancher/ \
--name $(NAME) \
$(IMAGE):$(TAG)
clean:
docker stop ${NAME}
docker rm ${NAME}

Start Rancher on the first server
> make run PORT=80 SSL_PORT=443

Visit the URL
https://192.168.56.110/g/clusters

It will ask us to update the password. Then we can create a customer cluster via k8s.
For the home machine, do not use it as worker
>   sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.2.8 --server https://192.168.56.110 --token 5x6452wfj86kpmxkzwxhjt7mpsbx5hxx7p66jqnpvdqk469mrxh4v7 --ca-checksum 326354803f20bff6574e64d735e854fe73e8d7fd5e9ff6a13d8252fbf5deeefa --node-name rancher-home --address 192.168.56.110 --internal-address 192.168.56.110 --etcd --controlplane

Set Up rancher-worker1
The network config
Go to the network setting directory
> cd /etc/sysconfig/network-scripts/

Open the configuration file, change the last line as follow:
> sudo vi ifcfg-enp0s3
ONBOOT=yes

Enable the second network adapter on VirtualBox, copy and set the configuration file for the second network
> sudo cp ifcfg-enp0s3 ifcfg-enp0s8

> cat ifcfg-enp0s8
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.56.111
NETMASK=255.255.255.0
DEFROUTE=yes

Update the latest software
> sudo yum update

Disable firewall
> sudo systemctl stop firewalld.service
> sudo systemctl disable firewalld.service

Install Docker
> sudo yum install -y yum-utils device-mapper-persistent-data lvm2
> sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Then the install command will work
> sudo yum install docker-ce
> sudo usermod -aG docker $(whoami)
> sudo systemctl enable docker.service
> sudo systemctl start docker.service

On the rancher-worker1
>   sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.2.8 --server https://192.168.56.110 --token 5x6452wfj86kpmxkzwxhjt7mpsbx5hxx7p66jqnpvdqk469mrxh4v7 --ca-checksum 326354803f20bff6574e64d735e854fe73e8d7fd5e9ff6a13d8252fbf5deeefa --node-name rancher-worker1 --address 192.168.56.111 --internal-address 192.168.56.111 --worker


If I need, here is the command to kill all the containers at one
> docker kill $(docker ps -q)

Remove all the unused containers and images
> docker system prune

After I start the cluster, I can add a nginx web server there

Visit the worker page, it works pretty well.
http://rancher-worker1:31489/

After everything is working fine, we can do the similar step to set up rancher-worker2 to join the cluster as worker.

Set Up rancher-worker2

The network config
Go to the network setting directory
> cd /etc/sysconfig/network-scripts/

Open the configuration file, change the last line as follow:
> sudo vi ifcfg-enp0s3
ONBOOT=yes

Enable the second network adapter on VirtualBox, copy and set the configuration file for the second network
> sudo cp ifcfg-enp0s3 ifcfg-enp0s8

> cat ifcfg-enp0s8
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.56.111
NETMASK=255.255.255.0
DEFROUTE=yes

Update the latest software
> sudo yum update

Disable firewall
> sudo systemctl stop firewalld.service
> sudo systemctl disable firewalld.service

Install Docker
> sudo yum install -y yum-utils device-mapper-persistent-data lvm2
> sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Then the install command will work
> sudo yum install docker-ce
> sudo usermod -aG docker $(whoami)
> sudo systemctl enable docker.service
> sudo systemctl start docker.service

On the rancher-worker1
>   sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.2.8 --server https://192.168.56.110 --token 5x6452wfj86kpmxkzwxhjt7mpsbx5hxx7p66jqnpvdqk469mrxh4v7 --ca-checksum 326354803f20bff6574e64d735e854fe73e8d7fd5e9ff6a13d8252fbf5deeefa --node-name rancher-worker2 --address 192.168.56.112 --internal-address 192.168.56.112 --worker


References:
https://gist.github.com/evanscottgray/8571828
分享到:
评论

相关推荐

    Rancher部署K8s相关镜像(1)

    K8S Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:...

    rancher-k8s

    - 主机名:Rancher_K8s_node3,IP地址:192.168.1.18,操作系统:Ubuntu 16.04/内核4.4.0,角色:K8s-node ##### 操作步骤 1. **运行Rancher Server**: ```shell docker run -d --restart always --name ...

    Rancher部署K8s相关镜像(3)

    K8S Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:...

    Docker-Rancher-K8S教程.docx

    Docker-Rancher-K8S教程

    Rancher部署K8s相关镜像(2)

    K8S Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:...

    rancher+k8s+etcd集群

    使用RKE构建企业生产Kubernetes集群 内容包含: 1.集群主机准备 2.daocker部署 3.docker compose安装 4.添加rancher用户 5.生成ssh证书用户部署集群 6.rke工具下载 7.初始化rke配置文件 ....

    Rancher、k8s和容器持久化存储

    总结来说,容器持久化存储是解决容器化应用数据持久化的关键技术,Kubernetes作为云原生的操作系统,提供了强大的容器管理和编排能力,而Rancher则为企业级K8s部署提供了便利的管理平台。这三者共同推动了容器云技术...

    Dapr学习(2)之Rancher2.63(k8s&k3s)环境安装Dapr.doc

    【Dapr学习(2)之Rancher2.63(k8s&k3s)环境安装Dapr】 在本文中,我们将深入探讨如何在Kubernetes(k8s)和k3s环境中,利用Rancher2.6.3管理工具安装Dapr。Dapr(Distributed Application Runtime)是一个...

    二进制高可用k8s集群一键部署脚本

    "二进制高可用k8s集群一键部署脚本"是为简化k8s集群搭建过程而设计的工具,它基于阿良的二进制部署文档,旨在帮助开发者和学习者快速创建一个稳定的高可用k8s集群。 首先,了解二进制部署意味着不依赖于预打包的...

    rancher shell deploy K8S docker

    jenkins调用shell触发rancher命令通过yml方式部署微服务镜像

    kubernetes介单节点rancher安装部署手册

    3. 所有节点关闭 CentOS 7 的防火墙 关闭防火墙,可以使用以下命令: `systemctl stop firewalld` `systemctl disable firewalld` 并启用 iptables: `yum install iptables-services -y` `systemctl restart ...

    rancher2.2部署k8s实操1

    在本篇内容中,我们将详细讨论如何使用Rancher 2.2版本部署Kubernetes(k8s)集群,以及涉及的关键组件和操作步骤。Rancher是一个流行的开源平台,用于管理和部署容器化应用程序,而Kubernetes则是一个自动化容器...

    k8s部署rancher,rancher证书文件

    k8s部署rancher,rancher证书文件

    k8s-dns-sidecar-amd64

    k8s-dns-sidecar-amd64-1.14.8镜像,镜像使用方法: docker load -i k8s-dns-sidecar-amd64-1.14.8.tar.gz

    rancher2.2 shell jenkins k8s 自动化部署

    包含NodePort,HostPort,ClusterIp几种方式自动化部署脚本。

    k8s集群pod经常重启问题排查总结.doc

    k8s集群pod经常重启问题排查总结

Global site tag (gtag.js) - Google Analytics