Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(inspect): api for retrieving service hostnames #11865

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions api/openapi/specs/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,42 @@ paths:
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
/meshes/{mesh}/{serviceType}/{serviceName}/_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
jakubdyszkiewicz marked this conversation as resolved.
Show resolved Hide resolved
schema:
type: string
enum: [meshservices, meshmultizoneservices, meshexternalservices]
required: true
description: The type of the service
- in: path
name: serviceName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agree that this doesn't support URIs yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URIs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unique resource identifier (<mesh>_<name>_<namespace>_<zone>_<shortType>_<optionalSection>)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then no. At least not for now

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 +469,42 @@ 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: An supported hostname along with the zones it exists 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 in which the hostname is available
required: [name]
properties:
name:
type: string
example: east
responses:
IndexResponse:
description: A response for the index endpoint
Expand Down Expand Up @@ -476,6 +548,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 +617,11 @@ components:
- type: Dataplane
mesh: default
name: dp-2
InspectHostnamesExample:
value:
total: 100
items:
- hostname: redis.redis-system.svc.east.mesh.local
zones:
- name: east
- name: west
31 changes: 31 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.

98 changes: 98 additions & 0 deletions docs/generated/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,46 @@ paths:
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
/meshes/{mesh}/{serviceType}/{serviceName}/_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
enum:
- meshservices
- meshmultizoneservices
- meshexternalservices
required: true
description: The type of the service
- 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 +2370,47 @@ 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: An supported hostname along with the zones it exists 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 in which the hostname is available
required:
- name
properties:
name:
type: string
example: east
PolicyDescription:
type: object
required:
Expand Down Expand Up @@ -12166,6 +12247,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 @@ -12687,4 +12777,12 @@ components:
- type: Dataplane
mesh: default
name: dp-2
InspectHostnamesExample:
value:
total: 100
items:
- hostname: redis.redis-system.svc.east.mesh.local
zones:
- name: east
- name: west

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ require (
go.opentelemetry.io/proto/otlp v1.3.1
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
golang.org/x/net v0.31.0
golang.org/x/sync v0.9.0
golang.org/x/sys v0.27.0
Expand Down Expand Up @@ -214,7 +215,6 @@ require (
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/term v0.26.0 // indirect
Expand Down
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}/_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
Loading