当前位置:网站首页>Helm deploy traifik ingress

Helm deploy traifik ingress

2022-06-11 02:55:00 Easy is not easy

1、 add to traefik helm Warehouse

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

2、 Download to local

$ helm  search repo traefik
NAME            CHART VERSION APP VERSION DESCRIPTION                                  
traefik/traefik	10.20.1      	2.7.0      	A Traefik based Kubernetes ingress controller 
$ helm pull traefik/traefik

3、 Deploy Traefik

3.1 modify values

#type: LoadBalancer
type: ClusterIP

ports:
  traefik:
    port: 8080
    hostPort: 8080
    exposedPort: 8080
    expose: true
    protocol: TCP


 add to 
additionalArguments:
  - "--serversTransport.insecureSkipVerify=true"
  - "--api.insecure=true"
  - "--api.dashboard=true"


 Or simply 
 The full configuration is as follows 
==================================
service:
  type: ClusterIP

ingressRoute:
  dashboard:
    enabled: false

nodeSelector:
  kubernetes.io/hostname: k8snode1

ports:
  web:
    hostPort: 80
  websecure:
    hostPort: 443
  traefik:
    port: 8080
    hostPort: 8080
    exposedPort: 8080
    expose: true

additionalArguments:
  - "--serversTransport.insecureSkipVerify=true"
  - "--api.insecure=true"
  - "--api.dashboard=true"

3.2  Deploy

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

 Other commands 
$ helm upgrade traefik traefik/traefik  -n kube-system  # to update 
$ helm uninstall traefik -n kube-system #  uninstall  traefik

# Check the status 
$ helm list -n kube-system 
NAME   	NAMESPACE  	REVISION	UPDATED                                	STATUS  	CHART          	APP VERSION
traefik	kube-system	1       	2022-06-07 15:05:58.300911179 +0800 CST	deployed	traefik-10.20.1	2.7.0     

$ helm status traefik -n kube-system 
NAME: traefik
LAST DEPLOYED: Tue Jun  7 15:05:58 2022
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
 

4  Create routing rules

4.1 Native Ingress Routing rules

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: traefik-dashboard-ingress
  namespace: kube-system
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/router.entrypoints: web
spec:
  rules:
  - host: traefik.ingress.cn
    http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: traefik
            port:
              number: 8080

4.2  Use CRD Configure routing rules by

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-dashboard-route
  namespace: kube-system
spec:
  entryPoints:
  - web
  routes:
  - match: Host(`traefikroute.ingress.cn`)
    kind: Rule
    services:
      - name: traefik
        port: 8080

 namespace: kube-system # Want to be with traefik ingress In the same namespace , You can visit ,

Such as :http://traefikroute.ingress.cn/dashboard/#/

Otherwise, you need to add expose Port set in ; Such as http://traefikroute.ingress.cn:8080/

5  visit

http://traefik.ingress.com
http://traefik.ingress.com/dashboard

6 verification

expose HTTP service

# establish pod and svc
cat > whoami.yaml << EOF
---
apiVersion: v1
kind: Pod
metadata:
  name: whoami
  labels:
    app: whoami
spec:
  containers:
    - name: whoami
      image: traefik/whoami:latest
      ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: whoami
spec:
  ports:
    - port: 80
      protocol: TCP
      targetPort: 80
  selector:
    app: whoami
  type: ClusterIP
EOF

==========================
 Create a routing rule , Make it accessible to the outside 

cat > whoami-ingressroute.yaml << EOF
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: whoami-route
spec:
  entryPoints:
  - web
  routes:
  - match: Host(`whoami.ingress.cn`)
    kind: Rule
    services:
      - name: whoami
        port: 80 
EOF

Browser access   whoami.ingress.cn

Personal summary :

1、 The others are through traefik Agent resource application pod,service You don't need to traefik In the same namespace , That is, namespace pairs traefik There is no limit to agency 

Neither of the above two examples is in traefik ingress In the namespace of

2、 But the deployment instance is pod service Routing rules All need to be in the same namespace

原网站

版权声明
本文为[Easy is not easy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110148512908.html