Commit 0feb53e4 authored by Thong Kuah's avatar Thong Kuah Committed by Douglas Barbosa Alexandre

Enable the kubernetes agent internal api by default

Since we now have the JWT internal auth since bf5b5cf9, we don't
need the protection of FF anymore. However we still keep the FF so that
we can disable this if necessary.

Adds docs for GitLab Kubernetes agent internal API
parent 0ea6df5b
---
title: Internal API for GitLab Kubernetes agent
merge_request: 41045
author:
type: other
......@@ -370,3 +370,64 @@ Example response:
"reference_counter_decreased": true
}
```
## Kubernetes agent information
Called from GitLab Kubernetes Agent Server (kas) to retrieve agent
information for the given agent token. This returns the Gitaly connection
information for the agent's project in order for kas to fetch and update
the agent's configuration.
```plaintext
GET /internal/kubernetes/agent_info
```
Example Request:
```shell
curl --request GET --header "Gitlab-Kas-Api-Request: <JWT token>" --header "Authorization: Bearer <agent token>" "http://localhost:3000/api/v4/internal/kubernetes/agent_info"
```
## Kubernetes agent project information
Called from GitLab Kubernetes Agent Server (kas) to retrieve project
information for the given agent token. This returns the Gitaly
connection for the requested project. GitLab kas uses this to configure
the agent to fetch Kubernetes resources from the project repository to
sync.
Only public projects are currently supported. For private projects, the ability for the
agent to be authorized is [not yet implemented](https://gitlab.com/gitlab-org/gitlab/-/issues/220912).
| Attribute | Type | Required | Description |
|:----------|:-------|:---------|:------------|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](../api/README.md#namespaced-path-encoding) |
```plaintext
GET /internal/kubernetes/project_info
```
Example Request:
```shell
curl --request GET --header "Gitlab-Kas-Api-Request: <JWT token>" --header "Authorization: Bearer <agent token>" "http://localhost:3000/api/v4/internal/kubernetes/project_info?id=7"
```
## Kubernetes agent usage metrics
Called from GitLab Kubernetes Agent Server (kas) to increase the usage
metric counters.
| Attribute | Type | Required | Description |
|:----------|:-------|:---------|:------------|
| `gitops_sync_count` | integer| yes | The number to increase the `gitops_sync_count` counter by |
```plaintext
POST /internal/kubernetes/usage_metrics
```
Example Request:
```shell
curl --request POST --header "Gitlab-Kas-Api-Request: <JWT token>" --header "Content-Type: application/json" --data '{"gitops_sync_count":1}' "http://localhost:3000/api/v4/internal/kubernetes/usage_metrics"
```
......@@ -45,7 +45,7 @@ module API
end
def check_feature_enabled
not_found! unless Feature.enabled?(:kubernetes_agent_internal_api)
not_found! unless Feature.enabled?(:kubernetes_agent_internal_api, default_enabled: true)
end
def check_agent_token
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment