kubenetes Ingress介绍&实施

ingress是一个管理http服务对外提供服务的service,他支持lb,ssl,vhost.

术语介绍

Node: 在k8s集群中的一个虚拟机或物理机

Cluster: 一组可以通过Kubernetes来管理的集群。

Edge router: 集群中的防火墙策略,可以是云厂商支持或物理硬件            

Cluster network:集群中 物理或逻辑的网络、可以参考 Kubernetes networking model.

Service: 通过label selector将一组pod对外提供服务,service会分配一个虚拟IP和端口

什么是ingress

ingress在k8s 1.1版本中出现,它是用来暴露集群内部http https服务,对外提供服务。通过ingress来控制流量路由控制规则。

internet

        |

  [ Ingress ]

  --|-----|--

  [ Services ]

Ingress 可以用来将service暴露对外,实现负载均衡,SSL,支持VHOST

 Ingress controller 负载实现ingress规则,通常是负载均衡的方式,通过他可以处理对外的流量。

Ingress 只能通过Service.Type的nodeport或loadbalancer类型将http https的服务暴露出来

资源准备

Ingress Resource


Ingress rules

host,如果没有指定host,所有的http流量将通过ip地址指定。如果有host将按host进行调度

paths:每个path需要有后端的serviceName和servicePort

Default Backend

没有rules的会把所有的流量发送到default的backend上。

Ingress 类型

Single Service Ingress:


service/networking/ingress.yaml

apiVersion: extensions/v1beta1

kind: Ingress

metadata:

  name: test-ingress

spec:

  backend:

    serviceName: testsvc

    servicePort: 80

root@ubuntu209:~/k8syaml# kubectl apply -f ingress.yaml


ADDRESS 分配会比较慢

fanout简单配置

root@ubuntu209:~/k8syaml# cat simple-fanout-example.yaml

apiVersion: extensions/v1beta1

kind: Ingress

metadata:

  name: simple-fanout-example

  annotations:

    nginx.ingress.kubernetes.io/rewrite-target: /

spec:

  rules:

  - host: foo.bar.com

    http:

      paths:

      - path: /foo

        backend:

          serviceName: service1

          servicePort: 4200

      - path: /bar

        backend:

          serviceName: service2

          servicePort: 8080


Ingress Controllers

Ingress 资源要工作,必须依赖Ingress Controllers,Ingress Controllers不随集群自己启动。需要自己选择合适的方式。

k8s支持GCE and nginx controllers.

controller种类

1、Ambassador:ambassador是datawire开源的服务网关,很好的支持kubernetes

2、appscode inc:提代基于haproxy的controller Voyager.

3、Contour:基于Envoy 

4、Citrix provides an Ingress Controller for its hardware (MPX), virtualized (VPX) and free containerized (CPX) ADC for baremetal and cloud deployments.

5、F5 F5 BIG-IP Controller for Kubernetes.

6、Gloo  is an open-source ingress controller based on Envoy which offers API Gateway functionality with enterprise support from solo.io.

7、HAProxy  jcmoraisjr/haproxy-ingress which is mentioned on the blog post HAProxy Ingress Controller for KubernetesHAProxy Technologies

8、Istio Control Ingress Traffic.

9、Kong  Kong Ingress Controller for Kubernetes.

10、NGINX, Inc.  NGINX Ingress Controller for Kubernetes

11、Traefik 

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。