Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/topology/transport/podexec/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"time"
"fmt"

"github.com/tarantool/tarantool-operator/pkg/topology/transport/podexec/cli"
v1 "k8s.io/api/core/v1"
Expand All @@ -16,6 +17,8 @@ const (
resource = "pods"
subResource = "exec"
defaultTimeout = 2 * time.Second
// use this pod annotation to set cartridge container name if pod has sidecars
cartridgeContainerNameAnnotation = "tarantool.io/cartridge-container-name"
)

type PodExec struct {
Expand All @@ -34,6 +37,17 @@ func (r *PodExec) Exec(ctx context.Context, pod *v1.Pod, res interface{}, lua st
return err
}

// if pod has more than 1 container use annotation to get cartridge container name
if len(pod.Spec.Containers) > 1 {
cartridgeContainerName, ok := pod.Annotations[cartridgeContainerNameAnnotation]

if !ok {
return fmt.Errorf("pod %s contains more than one container. use pod annotation %s to set cartridge container name", pod.GetName(), cartridgeContainerNameAnnotation)
}

r.ContainerName = cartridgeContainerName
}

stdout, err := r.execShellCommand(ctx, command, pod.GetName(), pod.GetNamespace())
if err != nil {
return err
Expand Down