kubernetes traefik ingress 安装部署以及使用注意点

1、简介

在这里插入图片描述

Traefik 是一款 open-source 边缘路由器,可让您轻松地发布服务. 它接收来自您的系统请求,并找出负责处理它们的后端服务组件。

traefik 与众不同在于它能够自动发现适合您服务的配置。 当 Traefik 检查您的基础设施时,它会发现相关信息,并发现哪个服务服务于哪个请求。

Traefik 支持多种集群技术,如 Kubernetes,Kubernetes, Docker, Docker Swarm, AWS, Mesos, Marathon, 并且可以同时处理多个 providers。(它甚至适用于在裸机上运行的传统软件。)
使用 Traefik,无需维护和同步配置文件:所有操作都会自动实时完成(无重启,不用中断服务)。 使用 Traefik,您只需花时间于系统开发和部署新功能,而不是配置和维护其工作状态。

2、kubernetes安装traefik ingress

2.1.安装helm

yum install -y wget
mkdir -p /usr/local/helm
cd /usr/local/helm
wget https://get.helm.sh/helm-v3.10.0-linux-amd64.tar.gz
tar zxvf helm-v3.10.0-linux-amd64.tar.gz
mv -f linux-amd64/helm /usr/bin

2.2. 更新

helm repo update

2.3. helm repo add traefik

helm repo add traefik https://helm.traefik.io/traefik

2.3. traefik values.yaml 修改简单配置,亲测可用

globalArguments:
  - "--global.sendanonymoususage=false"
  - "--global.checknewversion=false"

additionalArguments:
  - "--serversTransport.insecureSkipVerify=true"
  - "--log.level=INFO,ERROR"
metrics:
  prometheus:
    entryPoint: metrics
deployment:
  enabled: true
  replicas: 3  # 自定义3个pod
  annotations: {
    
    }
  podAnnotations: {
    
    }
  additionalContainers: []
  initContainers: []

ports:
  web:
    redirectTo: websecure  # http 请求跳转到https
  websecure:
    tls:
      enabled: true

ingressRoute:
  dashboard:
    enabled: false
providers:
  kubernetesCRD:
    enabled: true
    ingressClass: traefik-external
  kubernetesIngress:
    enabled: true
    publishedService:
      enabled: false

rbac:
  enabled: true

service:
  enabled: true
  type: ClusterIP
  annotations: {
    
    }
  labels: {
    
    }
  spec: {
    
    }
  externalIPs:
    - 192.168.100.199 #构建svc时候用externalIPs指定运行svc的主机内网IP TODO根据自己的需求而定

2.4. 启动

	helm install traefik traefik/traefik -f values.yaml -n kube-system

2.4. 卸载

	helm uninstall traefik -n kube-system 

3、SSL证书安装

3.1. 证书转换(以pem为例)

openssl x509 -in xxx.com.pem -out xxx.com.crt

3.2. 证书添加k8s

cat xxx.com.crt | base64 | tr -d '\n'
cat xxx.com.crt | base64 | tr -d '\n' 
apiVersion: v1
kind: Secret
metadata:
 name: ca-key-pair
 namespace: cert
data:
 tls.crt: <crt>  cat xxx.com.crt | base64 | tr -d '\n'(拷贝过来)
 tls.key: <pvt>  cat xxx.com.crt | base64 | tr -d '\n' (拷贝过来)

4、注意事项

traefik ingress 证书需要配置任何一个namespace应用域名中访问,并且要访问一次,
其他的namespace 无需配置(2.9版本的测试,不清楚是为啥),并且一个域名而且只能保留一个证书(任意和域名绑定的namespace)否则证书会乱掉

猜你喜欢

转载自blog.csdn.net/helenyqa/article/details/129168625
今日推荐