Kubernetes
Hoop.dev can be configured to use the kubectl command line to manage resources and execute actions on workloads in Kubernetes.
Prerequisites
To get the most out of this guide, you will need to:
- Either create an account in our managed instance or deploy your own hoop.dev instance
- You must be your account administrator to perform the following commands
Connection Configuration
Name | Type | Description |
---|---|---|
KUBECONFIG | filesystem | A https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/ with permission to exec into pods in a namespace |
Connection Command
The assumption is that the service account where the agent is deployed has the necessary permissions to interact with the Kubernetes API. Alternatively, create the connection passing your local KUBECONFIG. Example:
How to Use
It’s possible to narrow down the commands into distinct connections; this gives a better user experience.
- Update the connection with the command below
Then it’s possible
Interactive
kubectl
provides ways to create interactive sessions with pods. It’s possible to map these commands to Hoop to obtain interactive sessions allocating a pseudo-TTY.
Connection Command
How to Use
Start an interactive bash session with a deployment/pod
This will open an interactive session with the deployment myapp
. It’s possible to map any command that spawns an interactive session.
Then, it’s possible to gain a rails console session
Note that kubectl exec
is used with -tty
and --stdin
arguments. These flags are required when using hoop connect
One-off scripts
Processes can be spawned in an ad-hoc manner using kubectl exec
. However, in some cases, an interactive shell may be overly permissive.
Connection Configuration
Name | Type | Description |
---|---|---|
KUBECONFIG | filesystem | A https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/ with permission to exec into pods in a namespace |
Connection Command
How to Use
This example executes a one-off process using ruby.
Narrowing down the exec arguments allows passing the stdin and executing ruby scripts.
- Edit the connection command with the bellow content
Then, it’s possible
The connection now runs a one-off process accepting ruby scripts from the standard input.