Allow to Select Agent in Environment setting page
Problem
For Render Kubernetes resources in Environment inde... (#390769 - closed), users need to specify which agent to be used for fetching Kubernetes resources.
Proposal
- User visits Project > Deployments > Environments. This is Environment index page.
- User clicks an environment name, which navigates to Environment details page.
- User clicks "Edit" button
- User selects an available agent from dropdown list.
Prerequisites
To do this, we likely need to finish Show shared agents in deployment projects (#395498 - closed) for letting deployment projects fetch shared agents. Currently, this is not possible due to lacking read_cluster
permission.
Permission
It follows update_environment
permission. Developer+ is allowed to edit. If the environment is protected, users who are allowed to access can update the environment.
UI
Technical details
- We add
cluster_agent_id
FK column to theenvironments
table.
# Existing table
environments:
name:
cluster_agent_id: FK to clusters_agents table.
- In the environment edit page, frontend shows a drop down to select an agent. The agent list can be fetched with
userAccessAuthorizedAgents
GraphQL query. - Users choose one of the agent and click "Save" button. The form is submitted to GraphQL
Environment:Update
orEnvironment:Create
mutation. backend persists the information into the foreign keys above. - The specified agent (
Types::Clusters::AgentType
) is exposed inTypes::EnvironmentType
, something like:
{
project(fullPath: "group/project") {
id
environment(name: "<environment-name>") {
slug
clusterAgent {
id
name
project {
name
}
}
}
}
}
- When the agent owner project unauthorizes the access from deployment projects,
project.environment.clusterAgent
will benull
. In this case, users have to set a new authorized cluster.
A few notes:
- Currently frontend uses a haml with serializing the environment JSON, and requests to Controller's
PUT
endpoint. We do NOT extend the Controller endpoint in favor of GraphQLEnvironment:Update
mutation.
Frontend implementation plan
-
Refactor the edit_environment
component to use GraphQl for getting environment data (!120642 (merged)) -
Refactor the edit_environment
component to use GraphQl mutation for storing data (!121091 (merged)) -
Refactor the new_environment
component to use GraphQl mutation for storing data (!121444 (merged)) -
Add agents select to the environment_form
(!121503 (merged)) -
Retrieve agent information from the environment
query (!121869 (merged))
Further iteration
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.