Skip to content

Commit 5680a90

Browse files
dilyevskyclaude
andcommitted
[cmd] integrate tunnel client into apoxy run runtime component
Add tunnel as a fully functional runtime component that can be started via `apoxy run` config, enabling in-cluster tunnel connectivity alongside kube-aggregation and kube-mirror components. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ff3e7b8 commit 5680a90

File tree

4 files changed

+496
-1
lines changed

4 files changed

+496
-1
lines changed

api/config/v1alpha1/config_types.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ type STUNServer struct {
9494

9595
// TunnelConfig is the configuration for the tunnel.
9696
type TunnelConfig struct {
97+
// Name is the name of the TunnelNode to connect to.
98+
// Required when running as a runtime component.
99+
Name string `json:"name,omitempty"`
97100
// Mode is the mode of the tunnel.
98101
Mode TunnelMode `json:"mode,omitempty"`
99102
// SocksPort, when running in userspace mode, is the port to listen on for
@@ -107,6 +110,29 @@ type TunnelConfig struct {
107110
// If not specified, packet sniffing will be disabled.
108111
// This is only available in userspace mode and intended for debugging purposes.
109112
PacketCapturePath string `json:"packetCapturePath,omitempty"`
113+
// MinConns is the minimum number of concurrent tunnel connections to maintain.
114+
// Defaults to 1.
115+
// +optional
116+
MinConns *int `json:"minConns,omitempty"`
117+
// HealthAddr is the address to listen on for health checks.
118+
// Defaults to ":8080". Set to empty string to disable.
119+
// +optional
120+
HealthAddr string `json:"healthAddr,omitempty"`
121+
// MetricsAddr is the address to listen on for metrics.
122+
// Defaults to ":8081". Set to empty string to disable.
123+
// +optional
124+
MetricsAddr string `json:"metricsAddr,omitempty"`
125+
// AutoCreate will auto-create the TunnelNode if it doesn't exist.
126+
// +optional
127+
AutoCreate bool `json:"autoCreate,omitempty"`
128+
// EndpointSelection is the strategy for selecting tunnel server endpoints.
129+
// Valid values are "latency" and "random". Defaults to "latency".
130+
// +optional
131+
EndpointSelection string `json:"endpointSelection,omitempty"`
132+
// InsecureSkipVerify skips TLS verification when connecting to tunnel servers.
133+
// Only use for development/testing.
134+
// +optional
135+
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
110136
}
111137

112138
// TunnelMode is the mode of the tunnel.

api/config/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cmd/run.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@ Components are defined under runtime.components in the config. Example:
8181
return runKubeMirror(ctx, cfg, mirrorCfg)
8282
})
8383
case configv1alpha1.RuntimeComponentTunnel:
84-
return fmt.Errorf("tunnel runtime component not yet implemented")
84+
if comp.Tunnel == nil {
85+
return fmt.Errorf("tunnel component requires tunnel config")
86+
}
87+
tunCfg := resolveTunnelConfig(comp.Tunnel)
88+
if err := validateTunnelConfig(cfg, tunCfg); err != nil {
89+
return fmt.Errorf("invalid tunnel config: %w", err)
90+
}
91+
g.Go(func() error {
92+
return runTunnel(ctx, cfg, tunCfg)
93+
})
8594
default:
8695
return fmt.Errorf("unknown runtime component type: %q", comp.Type)
8796
}

0 commit comments

Comments
 (0)