Skip to content

Commit

Permalink
feat(inspect): api for retrieve service hostnames
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <[email protected]>
  • Loading branch information
jakubdyszkiewicz committed Oct 28, 2024
1 parent e02c7b4 commit 3536693
Show file tree
Hide file tree
Showing 15 changed files with 575 additions and 0 deletions.
93 changes: 93 additions & 0 deletions api/openapi/specs/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,41 @@ paths:
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
/meshes/{mesh}/{serviceType}/{serviceName}/_resources/hostnames:
get:
operationId: inspect-hostnames
summary: Returns hostnames for service
description: Returns hostnames for a service
tags: ["Inspect"]
parameters:
- in: path
name: mesh
example: default
schema:
type: string
required: true
description: The mesh the service is part of
- in: path
name: serviceType
example: meshservices
schema:
type: string
required: true
description: The type of the service (meshservices, meshmultizoneservices, meshexternalservices)
- in: path
name: serviceName
example: redis
schema:
type: string
required: true
description: The name of the service
responses:
'200':
$ref: '#/components/responses/InspectHostnamesResponse'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
components:
schemas:
Index:
Expand Down Expand Up @@ -433,6 +468,45 @@ components:
additionalProperties:
$ref: '#/components/schemas/ResourceStats'
description: A map of resource names to their corresponding statistics
InspectHostnames:
type: object
title: InspectHostnames
description: A list of hostnames
required: [total, items]
properties:
total:
type: integer
example: 200
items:
type: array
items:
$ref: '#/components/schemas/InspectHostname'
InspectHostname:
type: object
title: InspectHostname
description: A list of zones in which the hostname is available in
required: [hostname, zones]
properties:
hostname:
type: string
description: Generated hostname
example: redis.redis-system.svc.east.mesh.local
zones:
type: array
items:
$ref: '#/components/schemas/InspectHostnameZone'
InspectHostnameZone:
type: object
title: InspectHostnameZone
description: A name of the zone with hostname generator that was used to generate the hostname
required: [name, hostnameGeneratorCoreName]
properties:
name:
type: string
example: east
hostnameGeneratorCoreName:
type: string
example: synced-kube-mesh-service.kuma-system
responses:
IndexResponse:
description: A response for the index endpoint
Expand Down Expand Up @@ -476,6 +550,15 @@ components:
application/json:
schema:
$ref: '#/components/schemas/InspectRules'
InspectHostnamesResponse:
description: A response containing hostnames that match a service.
content:
application/json:
schema:
$ref: '#/components/schemas/InspectHostnames'
examples:
ResponseForDataplane:
$ref: '#/components/examples/InspectDataplanesForPolicyExample'
BadRequest:
description: Bad Request
content:
Expand Down Expand Up @@ -536,3 +619,13 @@ components:
- type: Dataplane
mesh: default
name: dp-2
InspectHostnamesExample:
value:
total: 100
items:
- hostname: redis.redis-system.svc.east.mesh.local
zones:
- name: east
hostnameGeneratorCoreName: synced-kube-mesh-service.kuma-system
- name: west
hostnameGeneratorCoreName: synced-kube-mesh-service.kuma-system
22 changes: 22 additions & 0 deletions api/openapi/types/zz_generated.api.go

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

104 changes: 104 additions & 0 deletions docs/generated/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,44 @@ paths:
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
/meshes/{mesh}/{serviceType}/{serviceName}/_resources/hostnames:
get:
operationId: inspect-hostnames
summary: Returns hostnames for service
description: Returns hostnames for a service
tags:
- Inspect
parameters:
- in: path
name: mesh
example: default
schema:
type: string
required: true
description: The mesh the service is part of
- in: path
name: serviceType
example: meshservices
schema:
type: string
required: true
description: >-
The type of the service (meshservices, meshmultizoneservices,
meshexternalservices)
- in: path
name: serviceName
example: redis
schema:
type: string
required: true
description: The name of the service
responses:
'200':
$ref: '#/components/responses/InspectHostnamesResponse'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
/meshes/{mesh}/meshaccesslogs/{name}:
get:
summary: Returns MeshAccessLog entity
Expand Down Expand Up @@ -2330,6 +2368,53 @@ components:
additionalProperties:
$ref: '#/components/schemas/ResourceStats'
description: A map of resource names to their corresponding statistics
InspectHostnames:
type: object
title: InspectHostnames
description: A list of hostnames
required:
- total
- items
properties:
total:
type: integer
example: 200
items:
type: array
items:
$ref: '#/components/schemas/InspectHostname'
InspectHostname:
type: object
title: InspectHostname
description: A list of zones in which the hostname is available in
required:
- hostname
- zones
properties:
hostname:
type: string
description: Generated hostname
example: redis.redis-system.svc.east.mesh.local
zones:
type: array
items:
$ref: '#/components/schemas/InspectHostnameZone'
InspectHostnameZone:
type: object
title: InspectHostnameZone
description: >-
A name of the zone with hostname generator that was used to generate the
hostname
required:
- name
- hostnameGeneratorCoreName
properties:
name:
type: string
example: east
hostnameGeneratorCoreName:
type: string
example: synced-kube-mesh-service.kuma-system
PolicyDescription:
type: object
required:
Expand Down Expand Up @@ -11966,6 +12051,15 @@ components:
application/json:
schema:
$ref: '#/components/schemas/InspectRules'
InspectHostnamesResponse:
description: A response containing hostnames that match a service.
content:
application/json:
schema:
$ref: '#/components/schemas/InspectHostnames'
examples:
ResponseForDataplane:
$ref: '#/components/examples/InspectDataplanesForPolicyExample'
BadRequest:
description: Bad Request
content:
Expand Down Expand Up @@ -12487,4 +12581,14 @@ components:
- type: Dataplane
mesh: default
name: dp-2
InspectHostnamesExample:
value:
total: 100
items:
- hostname: redis.redis-system.svc.east.mesh.local
zones:
- name: east
hostnameGeneratorCoreName: synced-kube-mesh-service.kuma-system
- name: west
hostnameGeneratorCoreName: synced-kube-mesh-service.kuma-system

4 changes: 4 additions & 0 deletions pkg/api-server/endpoints_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ var _ = Describe("Endpoints", func() {
apiTest(inputFile, apiServer, resourceStore)
}, test.EntriesForFolder("resources/inspect/policies/_resources/dataplanes"))

DescribeTable("inspect for policies /meshes/{mesh}/{serviceType}/{policyName}/_resources/hostnames", func(inputFile string) {
apiTest(inputFile, apiServer, resourceStore)
}, test.EntriesForFolder("resources/inspect/services/_resources/hostnames"))

DescribeTable("inspect dataplane rules /meshes/{mesh}/dataplanes/{dpName}/_rules", func(inputFile string) {
apiTest(inputFile, apiServer, resourceStore)
}, test.EntriesForFolder("resources/inspect/dataplanes/_rules"))
Expand Down
Loading

0 comments on commit 3536693

Please sign in to comment.