Giter Site home page Giter Site logo

wutong-gateway's Introduction

Wutong Gateway

欢迎使用 Wutong Gateway! Wutong Gateway 是一款基于 Openresty 的 Ingress Controller。 实现通过 http,tcp 方式将流量转发到位于 Kubernetes 的 Service 中。

安装

kubectl create namespace wt-system
kubectl apply -f https://raw.githubusercontent.com/wutong-paas/wutong-gateway/master/deploy/manifests.yaml

使用示例

  • 如果集群中的 Ingress APIVersion 是 networking.k8s.io/v1,将 Ingress 的模型字段 ingress.spec.ingressClassName 值设置为 wutong-gateway 生效;
  • 如果集群中的 Ingress APIVersion 是 extensions/v1beta1,将 Ingress Annotation kubernetes.io/ingress.class 值设置为 wutong-gateway 生效。

创建 Deployment & Service

kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --type=ClusterIP --port=80 --target-port=80

创建 Ingress

nginx-tcp.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-tcp
  annotations:
    nginx.ingress.kubernetes.io/l4-enable: "true"
    nginx.ingress.kubernetes.io/l4-host: 0.0.0.0
    nginx.ingress.kubernetes.io/l4-port: "31080"
spec:
  ingressClassName: wutong-gateway
  defaultBackend:
    service:
      name: nginx
      port:
        number: 80

nginx-http.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-http
spec:
  ingressClassName: wutong-gateway
  rules:
    - host: nginx.wutong-gateway-sample.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: nginx
                port:
                  number: 80
kubectl apply -f nginx-tcp.yaml
kubectl apply -f nginx-http.yaml

wutong-gateway 作为 DaemonSet 部署在集群中的 Master 节点中,此时可以进入节点终端进行验证:

# tcp
curl localhost:31080

# http
curl localhost:80 -H 'Host: nginx.wutong-gateway-sample.com'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.