Skip to content

Commit

Permalink
feat(api-server): new inspect api
Browse files Browse the repository at this point in the history
Signed-off-by: Charly Molter <[email protected]>
  • Loading branch information
lahabana committed Oct 26, 2023
1 parent fc03586 commit 9dd173d
Show file tree
Hide file tree
Showing 54 changed files with 1,380 additions and 173 deletions.
6 changes: 6 additions & 0 deletions api/mesh/v1alpha1/dataplane_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import (
"github.com/pkg/errors"
)

const (
KubeNamespaceTag = "k8s.kuma.io/namespace"
KubeServiceTag = "k8s.kuma.io/service-name"
KubePortTag = "k8s.kuma.io/service-port"
)

const (
// Mandatory tag that has a reserved meaning in Kuma.
ServiceTag = "kuma.io/service"
Expand Down
1 change: 1 addition & 0 deletions api/openapi/openapi.cfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ generate:
models: true
import-mapping:
./common/error_schema.yaml: "github.com/kumahq/kuma/api/openapi/types/common"
./common/resource.yaml: "github.com/kumahq/kuma/api/openapi/types/common"
output-options:
skip-prune: true
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: Kuma API
description: Kuma API Global Insight endpoint
description: Kuma API
version: '1.0.0'
paths:
/global-insight:
Expand All @@ -17,9 +17,76 @@ paths:
$ref: '#/components/responses/InternalServerError'
operationId: get-global-insight
description: Returns a Global Insight object

/meshes/{mesh}/{policyType}/{policyName}/-resources/dataplanes:
get:
parameters:
- in: path
name: mesh
example: default
schema:
type: string
required: true
description: The mesh the policy is part of
- in: path
name: policyType
example: meshretries
schema:
type: string
required: true
description: The type of the policy
- in: path
name: policyName
example: retry-all
schema:
type: string
required: true
description: The type of the policy
- in: query
name: size
schema:
type: integer
required: false
description: The max number of items to return
- in: query
name: offset
schema:
type: integer
required: false
description: The offset of result
- in: query
name: name
schema:
type: string
required: false
description: A sub string to filter resources by name
summary: Returns resources matched by this policy
description: Returns resources matched by this policy. In the case of `targetRef` policies we'll match using the top level `targetRef`
tags: ["Inspect"]
responses:
'200':
$ref: '#/components/responses/InspectDataplanesForPolicyResponse'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
operationId: inspect-resources
components:
schemas:
InspectDataplanesForPolicy:
type: object
title: InspectPolicy
description: A list of proxies
required: [total, items]
properties:
total:
type: integer
example: 200
next:
type: string
items:
type: array
items:
$ref: './common/resource.yaml#/components/schemas/Meta'
BaseStatus:
type: object
title: Status
Expand Down Expand Up @@ -190,6 +257,15 @@ components:
examples:
Single control plane response:
$ref: '#/components/examples/GlobalInsightExample'
InspectDataplanesForPolicyResponse:
description: A response containing global insight.
content:
application/json:
schema:
$ref: '#/components/schemas/InspectDataplanesForPolicy'
examples:
ResponseForDataplane:
$ref: '#/components/examples/InspectDataplanesForPolicyExample'
BadRequest:
description: Bad Request
content:
Expand Down Expand Up @@ -234,3 +310,14 @@ components:
total: 100
meshes:
total: 3
InspectDataplanesForPolicyExample:
value:
total: 100
next: http://localhost:5681/meshes/default/meshretries/-resources/dataplanes?offset=100
items:
- type: Dataplane
mesh: default
name: dp-1
- type: Dataplane
mesh: default
name: dp-2
18 changes: 18 additions & 0 deletions api/openapi/specs/common/resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
components:
schemas:
Meta:
type: object
required: [type, mesh, name]
properties:
type:
type: string
example: Dataplane
description: the type of this resource
mesh:
type: string
example: default
description: the mesh this resource is part of
name:
type: string
example: my-resource
description: the name of the resource
16 changes: 16 additions & 0 deletions api/openapi/types/common/zz_generated.resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 113 additions & 0 deletions docs/generated/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,62 @@ paths:
$ref: '#/components/responses/InternalServerError'
operationId: get-global-insight
description: Returns a Global Insight object
/meshes/{mesh}/{policyType}/{policyName}/-resources/dataplanes:
get:
parameters:
- in: path
name: mesh
example: default
schema:
type: string
required: true
description: The mesh the policy is part of
- in: path
name: policyType
example: meshretries
schema:
type: string
required: true
description: The type of the policy
- in: path
name: policyName
example: retry-all
schema:
type: string
required: true
description: The type of the policy
- in: query
name: size
schema:
type: integer
required: false
description: The max number of items to return
- in: query
name: offset
schema:
type: integer
required: false
description: The offset of result
- in: query
name: name
schema:
type: string
required: false
description: A sub string to filter resources by name
summary: Returns resources matched by this policy
description: >-
Returns resources matched by this policy. In the case of `targetRef`
policies we'll match using the top level `targetRef`
tags:
- Inspect
responses:
'200':
$ref: '#/components/responses/InspectDataplanesForPolicyResponse'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
operationId: inspect-resources
/meshes/{mesh}/meshaccesslogs/{name}:
get:
summary: Returns MeshAccessLog entity
Expand Down Expand Up @@ -1126,6 +1182,23 @@ paths:
$ref: '#/components/responses/MeshTrafficPermissionList'
components:
schemas:
InspectDataplanesForPolicy:
type: object
title: InspectPolicy
description: A list of proxies
required:
- total
- items
properties:
total:
type: integer
example: 200
next:
type: string
items:
type: array
items:
$ref: '#/components/schemas/Meta'
BaseStatus:
type: object
title: Status
Expand Down Expand Up @@ -1341,6 +1414,25 @@ components:
description: TODO
items:
$ref: '#/components/schemas/InvalidParameters'
Meta:
type: object
required:
- type
- mesh
- name
properties:
type:
type: string
example: Dataplane
description: the type of this resource
mesh:
type: string
example: default
description: the mesh this resource is part of
name:
type: string
example: my-resource
description: the name of the resource
MeshAccessLogItem:
type: object
properties:
Expand Down Expand Up @@ -5883,6 +5975,15 @@ components:
examples:
Single control plane response:
$ref: '#/components/examples/GlobalInsightExample'
InspectDataplanesForPolicyResponse:
description: A response containing global insight.
content:
application/json:
schema:
$ref: '#/components/schemas/InspectDataplanesForPolicy'
examples:
ResponseForDataplane:
$ref: '#/components/examples/InspectDataplanesForPolicyExample'
BadRequest:
description: Bad Request
content:
Expand Down Expand Up @@ -6226,4 +6327,16 @@ components:
total: 100
meshes:
total: 3
InspectDataplanesForPolicyExample:
value:
total: 100
next: >-
http://localhost:5681/meshes/default/meshretries/-resources/dataplanes?offset=100
items:
- type: Dataplane
mesh: default
name: dp-1
- type: Dataplane
mesh: default
name: dp-2

2 changes: 1 addition & 1 deletion mk/docs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ docs/generated/openapi.yaml:
rm -rf $(OAPI_TMP_DIR)
mkdir -p $(dir $@)
mkdir -p $(OAPI_TMP_DIR)/policies
for i in $(API_DIRS); do mkdir -p $(OAPI_TMP_DIR)/$$(echo $${i} | cut -d: -f2); cp -r $$(echo $${i} | cut -d: -f1) $(OAPI_TMP_DIR)/$$(echo $${i} | cut -d: -f2); done
for i in $(API_DIRS); do mkdir -p $(OAPI_TMP_DIR)/$$(echo $${i} | cut -d: -f2); cp -R $$(echo $${i} | cut -d: -f1) $(OAPI_TMP_DIR)/$$(echo $${i} | cut -d: -f2); done
for i in $$( find $(POLICIES_DIR) -name '*.yaml' | grep '/api/'); do DIR=$(OAPI_TMP_DIR)/policies/$$(echo $${i} | awk -F/ '{print $$(NF-3)}'); mkdir -p $${DIR}; cp $${i} $${DIR}/$$(echo $${i} | awk -F/ '{print $$(NF)}'); done

ifdef BASE_API
Expand Down
Loading

0 comments on commit 9dd173d

Please sign in to comment.