Skip to content

Add internal Kubernetes Agent API

Thong Kuah requested to merge cluster_agent into master

Creates an experimental, internal Kubernetes Agent API. Part of &3329

Feature flag: kubernetes_agent_internal_api

Also creates the necessary tables and models to support the API

  • create agents table
  • create agent_tokens table
  • Use agent token to authenticate to this new API (Authorization: Bearer TOKEN)
  • If token is invalid, respond with 403 Forbidden
  • [-] If token is has been revoked, respond with 403 Forbidden. Will follow-up in new issue

In response we also need:

  • agent_id
  • agent_name
  • project_id (can be added later, not urgent)
  • [-] cluster_id (can be added later, not urgent) Will follow-up in new issue

Related issue: gitlab-org/cluster-integration/gitlab-agent#1 (moved)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Notes for anyone who wants to try the branch:

  • gdk update and switch to the branch

  • run bundle exec rails db:migrate RAILS_ENV=development

  • In Rails console (bundle exec rails console):

    Feature.enable(:kubernetes_agent_internal_api)
    
    p = Project.find(<id>)
    agent = Clusters::Agent.create!(project: p, name: "my-agent")
    token = Clusters::AgentToken.create!(agent: agent)
    puts token.token # this is the token for the agent
Edited by Mayra Cabrera

Merge request reports