Skip to content

Commit

Permalink
Merge pull request #175 from projectsyn/feat/discovery
Browse files Browse the repository at this point in the history
Add discovery URL that returns metadata about lieutenant
  • Loading branch information
glrf authored Mar 30, 2022
2 parents 3d11b68 + c416ac6 commit 8aa6f93
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 75 deletions.
10 changes: 10 additions & 0 deletions docs/modules/ROOT/pages/references/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ This value will be set as fact on new clusters.
|Namespace where the Kubernetes objects are stored.
|`default`

|OIDC_DISCOVERY_URL
|The OpenID Connect discovery endpoint of the identity provider when using OIDC.
It's returned on the discovery URI and will be picked up by Commodore
|Empty

|OIDC_CLIENT_ID
|The client id used to authenticate when using OIDC.
It's returned on the discovery URI and will be picked up by Commodore
|Empty

|K8S_AUTH_CLIENT_CACHE_SIZE
|For each new API client (identified by the auth token), a Kubernetes client will be instantiated to pass through the request with the same token, which usually takes 2 seconds.
The K8s client instance will be cached for subsequent API calls and this setting controls how many instances to keep in memory.
Expand Down
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ var (
)

func main() {
e, err := service.NewAPIServer()
conf := service.APIConfig{
APIVersion: Version,
Namespace: os.Getenv("NAMESPACE"),
OidcDiscoveryURL: os.Getenv("OIDC_DISCOVERY_URL"),
OidcCLientID: os.Getenv("OIDC_CLIENT_ID"),
}

e, err := service.NewAPIServer(conf)
if err != nil {
fmt.Fprintf(os.Stderr, err.Error()+"\n")
os.Exit(1)
Expand Down
37 changes: 37 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ components:
A unique object identifier string. Automatically generated by the API on creation (in the form
"<letter>-<adjective>-<noun>-<digits>" where all letters are lowercase, max 63 characters in total).
readOnly: true
OIDCConfig:
type: object
required:
- discoveryUrl
- clientId
properties:
discoveryUrl:
type: string
format: uri-template
clientId:
type: string
Metadata:
type: object
required:
- apiVersion
properties:
apiVersion:
type: string
oidc:
$ref: '#/components/schemas/OIDCConfig'
TenantProperties:
type: object
description: |-
Expand Down Expand Up @@ -244,6 +264,23 @@ tags:
- name: system
description: API system
paths:
/:
get:
operationId: discovery
summary: Lieutenant API Root
description: Get metadata about Lieutenant
security: []
tags:
- system
responses:
'200':
description: Lieutenant metadata
content:
application/json:
schema:
$ref: '#/components/schemas/Metadata'
default:
$ref: '#/components/responses/Default'
/tenants:
get:
operationId: listTenants
Expand Down
110 changes: 110 additions & 0 deletions pkg/api/client.go

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

Loading

0 comments on commit 8aa6f93

Please sign in to comment.