Add KAS Endpoint to deploy a web terminal pod
Add an endpoint that deploys the container image to be called by rails
Requirements
Add endpoint that applies a manifest similar to the example kubernetes.yml that spins up a web terminal pod, returning it and its namespace in the payload for rails to pass to the frontend.
The manifest specifically needs to ensure the pod uses the agent's service account. It also needs to set stdin: true, tty: true, and stdinOnce: true. The testing JS API call is currently
coreV1Api.createCoreV1NamespacedPod('web-terminal', {
metadata: { generateName: 'web-terminal-' },
spec: {
serviceAccountName: 'web-terminal',
restartPolicy: 'Never',
containers: [
{
image: 'registry.gitlab.com/gitlab-org/cluster-integration/shell-image:v16.4.0',
name: 'web-terminal',
stdin: true,
stdinOnce: true,
tty: true,
},
],
},
})
The image tag should match GitLab's MAJOR and MINOR versions in the following pattern: vMAJOR.MINOR
The namespace and pod name should be recorded to automate the clean up of pods in a later iteration.
Proposal
gRPC endpoint
Add a new server module called web_terminal. It should expose a new gRPC endpoint that accepts:
imageservice_accountagent_id
as parameters to deploy a web-terminal shell in a Kubernetes cluster. This endpoint should return the agent namespace and the web terminal pod name, e.g.:
{ "namespace": "agent-namespace", "pod": "web-terminal-abcdf" }
kas-grpc gem
To use the new API endpoint Rails needs the gRPC+proto definitions via the kas-grpc GEM:
- Make the build generate and copy the necessary files into the gem directory. Edit https://gitlab.com/gitlab-org/cluster-integration/gitlab-agent/-/blob/master/pkg/ruby/BUILD.bazel to add the new RPC directory.
- Get that merged.
- Release the new GEM version.
- Use the GEM in the Rails code to call the new API.