doc/user/clusters/agent/work_with_agent.md
{{< details >}}
{{< /details >}}
Use the following tasks when you work with the agent for Kubernetes.
The installed agentk version is displayed on the Agent tab.
Prerequisites:
To view the list of agents:
On this page, you can view:
agentk installed on your cluster.To configure your agent:
config.yaml file optionally created during installation.You can quickly locate an agent configuration file from the list of agents.
The Configuration column indicates the location of the config.yaml file,
or shows how to create one.
The agent configuration file manages the various agent features:
kubectl commands to your .gitlab-ci.yml file.The configuration file format for the agent is defined as a protocol buffer message in the source repository.
To view all the available configuration file fields:
ConfigurationFile in the
generated documentation to view the fields for the whole
agent configuration file.{{< history >}}
{{< /history >}}
In addition to the agents owned by your project, you can also view agents shared with the
ci_access and user_access keywords. Once an agent
is shared with a project, it automatically appears in the project agent tab.
To view the list of shared agents:
The list of shared agents and their clusters are displayed.
The activity logs help you to identify problems and get the information you need for troubleshooting. You can see events from a week before the current date. To view an agent's activity:
The activity list includes:
The connection status is logged when you connect an agent for the first time or after more than an hour of inactivity.
View and provide feedback about the UI in this epic.
{{< history >}}
grpc_level was introduced in GitLab 15.1.{{< /history >}}
To debug the cluster-side component (agentk) of the agent, set the log
level according to the available options:
errorinfodebugThe agent has two loggers:
info.error.You can change your log levels by using a top-level observability section in the agent configuration file, for example setting the levels to debug and warn:
observability:
logging:
level: debug
grpc_level: warn
When grpc_level is set to info or below, there are a lot of gRPC logs.
Commit the configuration changes and inspect the agent service logs:
kubectl logs -f -l=app=gitlab-agent -n gitlab-agent
For more information about debugging, see troubleshooting documentation.
{{< history >}}
cluster_agents_limit_tokens_created.cluster_agents_limit_tokens_created removed.{{< /history >}}
An agent can have only two active tokens at one time.
To reset the agent token without downtime:
You can remove an agent by using the GitLab UI or the GraphQL API. The agent and any associated tokens are removed from GitLab, but no changes are made in your Kubernetes cluster. You must clean up those resources manually.
To remove an agent from the UI:
Get the <cluster-agent-token-id> from a query in the interactive GraphQL explorer.
https://gitlab.example.com/-/graphql-explorer, replacing gitlab.example.com with your instance's URL.query{
project(fullPath: "<full-path-to-agent-configuration-project>") {
clusterAgent(name: "<agent-name>") {
id
tokens {
edges {
node {
id
}
}
}
}
}
}
Remove an agent record with GraphQL by deleting the clusterAgentToken.
mutation deleteAgent {
clusterAgentDelete(input: { id: "<cluster-agent-id>" } ) {
errors
}
}
mutation deleteToken {
clusterAgentTokenDelete(input: { id: "<cluster-agent-token-id>" }) {
errors
}
}
Verify whether the removal occurred successfully. If the output in the Pod logs includes unauthenticated, it means that the agent was successfully removed:
{
"level": "warn",
"time": "2021-04-29T23:44:07.598Z",
"msg": "GetConfiguration.Recv failed",
"error": "rpc error: code = Unauthenticated desc = unauthenticated"
}
Delete the agent in your cluster:
kubectl delete -n gitlab-kubernetes-agent -f ./resources.yml