Documentation ¶
Overview ¶
Package openapi Wayne OpenAPI Document
wayne 开放 API (以下简称 openapi)是一组便于开发者调试、第三方工具开发和 CI/CD 的开放数据接口。 openapi 虽然格式上满足 Restful,但是并不是单一接口只针对特定资源的操作,在大部分时候单一接口会操作一组资源; 同时,虽然 openapi 下只允许通过 GET 请求访问,但是并不意味着 GET 操作代表着 Restful 中对 GET 的用法定义; openapi 的路径格式:/openapi/v1/gateway/action/:action,:action 代表特定操作,例如: get_vip_info、upgrade_deployment。
openapi 所操作的 action 必须搭配具有该 action 权限的 APIKey 使用(作为一个命名为 apikey 的 GET 请求参数), 而对应的 apikey 需要具备 action 对应的权限(例如:action 对应 get_pod_info 的时候,apikey 需要具备 OPENAPI_GET_POD_INFO 权限), 同时,受限于某些action的使用场景,可能强制要求附加的 APIKey 的使用范围,目前APIKey的适用范围包括三种,App 级别、Namespace 级别 以及 全局级别。 Terms Of Service:
Schemes: https Host: localhost BasePath: /openapi/v1/gateway/action Version: v1.2.0 Consumes: - application/json Produces: - application/json Security: - api_key: SecurityDefinitions: api_key: type: apiKey name: apikey in: query
swagger:meta
Index ¶
- Constants
- type DeploymentInfo
- type DeploymentStatus
- type DeploymentStatusParam
- type OpenAPIController
- func (c *OpenAPIController) CheckDeploymentPermission(deployment string) bool
- func (c *OpenAPIController) CheckNamespacePermission(namespace string) bool
- func (c *OpenAPIController) CheckoutRoutePermission(action string) bool
- func (c *OpenAPIController) GetDeploymentStatus()
- func (c *OpenAPIController) GetPodInfo()
- func (c *OpenAPIController) GetPodInfoFromIP()
- func (c *OpenAPIController) GetResourceInfo()
- func (c *OpenAPIController) Prepare()
- func (c *OpenAPIController) RestartDeployment()
- func (c *OpenAPIController) ScaleDeployment()
- func (c *OpenAPIController) UpgradeDeployment()
- type PodInfoFromIPParam
- type PodInfoParam
- type RestartDeploymentParam
- type ScaleDeploymentParam
- type UpgradeDeploymentParam
Constants ¶
const ( GetPodInfoAction = "GET_POD_INFO" GetPodInfoFromIPAction = "GET_POD_INFO_FROM_IP" GetResourceInfoAction = "GET_RESOURCE_INFO" GetDeploymentStatusAction = "GET_DEPLOYMENT_STATUS" UpgradeDeploymentAction = "UPGRADE_DEPLOYMENT" ScaleDeploymentAction = "SCALE_DEPLOYMENT" RestartDeploymentAction = "RESTART_DEPLOYMENT" PermissionPrefix = "OPENAPI_" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeploymentInfo ¶
type DeploymentInfo struct { Deployment *models.Deployment DeploymentTemplete *models.DeploymentTemplate DeploymentObject *v1beta1.Deployment Cluster *models.Cluster Namespace *models.Namespace }
type DeploymentStatus ¶
type DeploymentStatus struct { // required: true Pods []response.Pod `json:"pods"` // required: true Deployment response.Deployment `json:"deployment"` // required: true Healthz bool `json:"healthz"` }
swagger:model deploymentstatus
type DeploymentStatusParam ¶
type DeploymentStatusParam struct { // in: query // Required: true Deployment string `json:"deployment"` // Required: true Namespace string `json:"namespace"` // Required: true Cluster string `json:"cluster"` }
swagger:parameters DeploymentStatusParam
type OpenAPIController ¶
type OpenAPIController struct {
base.APIKeyController
}
func (*OpenAPIController) CheckDeploymentPermission ¶
func (c *OpenAPIController) CheckDeploymentPermission(deployment string) bool
func (*OpenAPIController) CheckNamespacePermission ¶
func (c *OpenAPIController) CheckNamespacePermission(namespace string) bool
func (*OpenAPIController) CheckoutRoutePermission ¶
func (c *OpenAPIController) CheckoutRoutePermission(action string) bool
func (*OpenAPIController) GetDeploymentStatus ¶
func (c *OpenAPIController) GetDeploymentStatus()
swagger:route GET /get_deployment_status deploy DeploymentStatusParam
该接口用于返回特定部署的状态信息
重点关注 kubernetes 集群内状态而非描述信息,当然也可以只关注 healthz 字段。 该接口可以使用所有种类的 apikey
Responses: 200: respdeploymentstatus 400: responseState 401: responseState 500: responseState
@router /get_deployment_status [get]
func (*OpenAPIController) GetPodInfo ¶
func (c *OpenAPIController) GetPodInfo()
swagger:route GET /get_pod_info pod PodInfoParam
用于获取线上所有 pod 中包含请求条件中 labelSelector 指定的特定 label 的 pod
返回 每个 pod 的 pod IP 和 所有 label 列表。 需要绑定全局 apikey 使用。该接口的权限控制为只能使用全局 apikey 的原因是查询条件为 labelSelector ,是对所有 app 的 条件过滤。
Responses: 200: resppodlist 401: responseState 500: responseState
@router /get_pod_info [get]
func (*OpenAPIController) GetPodInfoFromIP ¶ added in v1.2.0
func (c *OpenAPIController) GetPodInfoFromIP()
swagger:route GET /get_pod_info_from_ip pod PodInfoFromIPParam
用于通过线上 kubernetes Pod IP 反查对应 Pod 信息的接口
返回 每个 pod 的 pod IP 和 所有 label 列表。 需要绑定全局 apikey 使用。该接口的权限控制为只能使用全局 apikey 的原因是查询条件为 IP ,是对所有 app 的 条件过滤。
Responses: 200: resppodlist 401: responseState 500: responseState
@router /get_pod_info_from_ip [get]
func (*OpenAPIController) GetResourceInfo ¶
func (c *OpenAPIController) GetResourceInfo()
swagger:route GET /get_resource_info resource ResourceInfoParam
通过给定的资源类型和资源名称反查出资源所属的 app 和 用户信息
因为查询范围是对所有的服务进行的,因此需要绑定 全局 apikey 使用。
Responses: 200: respresourceinfo 400: responseState 500: responseState
@router /get_resource_info [get]
func (*OpenAPIController) Prepare ¶
func (c *OpenAPIController) Prepare()
func (*OpenAPIController) RestartDeployment ¶ added in v1.1.0
func (c *OpenAPIController) RestartDeployment()
swagger:route GET /restart_deployment deploy RestartDeploymentParam
用于用户调用以实现强制重启部署
该接口只能使用 app 级别的 apikey,这样做的目的主要是防止 apikey 的滥用
Responses: 200: responseSuccess 400: responseState 401: responseState 500: responseState
@router /restart_deployment [get]
func (*OpenAPIController) ScaleDeployment ¶
func (c *OpenAPIController) ScaleDeployment()
swagger:route GET /scale_deployment deploy ScaleDeploymentParam
用于 CI/CD 中的部署水平扩容/缩容
副本数量范围为0-32 该接口只能使用 app 级别的 apikey,这样做的目的主要是防止 apikey 的滥用
Responses: 200: responseSuccess 400: responseState 401: responseState 500: responseState
@router /scale_deployment [get]
func (*OpenAPIController) UpgradeDeployment ¶
func (c *OpenAPIController) UpgradeDeployment()
swagger:route GET /upgrade_deployment deploy UpgradeDeploymentParam
用于 CI/CD 中的集成升级部署
该接口只能使用 app 级别的 apikey,这样做的目的主要是防止 apikey 的滥用 目前用户可以选择两种用法,第一种是默认的,会根据请求的 images 对特定部署线上模板进行修改并创建新模板,然后使用新模板进行升级; 第二种是通过指定 publish=false 来关掉直接上线,这种条件下会根据 images 字段创建新的模板,并返回新模板id,用户可以选择去平台上手动上线或者通过本接口指定template_id参数上线。 cluster 字段可以选择单个机房也可以选择多个机房,对于创建模板并上线的用法,会根据指定的机房之前的模板进行分类(如果机房a和机房b使用同一个模板,那么调用以后仍然共用一个新模板) 而对于指定 template_id 来上线的形式,则会忽略掉所有检查,直接使用特定模板上线到所有机房。
Responses: 200: responseSuccess 400: responseState 401: responseState 500: responseState
@router /upgrade_deployment [get]
type PodInfoFromIPParam ¶ added in v1.2.0
type PodInfoFromIPParam struct { // A list of ip. // in: query // Required: true IPS string `json:"ips"` // Required: true Cluster string `json:"cluster"` // contains filtered or unexported fields }
swagger:parameters PodInfoFromIPParam
type PodInfoParam ¶
type PodInfoParam struct { // A label key of k8s pod. // in: query // Required: true LabelSelector string `json:"labelSelector"` // Required: true Cluster string `json:"cluster"` }
swagger:parameters PodInfoParam
type RestartDeploymentParam ¶ added in v1.1.0
type RestartDeploymentParam struct { // in: query // Required: true Deployment string `json:"deployment"` // Required: true Namespace string `json:"namespace"` // Required: true Cluster string `json:"cluster"` }
swagger:parameters RestartDeploymentParam
type ScaleDeploymentParam ¶
type ScaleDeploymentParam struct { // in: query // Required: true Deployment string `json:"deployment"` // Required: true Namespace string `json:"namespace"` // Required: true Cluster string `json:"cluster"` // Required: true Replicas int `json:"replicas"` }
swagger:parameters ScaleDeploymentParam
type UpgradeDeploymentParam ¶
type UpgradeDeploymentParam struct { // in: query // Required: true Deployment string `json:"deployment"` // Required: true Namespace string `json:"namespace"` // Required: true Cluster string `json:"cluster"` // Required: false TemplateId int `json:"template_id"` // Required: false Publish bool `json:"publish"` // Required: false Description string `json:"description"` // Required: false Images string `json:"images"` // contains filtered or unexported fields }
swagger:parameters UpgradeDeploymentParam