Traefik2.2.0 安装部署详解

转载地址

转载原站地址linux

前提:

Traefik 2.X.0 现已发布一段时间,版本更新很多新特性,尤为是TCP转发和http转发并存这个亮点,能够解决很多业务问题,节省不少核心网络端口,特裸机部署进行体验。

核心概念

Traefik 相似边缘路由器,能够做为整个平台的入口,根据逻辑和规则,处理并路由每一个传入的请求。这些规则肯定哪些服务处理哪些请求;传统的反向代理须要一个配置文件,其中包含路由到你服务的全部可能路由,而Traefik 会实时检测服务并自动更新路由规则,能够自动服务发现。

Entrypoint 这是流量的入口,它们定义了接收请求的端口(HTTP或者TCP)。
Providers 用来自动发现平台上的服务,能够是编排工具、容器引擎或者 key-value 存储等,好比 Docker、Kubernetes、File
Routers 分析请求(host, path, headers, SSL, …),负责将传入请求链接到能够处理这些请求的服务上去。
Services 将请求转发给你的应用(load balancing, …),负责配置如何获取最终将处理传入请求的实际服务。
Middlewares 中间件,用来修改请求或者根据请求来作出一些判断(authentication, rate limiting, headers, ...),中间件被附件到路由上,是一种在请求发送到你的服务以前(或者在服务的响应发送到客户端以前)调整请求的一种方法。

增长主干功能以下:

[acme,middleware,tls] 入口点重定向和默认路由器配置
[consul,etcd,kv,redis,zk] 添加KV商店提供程序(仅动态配置)
[consulcatalog,docker,marathon,rancher,udp] 在带有标签的 providers 中添加 UDP
[docker] 在network_mode为主机时修复 traefik behavior
[docker] 支持到 Docker 的 SSH 链接
[healthcheck] 不要对 health check URLs 进行重定向
[k8s,k8s/crd,udp] 在 kubernetesCRD provider 中添加 UDP 支持
[WebUI中]加入黑暗的主题为Web UI

Bug 修复一大堆:

更多详细信息请查看更新说明:
https://github.com/containous/traefik/releases

环境介绍:

默认占用端口: 
http 80  
https 443  
traefik 管理页面 8080 

配置目录: /etc/traefik  
服务日志路径:/var/log/traefik
访问日志:/data/traefiklog

安装 traefik

wget --quiet -O /tmp/traefik.tar.gz "https://github.com/containous/traefik/releases/download/v2.2.0/traefik_v2.2.0_linux_amd64.tar.gz"

tar xzvf /tmp/traefik.tar.gz -C /usr/local/bin traefik

rm -f /tmp/traefik.tar.gz;

chmod +x /usr/local/bin/traefik

mkdir -p /etc/traefik  
mkdir -p /var/log/traefik
mkdir -p /data/traefiklog

验证版本

traefik  version
Version:      2.2.0
Codename:     chevrotin
Go version:   go1.14.1
Built:        2020-03-25T17:32:57Z
OS/Arch:      linux/amd64

添加traefik 开机启动文件:

cd /etc/systemd/system/ 
Traefik启动文件以下: 

vi traefik.service 

[Unit] 
Description=Traefik 
Documentation=https://docs.traefik.io 
#After=network-online.target 
#AssertFileIsExecutable=/usr/local/bin/traefik
#AssertPathExists=/etc/traefik/traefik.toml 

[Service] 
# Run traefik as its own user (create new user with: useradd -r -s /bin/false -U -M traefik) 
#User=traefik 
#AmbientCapabilities=CAP_NET_BIND_SERVICE 
# configure service behavior 
Type=notify 
ExecStart=/usr/local/bin/traefik --configFile=/etc/traefik/traefik.toml 
Restart=always 
WatchdogSec=1s 

# lock down system access 
# prohibit any operating system and configuration modification 
#ProtectSystem=strict 
# create separate, new (and empty) /tmp and /var/tmp filesystems 
#PrivateTmp=true 
# make /home directories inaccessible 
#ProtectHome=true 
# turns off access to physical devices (/dev/...) 
#PrivateDevices=true 
# make kernel settings (procfs and sysfs) read-only 
#ProtectKernelTunables=true 
# make cgroups /sys/fs/cgroup read-only 
#ProtectControlGroups=true 

# allow writing of acme.json 
#ReadWritePaths=/etc/traefik/acme.json 
# depending on log and entrypoint configuration, you may need to allow writing to other paths, too 
# limit number of processes in this unit 
#LimitNPROC=1 

[Install] 
WantedBy=multi-user.target

修改权限

sudo chown root:root /etc/systemd/system/traefik.service 
sudo chmod 644 /etc/systemd/system/traefik.service

初始化配置文件

请移步原站阅读:
原站地址git

管理面板

地址为 节点IP地址:8080
Traefik2.2.0 安装部署详解github

总体效果比 1.X 版本浪不少,总体功能比1.X 版本也强不少!

相关文章
相关标签/搜索