mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-04 14:35:32 +00:00
The Kubernetes backend copies actions and workspaces into job containers with `tar` over `pods/exec`, so every byte goes through the API server. On managed clusters that often sits in other zones than the nodes, so each byte can cross zones twice, and the copies load the API server. With `kubernetes.transfer.mode: auto` or `direct`, an init container copies `gitea-runner` into the job pod, and the job container fetches directories and copies of 64 KiB or more gzipped from the runner over the pod network. `auto` falls back to the API server for a job pod that cannot reach the runner, `direct` fails the job. Copies can hold secrets, so each is served once, over TLS 1.3 pinned to a certificate the runner generates, only to the job pod's IPs. Copying setup-go@v5, cache@v4, setup-java@v4 and build-push-action@v6 sends 11.6 MB through the API server on main and 532 B with this PR. Co-authored-by: silverwind <[email protected]> Co-authored-by: silverwind <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1354 Reviewed-by: silverwind <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"gitea.com/gitea/runner/act/container"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// loadKubernetesTransferCmd is what job pods run when kubernetes.transfer is on: the init container installs the binary, the job container fetches with it.
|
|
func loadKubernetesTransferCmd() *cobra.Command {
|
|
transferCmd := &cobra.Command{
|
|
Use: container.KubernetesTransferCommand,
|
|
Short: "Copy files from the runner into a Kubernetes job pod",
|
|
Hidden: true,
|
|
}
|
|
transferCmd.AddCommand(&cobra.Command{
|
|
Use: "install <path>",
|
|
Short: "Copy this binary to path",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(_cmd *cobra.Command, args []string) error {
|
|
return container.InstallKubernetesTransferHelper(args[0])
|
|
},
|
|
}, &cobra.Command{
|
|
Use: "fetch <dir>",
|
|
Short: "Extract the tar stream the transfer request on stdin points to into dir",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return container.FetchKubernetesTransfer(cmd.Context(), cmd.InOrStdin(), args[0])
|
|
},
|
|
})
|
|
return transferCmd
|
|
}
|