Documentation
¶
Index ¶
- Constants
- Variables
- func Connect(svc *corev1.Service, waitForConnection bool) error
- func EnvsFromMap(envVars map[string]string) []v1.EnvVar
- func K8sEnabled() bool
- func NewKubernetesClient() (*kubernetes.Clientset, error)
- func Ptr[T any](value T) *T
- func Resources(cpu, mem string) map[string]string
- func ResourcesLarge() map[string]string
- func ResourcesMedium() map[string]string
- func ResourcesSmall() map[string]string
- func Run(ctx context.Context, cfg *Config) (string, *corev1.Service, error)
- func SizedVolumeClaim(size string) []v1.PersistentVolumeClaim
- func SortedKeys(m map[string]string) []string
- func TCPReadyProbe(port int) *v1.Probe
- func WaitReady(ctx context.Context, t time.Duration) error
- type API
- type App
- type Config
- type PodConfig
- type PortForwardConfig
- type PortForwardManager
Constants ¶
const ( // ClientReadyTimeout is a timeout client (tests) will wait until abandoning attempts ClientReadyTimeout = 1 * time.Minute // RetryDelay is a delay before retrying forwarding RetryDelay = 1 * time.Second // K8sFunctionCallTimeout is a common K8s API timeout we use in functions // function may contain multiple calls K8sFunctionCallTimeout = 2 * time.Minute )
const ( ManifestsDir = "pods-out" K8sNamespaceEnvVar = "KUBERNETES_NAMESPACE" )
const (
EnvVarLogLevel = "PODS_LOG_LEVEL"
)
Variables ¶
var (
L zerolog.Logger
)
Functions ¶
func Connect ¶ added in v0.14.1
Connect connects service to localhost, the same method is used internally by environment and externally by tests 'blocking' means it'd wait until first successful port connection
func K8sEnabled ¶
func K8sEnabled() bool
K8sEnabled is a flag that means Kubernetes in enabled, used in framework components
func NewKubernetesClient ¶
func NewKubernetesClient() (*kubernetes.Clientset, error)
NewKubernetesClient creates a new Kubernetes client
func ResourcesLarge ¶
ResourcesLarge returns large resource limits/requests
func ResourcesMedium ¶
ResourcesMedium returns medium resource limits/requests
func ResourcesSmall ¶
ResourcesSmall returns small resource limits/requests
func SizedVolumeClaim ¶
func SizedVolumeClaim(size string) []v1.PersistentVolumeClaim
func SortedKeys ¶
SortedKeys returns sorted keys of a map
func TCPReadyProbe ¶ added in v0.14.1
TCPReadyProbe is a default TCP port probe
Types ¶
type API ¶
type API struct {
ClientSet *kubernetes.Clientset
RESTConfig *rest.Config
// contains filtered or unexported fields
}
API is a struct that provides methods to interact with Kubernetes clusters.
var Client *API
Client is a global K8s client that we use for all deployments
func NewAPI ¶
NewAPI creates a new instance of K8s API. It takes the kubeconfig path and namespace as parameters.
func (*API) AllPodsReady ¶
AllPodsReady checks if all Pods in the namespace are ready. A Pod is considered ready if all its containers are ready and the Pod's phase is "Running".
func (*API) CreateNamespace ¶
CreateNamespace creates a new Kubernetes namespace with the specified name.
func (*API) RemoveNamespace ¶
RemoveNamespace deletes a Kubernetes namespace with the specified name.
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is an application context with a generated Kubernetes manifest
func (*App) GetConnectionDetails ¶ added in v0.14.1
GetConnectionDetails returns connection details needed to forward ports
type PodConfig ¶
type PodConfig struct {
StatefulSet bool
// Name is a pod name
Name *string
// Replicas amount of replicas for a pod
Replicas *int32
// Labels are K8s labels added to a pod
Labels map[string]string
// Annotations are K8s annotations added to a pod
Annotations map[string]string
// Image docker image URI in format $repo/$image_name:$tag, ex. "public.ecr.aws/chainlink/chainlink:v2.17.0"
Image *string
// Env represents container environment variables
Env []corev1.EnvVar
// Command is a container command to run on start
Command *string
// Ports is a list of $svc:$container ports, ex.: ["8080:80", "9090:90"]
Ports []string
// ConfigMap is a map of files in ConfigMap, ex.: "config.toml": `some_toml`
ConfigMap map[string]string
// ConfigMapMountPath mounts files with paths, ex.: "config.toml": "/config.toml"
ConfigMapMountPath map[string]string
// Secrets is a map of files in K8s Secret, ex. "secrets.toml": `some_secret`
Secrets map[string]string
// SecretsMountPath mounts secrets with paths, ex.: "secrets.toml": "/secrets.toml"
SecretsMountPath map[string]string
// ReadinessProbe is container readiness probe definition
ReadinessProbe *corev1.Probe
// Requests is K8s resources requests on CPU/Mem
Requests map[string]string
// Limits is K8s resources limits on CPU/Mem
Limits map[string]string
// ContainerSecurityContext is a container security context
ContainerSecurityContext *corev1.SecurityContext
// PodSecurityContext is a Pod security context
PodSecurityContext *corev1.PodSecurityContext
// VolumeClaimTemplates is a list K8s persistent volume claim templates
VolumeClaimTemplates []corev1.PersistentVolumeClaim
}
PodConfig describes particular Pod configuration
type PortForwardConfig ¶
PortForwardConfig represents a single port forward configuration
type PortForwardManager ¶
type PortForwardManager struct {
// contains filtered or unexported fields
}
PortForwardManager manages multiple port forwards
func NewForwarder ¶
func NewForwarder(api *API) *PortForwardManager
NewForwarder creates a new manager for multiple port forwards
func (*PortForwardManager) Forward ¶
func (m *PortForwardManager) Forward(configs []PortForwardConfig, waitForConnection bool) error
Forward starts multiple port forwards concurrently
func (*PortForwardManager) List ¶
func (m *PortForwardManager) List() []string
List returns all active port forwards
func (*PortForwardManager) Stop ¶
func (m *PortForwardManager) Stop(serviceName string, localPort int)
Stop stops a specific port forward
func (*PortForwardManager) StopAll ¶
func (m *PortForwardManager) StopAll()
StopAll stops all active port forwards