apinto-ingress-controller

command module
v0.0.0-...-88ad6e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

README

Apinto-Ingress-Controller

​ Apinto-Ingress-Controller是Kubernetes集群中Apinto网关的Ingress控制器,使得Apinto能够作为Ingress资源在集群中运作。 ​ 该控制器的所有配置均参考Apinto网关的配置格式,并以Kubernetes CRDs(自定义资源)实现。支持配置诸如routerserviceauth等Apinto已实现的模块,同时也支持配置插件。

概况

部署

由于现阶段不支持以Helm chart的方式进行部署,因此暂时以手动部署的形式进行说明。

  1. 集群内部署apinto集群

  2. 部署secret资源,用于配置controller内的admission server证书。可以使用脚本生成自签证书进行配置。

    kubectl create -f admission_secret.yml
    
  3. 部署configmap资源来生成应用所需配置。

    kubectl create -f controller_configmap.yml
    
  4. 部署deployment资源生成应用。

    kubectl create -f controller_deployment.yml
    
  5. 部署admission服务向validatingWebhook提供校验的服务

    kubectl create -f admission_service.yml
    
  6. 部署ValidatingWebhook资源。

    kubectl create -f webhook_configuration.yml
    

以上部署所需yaml文件均在此目录

快速使用

自定义资源的配置顺序与apinto一致,均有依赖关系。

以配置路由以及服务为例:

**服务 ** service.yml

apiVersion: apinto.com/v1beta
kind: ApintoService
metadata:
  name: demo-anonymous
spec:
  name: demo-anonymous
  driver: http
  desc: "示例服务"
  timeout: 30000
  anonymous:
    type: round-robin
    config: "http://demo-apinto.eolink.com:8280" #该接口返回http调用信息
  retry: 2
  rewrite_url: /

路由 router.yml

apiVersion: apinto.com/v1beta
kind: ApintoRouter
metadata:
  name: apinto.router
spec:
  name: apinto.router# 路由名称
  listen: 8080    # 监听端口
  driver: http # 驱动
  protocol: http
  method:
    - GET
  rules:      # 规则列表
    - location: "/demo"  # 匹配路径
  target: demo-anonymous@service    # 目标服务ID,格式为:{服务名称}@service
kubectl create -f service.yml
kubectl create -f router.yml

创建完服务以及路由之后,调用apinto暴露到集群外的服务来查看是否存在该路由

curl -X GET 'http://{node_ip}:{admin_port}/api/router/apinto.router'

返回

{
	"create": "2022-03-23 06:14:48",
	"driver": "http",
	"id": "apinto.router@router",
	"listen": 8080,
	"method": ["GET"],
	"name": "apinto.router",
	"profession": "router",
	"protocol": "http",
	"rules": [{
		"location": "/demo"
	}],
	"target": "demo-anonymous@service",
	"update": "2022-03-23 06:14:48"
}

通过调用apinto暴露到集群外的服务来请求该路由

curl -X GET 'http://{node_ip}:{http_port}/demo'

返回

{
	"body": "",
	"header": {
		"Accept": ["*/*"],
		"User-Agent": ["curl/7.75.0"],
		"X-Forwarded-For": ["10.24.1.1,10.24.1.1"]
	},
	"host": "192.2.9.43:31080",  
	"method": "GET",
	"path": "/demo",
	"remote_addr": "192.4.5.22:19091", 
	"url": "/demo"
}

备注:以上的ip数据非原始数据

使用示例点此进行跳转。

联系我们

关于我们

EOLINK 是领先的 API 管理服务供应商,为全球超过3000家企业提供专业的 API 研发管理、API自动化测试、API监控、API网关等服务。是首家为ITSS(中国电子工业标准化技术协会)制定API研发管理行业规范的企业。

官方网站:https://www.eolink.com

免费下载PC桌面端:https://www.eolink.com/pc/

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
pkg
api
config
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
kube/apinto/client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
kube/apinto/client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
kube/apinto/client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
kube/apinto/client/clientset/versioned/typed/apinto/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
kube/apinto/client/clientset/versioned/typed/apinto/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
types
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
types/apinto/v1
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL