Skip to content

Commit e1326a6

Browse files
authored
k8s-gateway: support configurable deployer and plugin translation (#9227)
* support configurable deployer and plugin tarnslation * add changelog * define defaults * PR feedback * bad find/replace * handle bad override, avoid npe
1 parent 112ed69 commit e1326a6

File tree

6 files changed

+61
-19
lines changed

6 files changed

+61
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
changelog:
2+
- type: NON_USER_FACING
3+
issueLink: https://github.com/solo-io/solo-projects/issues/5874
4+
resolvesIssue: false
5+
description: >-
6+
Run the PluginRegistryFactory supplied by the setup.Extensions, to ensure that the Enterprise ControlPlane
7+
runs all the Enterprise plugins.
8+
Create an experimental API (temporary) to configure the image used for the proxy workloads. This will be used
9+
by the Enterprise ControlPlane, while the workload provisioning API is being discussed.

projects/gateway2/controller/start.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ package controller
33
import (
44
"context"
55

6+
v1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
7+
"github.com/solo-io/gloo/projects/gloo/pkg/plugins"
8+
"github.com/solo-io/gloo/projects/gloo/pkg/translator"
9+
610
"github.com/solo-io/gloo/projects/gateway2/wellknown"
711

812
"sigs.k8s.io/controller-runtime/pkg/log/zap"
@@ -35,6 +39,12 @@ var (
3539
type StartConfig struct {
3640
Dev bool
3741
ControlPlane bootstrap.ControlPlane
42+
43+
Settings *v1.Settings
44+
45+
// GlooPluginRegistryFactory is the factory function to produce a PluginRegistry
46+
// The plugins in this registry are used during the conversion of a Proxy resource into an xDS Snapshot
47+
GlooPluginRegistryFactory plugins.PluginRegistryFactory
3848
}
3949

4050
// Start runs the controllers responsible for processing the K8s Gateway API objects
@@ -66,7 +76,10 @@ func Start(ctx context.Context, cfg StartConfig) error {
6676
// TODO: replace this with something that checks that we have xds snapshot ready (or that we don't need one).
6777
mgr.AddReadyzCheck("ready-ping", healthz.Ping)
6878

69-
glooTranslator := newGlooTranslator(ctx)
79+
glooTranslator := translator.NewDefaultTranslator(
80+
cfg.Settings,
81+
cfg.GlooPluginRegistryFactory(ctx))
82+
7083
var sanz sanitizer.XdsSanitizers
7184
inputChannels := xds.NewXdsInputChannels()
7285
xdsSyncer := xds.NewXdsSyncer(

projects/gateway2/controller/translator.go

-17
This file was deleted.

projects/gateway2/deployer/deployer.go

+28
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import (
77
"fmt"
88
"io"
99
"io/fs"
10+
"os"
1011
"path/filepath"
12+
"strings"
13+
14+
"github.com/solo-io/gloo/projects/gloo/constants"
1115

1216
"github.com/solo-io/gloo/pkg/version"
1317
"github.com/solo-io/gloo/projects/gateway2/helm"
@@ -150,6 +154,7 @@ func (d *Deployer) renderChartToObjects(ctx context.Context, gw *api.Gateway) ([
150154
"host": fmt.Sprintf("gloo.%s.svc.%s", defaults.GlooSystem, "cluster.local"),
151155
"port": d.inputs.Port,
152156
},
157+
"image": getDeployerImageValues(),
153158
},
154159
}
155160
if d.inputs.Dev {
@@ -309,3 +314,26 @@ func ConvertYAMLToObjects(scheme *runtime.Scheme, yamlData []byte) ([]client.Obj
309314

310315
return objs, nil
311316
}
317+
318+
func getDeployerImageValues() map[string]any {
319+
image := os.Getenv(constants.GlooGatewayDeployerImage)
320+
defaultImageValues := map[string]any{
321+
// If tag is not defined, we fall back to the default behavior, which is to use that Chart version
322+
"tag": "",
323+
}
324+
325+
if image == "" {
326+
// If the env is not defined, return the default
327+
return defaultImageValues
328+
}
329+
330+
imageParts := strings.Split(image, ":")
331+
if len(imageParts) != 2 {
332+
// If the user provided an invalid override, fallback to the default
333+
return defaultImageValues
334+
}
335+
return map[string]any{
336+
"repository": imageParts[0],
337+
"tag": imageParts[1],
338+
}
339+
}

projects/gloo/constants/gloo_gateway.go

+7
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@ package constants
22

33
const (
44
GlooGatewayEnableK8sGwControllerEnv = "GG_EXPERIMENTAL_K8S_GW_CONTROLLER"
5+
6+
// GlooGatewayDeployerImage is an experimental API that allows users to inject the image
7+
// that the deployer should provision. The value should be in the form:
8+
// [image_repository:image_tag] --> quay.io/solo-io/gloo-envoy-wrapper:1.17.0-beta1
9+
// This API is intended to be short-lived, as the long-term vision is to support a CR to define
10+
// configuration for our deployer
11+
GlooGatewayDeployerImage = "GG_EXPERIMENTAL_DEPLOYER_IMAGE"
512
)

projects/gloo/pkg/syncer/setup/start_func.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ func ExecuteAsynchronousStartFuncs(
4545
func K8sGatewayControllerStartFunc() StartFunc {
4646
return func(ctx context.Context, opts bootstrap.Opts, extensions Extensions) error {
4747
return controller.Start(ctx, controller.StartConfig{
48-
ControlPlane: opts.ControlPlane,
48+
ControlPlane: opts.ControlPlane,
49+
Settings: opts.Settings,
50+
GlooPluginRegistryFactory: extensions.PluginRegistryFactory,
4951

5052
// Useful for development purposes
5153
// At the moment, this is not tied to any user-facing API

0 commit comments

Comments
 (0)