logo

Kubernetes

kubectl

Hoop could be configured to use the kubectl command line to manage resources or execute actions on workloads in Kubernetes.

Connection Configuration

Name
Type
Description
KUBECONFIG
filesystem
A kubeconfig file with permission to exec into pods in a namespace

Connection Command

plain text
kubectl

How to Use

plain text
# view pods in the default namespace hoop exec my-conn-k8s -- get pods # restart an app hoop exec k8s -- rollout restart deployment/myapp # scale up an app hoop exec my-conn-k8s -- scale --replicas=3 deployment/myapp
It’s possible to narrow down the commands in distinct connections, this gives a better user experience
  • Update the connection with the command bellow
plain text
kubectl --namespace prod rollout
Then it’s possible
plain text
hoop exec my-conn-k8s -- restart deployment/myapp hoop exec my-conn-k8s -- undo deployment/myapp

Interactive


kubectl provides ways of creating interactive sessions with pods. It’s possible to map these commands to Hoop to obtain interactive sessions allocating a pseudo TTY.

Connection Command

plain text
kubectl exec --tty --stdin deployment/myapp --

How to Use

Start an interactive bash session with a deployment/pod
plain text
hoop connect myapp -- bash
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
plain text
hoop connect myapp -- rails console
:::info IMPORTANT Note that kubectl exec is used with -tty and --stdin arguments. These flags are required when using hoop connect. :::

One-off scripts


Processes could be spawn in an ad-hoc manner with kubectl exec. In some cases an interactive shell could be too much permissive.

Connection Configuration

Name
Type
Description
KUBECONFIG
filesystem
A kubeconfig file with permission to exec into pods in a namespace

Connection Command

plain text
kubectl exec --stdin deployment/myapp --

How to Use

This example executes an one-off process using ruby.
plain text
hoop exec myapp-oneoff -- rails runner 'puts Rails.env'
Narrowing down the exec arguments, allow passing the stdin and executing ruby scripts.
  • Edit the connection command with the bellow content
plain text
kubectl exec --stdin deployment/myapp -- rails runner -
Then, it’s possible
plain text
hoop exec myapp-oneoff <<EOF myvar='Hello' puts myvar EOF
The connection now runs one-off process accepting ruby scripts from the standard input.

Powered by Notaku