kubernetes 部署 traefik2.5

Posted 战狐

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kubernetes 部署 traefik2.5相关的知识,希望对你有一定的参考价值。


kubernetes 部署 traefik2.5

零、前言

本文不涉及Gateway API,因为仍然是实验功能。

traefik 相关基础知识都在之前的文章写了,本文只关注新装2.5版本,以及在不同k8s版本安装的差异性进行备注

一、系统环境

  • Traefik版本: 2.5.6
  • Kubernetes 版本:1.19

二、helm 安装

2.1 系统环境

  • Kubernetes 1.14+
  • Helm 3.x

2.2 安装

添加Traefik chart 仓库

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

更新仓库

helm repo update

使用helm 安装

helm install traefik traefik/traefik

其他个性化配置查看values.yaml

helm安装官方文档


三、手动安装

3.1 创建CRD

这里要注意你的k8s版本,从k8s 1.16开始废弃apiextensions.k8s.io/v1beta1,1.22完全删除。

对于k8s 1.16 以上版本,使用apiextensions.k8s.io/v1

00-traefik-v2.5-crd.yaml

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.2
creationTimestamp: null
name: ingressroutes.traefik.containo.us
spec:
group: traefik.containo.us
names:
kind: IngressRoute
listKind: IngressRouteList
plural: ingressroutes
singular: ingressroute
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: IngressRoute is an Ingress CRD specification.
properties:
apiVersion:
description: APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: IngressRouteSpec is a specification for a IngressRouteSpec
resource.
properties:
entryPoints:
items:
type: string
type: array
routes:
items:
description: Route contains the set of routes.
properties:
kind:
enum:
- Rule
type: string
match:
type: string
middlewares:
items:
description: MiddlewareRef is a ref to the Middleware resources.
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
type: array
priority:
type: integer
services:
items:
description: Service defines an upstream to proxy traffic.
properties:
kind:
enum:
- Service
- TraefikService
type: string
name:
description: Name is a reference to a Kubernetes Service
object (for a load-balancer of servers), or to a TraefikService
object (service load-balancer, mirroring, etc). The
differentiation between the two is specified in the
Kind field.
type: string
namespace:
type: string
passHostHeader:
type: boolean
port:
anyOf:
- type: integer
- type: string
x-kubernetes-int-or-string: true
responseForwarding:
description: ResponseForwarding holds configuration for
the forward of the response.
properties:
flushInterval:
type: string
type: object
scheme:
type: string
serversTransport:
type: string
sticky:
description: Sticky holds the sticky configuration.
properties:
cookie:
description: Cookie holds the sticky configuration
based on cookie.
properties:
httpOnly:
type: boolean
name:
type: string
sameSite:
type: string
secure:
type: boolean
type: object
type: object
strategy:
type: string
weight:
description: Weight should only be specified when Name
references a TraefikService object (and to be precise,
one that embeds a Weighted Round Robin).
type: integer
required:
- name
type: object
type: array
required:
- kind
- match
type: object
type: array
tls:
description: "TLS contains the TLS certificates configuration of the
routes. To enable Lets Encrypt, use an empty TLS struct, e.g. in
YAML: \\n \\t tls: # inline format \\n \\t tls: \\t secretName:
# block format"
properties:
certResolver:
type: string
domains:
items:
description: Domain holds a domain name with SANs.
properties:
main:
type: string
sans:
items:
type: string
type: array
type: object
type: array
options:
description: Options is a reference to a TLSOption, that specifies
the parameters of the TLS connection.
properties:
name:
type: string

以上是关于kubernetes 部署 traefik2.5的主要内容,如果未能解决你的问题,请参考以下文章

在AWS上部署kubernetes

Kubernetes - Kubernetes部署Kubernetes Dashbaord

kubernetes上部署 wiki.js

Kubernetes——Kubernetes基础+部署Kubernetes集群

Kubernetes——Kubernetes基础+部署Kubernetes集群

Kubernetes 生产部署实录