Using Traefik Publishing Services in a kuberneters cluster

Source: Internet
Author: User
Tags etcd amazon ecs k8s

The implementation principle and configuration of k8s Ingress are described in the previous article, and the alternative Traefik is described in this paper. Before we start the configuration, let's review the implementation of the Ingress release k8s service, which requires the following components to be used ingress scenarios:
1. Reverse Proxy Load Balancer
2. Ingress control
3, Ingress
Where Ingress control is responsible for communicating with apiserver, monitoring pod and service changes, and updating the configuration of the reverse proxy load balancer, while allowing the reverse proxy load balancer to overload the configuration.

Next we look at Traefik, official address: https://traefik.io/
Traefik (pronounced like traffic) are a modern HTTP reverse proxy and load balancer made to deploy microservices with ease. It supports several backends (Docker,swarm Mode,kubernetes,marathon, Consul,etcd,rancher,amazon ECS, and a lot more) to M Anage its configuration automatically and dynamically.

Traefik is essentially an HTTP directional proxy and load balancer that can support back-end services such as Docker, Swarm mode, Kubernetes, Marathon, Consul, Etcd, Rancher, Amazon ECS, etc. Dynamically manage the configuration files for these services (which we can understand to automatically discover configuration changes for these backend services and reload the configuration of the service)

It's how Traefik works:

Main features of Traefik:
1, go speech writing, no need to install other dependent packages, fast
2. Support rest API, multi-backend type support
3, support profile hot load, do not need to restart the app process
4, support round Robin, Rebalancer load-balancers and other load balancing strategy
5. Self-Angularjs Web UI graphical interface
6, support HTTPS, automatic Update HTTPS certificate
7, Support WebSocket, HTTP/2, GRPC, high-availability cluster, etc.
8, support network error retry, back-end auto-fuse (when the back-end application error Too many times, can automatically fuse)

All in all, the choice of Service release in the K8s cluster, Traefik can be used as an alternative solution for Ingress, Traefik's features are enough to persuade us to replace Ingress with Traefik, and below we start in k8s 1.5. Use Traefik to publish services in a 2 cluster environment.

First, through the Yaml file has been daemonset way to run Traefik

# mkdir traefik# cd traefik# docker pullk docker.io/traefik
# cat traefik.ds.yaml   apiVersion: extensions/v1beta1kind: DaemonSetmetadata:  name: traefik-ingress-lb  namespace: default  labels:    k8s-app: traefik-ingress-lbspec:  template:    metadata:      labels:        k8s-app: traefik-ingress-lb        name: traefik-ingress-lb    spec:      terminationGracePeriodSeconds: 60      hostNetwork: true      restartPolicy: Always      containers:      - image: docker.io/traefik        name: traefik-ingress-lb        resources:          limits:            cpu: 200m            memory: 30Mi          requests:            cpu: 100m            memory: 20Mi        ports:        - name: http          containerPort: 80          hostPort: 80        - name: admin          containerPort: 8081        args:        - --web        - --web.address=:8081        - --kubernetes        - --kubernetes.endpoint=http://192.168.115.5:8080

Second, create WebUI service, ingress through Yaml file.

# cat ui.yaml apiVersion: v1kind: Servicemetadata:  name: traefik-web-ui  namespace: defaultspec:  selector:    k8s-app: traefik-ingress-lb  ports:  - name: web    port: 80    targetPort: 8081---apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: traefik-web-ui  namespace: defaultspec:  rules:  - host: traefik-ui.local    http:      paths:      - path: /        backend:          serviceName: traefik-web-ui          servicePort: web

Iii. creating Kubernetes-dashboard and Frontend ingress through YAML files

# cat traefik.ing.yaml   apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: traefik-ingressspec:  rules:  - host: k8s.webui    http:      paths:      - path: /        backend:          serviceName: kubernetes-dashboard            servicePort: 80  - host: k8s.frontend    http:      paths:      - path: /        backend:          serviceName: frontend          servicePort: 80

Iii. creating pods and ingress from the Yaml configuration file above

# cd kubernetes/traefik/# kubectl get pod# kubectl get svc# kubectl create -f .

# kubectl get pod# kubectl get svc# kubectl get ingress


Iv. Access to Application testing
Modify the test machine Hosts file because Traefik runs in Demonset, so the hosts record points to any node in the k8s cluster



You can view the graphical interface of Taefik by accessing port 8081 on any node in the cluster

Using Traefik Publishing Services in a kuberneters cluster

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.