Skip to content

Commit e361147

Browse files
committed
Two deployers
Signed-off-by: David L. Chandler <[email protected]>
1 parent bbc886e commit e361147

File tree

10 files changed

+211
-181
lines changed

10 files changed

+211
-181
lines changed

pkg/deployer/deployer.go

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ type Deployer struct {
5959
agwControllerName string
6060
agwGatewayClassName string
6161
chart *chart.Chart
62-
agentgatewayChart *chart.Chart
6362
scheme *runtime.Scheme
6463
client apiclient.Client
6564
helmValues HelmValuesGenerator
@@ -82,7 +81,7 @@ func WithGVKToGVRMapper(m map[schema.GroupVersionKind]schema.GroupVersionResourc
8281
}
8382
}
8483

85-
// NewDeployer creates a new gateway/inference pool/etc
84+
// NewDeployer creates a new gateway/inference pool/etc deployer with a single chart.
8685
// TODO [danehans]: Reloading the chart for every reconciliation is inefficient.
8786
// See https://github.com/kgateway-dev/kgateway/issues/10672 for details.
8887
func NewDeployer(
@@ -101,36 +100,6 @@ func NewDeployer(
101100
scheme: scheme,
102101
client: client,
103102
chart: chart,
104-
agentgatewayChart: nil,
105-
helmValues: hvg,
106-
helmReleaseNameAndNamespaceGenerator: helmReleaseNameAndNamespaceGenerator,
107-
patcher: applyPatch,
108-
}
109-
for _, o := range opts {
110-
o(d)
111-
}
112-
return d
113-
}
114-
115-
// NewDeployerWithMultipleCharts creates a new gateway deployer that supports both envoy and agentgateway charts
116-
func NewDeployerWithMultipleCharts(
117-
controllerName, agwControllerName, agwGatewayClassName string,
118-
scheme *runtime.Scheme,
119-
client apiclient.Client,
120-
envoyChart *chart.Chart,
121-
agentgatewayChart *chart.Chart,
122-
hvg HelmValuesGenerator,
123-
helmReleaseNameAndNamespaceGenerator func(obj client.Object) (string, string),
124-
opts ...Option,
125-
) *Deployer {
126-
d := &Deployer{
127-
controllerName: controllerName,
128-
agwControllerName: agwControllerName,
129-
agwGatewayClassName: agwGatewayClassName,
130-
scheme: scheme,
131-
client: client,
132-
chart: envoyChart,
133-
agentgatewayChart: agentgatewayChart,
134103
helmValues: hvg,
135104
helmReleaseNameAndNamespaceGenerator: helmReleaseNameAndNamespaceGenerator,
136105
patcher: applyPatch,
@@ -183,12 +152,7 @@ func (d *Deployer) RenderChartToObjects(ns, name string, vals map[string]any) ([
183152
// It returns the list of Objects that are rendered, and an optional error if rendering failed,
184153
// or converting the rendered manifests to objects failed.
185154
func (d *Deployer) RenderToObjects(ns, name string, vals map[string]any) ([]client.Object, error) {
186-
return d.RenderToObjectsWithChartType(ns, name, vals, ChartTypeEnvoy)
187-
}
188-
189-
// RenderToObjectsWithChartType renders the helm chart with the specified chart type.
190-
func (d *Deployer) RenderToObjectsWithChartType(ns, name string, vals map[string]any, chartType ChartType) ([]client.Object, error) {
191-
manifest, err := d.RenderManifestWithChartType(ns, name, vals, chartType)
155+
manifest, err := d.RenderManifest(ns, name, vals)
192156
if err != nil {
193157
return nil, err
194158
}
@@ -201,11 +165,6 @@ func (d *Deployer) RenderToObjectsWithChartType(ns, name string, vals map[string
201165
}
202166

203167
func (d *Deployer) RenderManifest(ns, name string, vals map[string]any) ([]byte, error) {
204-
return d.RenderManifestWithChartType(ns, name, vals, ChartTypeEnvoy)
205-
}
206-
207-
// RenderManifestWithChartType renders the helm chart with the specified chart type.
208-
func (d *Deployer) RenderManifestWithChartType(ns, name string, vals map[string]any, chartType ChartType) ([]byte, error) {
209168
mem := driver.NewMemory()
210169
mem.SetNamespace(ns)
211170
cfg := &action.Configuration{
@@ -221,13 +180,7 @@ func (d *Deployer) RenderManifestWithChartType(ns, name string, vals map[string]
221180
install.ClientOnly = true
222181
installCtx := context.Background()
223182

224-
// Select the appropriate chart based on chart type
225-
chartToUse := d.chart
226-
if chartType == ChartTypeAgentgateway && d.agentgatewayChart != nil {
227-
chartToUse = d.agentgatewayChart
228-
}
229-
230-
release, err := install.RunWithContext(installCtx, chartToUse, vals)
183+
release, err := install.RunWithContext(installCtx, d.chart, vals)
231184
if err != nil {
232185
return nil, fmt.Errorf("failed to render helm chart for %s.%s: %w", ns, name, err)
233186
}
@@ -262,10 +215,8 @@ func (d *Deployer) GetObjsToDeploy(ctx context.Context, obj client.Object) ([]cl
262215
"values", vals,
263216
)
264217

265-
chartType := d.helmValues.GetChartType(ctx, obj)
266-
267218
rname, rns := d.helmReleaseNameAndNamespaceGenerator(obj)
268-
objs, err := d.RenderToObjectsWithChartType(rns, rname, vals, chartType)
219+
objs, err := d.RenderToObjects(rns, rname, vals)
269220
if err != nil {
270221
return nil, fmt.Errorf("failed to get objects to deploy %s.%s: %w", obj.GetNamespace(), obj.GetName(), err)
271222
}

0 commit comments

Comments
 (0)