Skip to content

Commit ab6c482

Browse files
committed
feat: add extra field for console API
Add extra fields for enabling or disabling console API endpoints Signed-off-by: Santiago Jimenez Giraldo <santiago@redpanda.com>
1 parent f5ed1d9 commit ab6c482

File tree

5 files changed

+118
-6
lines changed

5 files changed

+118
-6
lines changed

src/go/k8s/api/vectorized/v1alpha1/console_types.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ type ConsoleSpec struct {
8282

8383
// The name of the ServiceAccount to be used by the Redpanda pods
8484
ServiceAccount *string `json:"serviceAccount,omitempty"`
85+
86+
// +optional
87+
// Console contains all configuration options for features that are generic,
88+
// such as enabling API endpoints.
89+
Console *ConsoleConfigField `json:"console,omitempty"`
8590
}
8691

8792
// Server is the Console app HTTP server config
@@ -265,6 +270,28 @@ type Connectivity struct {
265270
External string `json:"external,omitempty"`
266271
}
267272

273+
type ConsoleConfigField struct {
274+
// +optional
275+
// ConsoleAPI declares the configuration properties for managing the
276+
// connect/grpc/grpc-gateway API endpoints.
277+
API ConsoleAPI `json:"api" yaml:"api"`
278+
}
279+
280+
type ConsoleAPI struct {
281+
// +kubebuilder:default=true
282+
// Enabled determines whether any of the connect/grpc/grpc-gateway endpoints
283+
// will be mounted to the server.
284+
Enabled bool `json:"enabled"`
285+
// +kubebuilder:default={"*"}
286+
// EnabledProcedures is a list of procedure names that shall be allowed.
287+
// If a procedure is called that is not on this list a descriptive error
288+
// will be returned. A procedure name has the following format, regardless
289+
// whether it's called via connect, gRPC or the HTTP interface:
290+
// "/redpanda.api.dataplane.v1alpha1.UserService/ListUsers".
291+
// You can use "*" to enable all procedures.
292+
EnabledProcedures []string `json:"enabledProcedures"`
293+
}
294+
268295
//+kubebuilder:object:root=true
269296
//+kubebuilder:subresource:status
270297

src/go/k8s/api/vectorized/v1alpha1/zz_generated.deepcopy.go

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

src/go/k8s/config/crd/bases/redpanda.vectorized.io_consoles.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,36 @@ spec:
303303
format: duration
304304
type: string
305305
type: object
306+
console:
307+
description: Console contains all configuration options for features
308+
that are generic, such as enabling API endpoints.
309+
properties:
310+
api:
311+
description: ConsoleAPI declares the configuration properties
312+
for managing the connect/grpc/grpc-gateway API endpoints.
313+
properties:
314+
enabled:
315+
default: true
316+
description: Enabled determines whether any of the connect/grpc/grpc-gateway
317+
endpoints will be mounted to the server.
318+
type: boolean
319+
enabledProcedures:
320+
default:
321+
- '*'
322+
description: 'EnabledProcedures is a list of procedure names
323+
that shall be allowed. If a procedure is called that is
324+
not on this list a descriptive error will be returned. A
325+
procedure name has the following format, regardless whether
326+
it''s called via connect, gRPC or the HTTP interface: "/redpanda.api.dataplane.v1alpha1.UserService/ListUsers".
327+
You can use "*" to enable all procedures.'
328+
items:
329+
type: string
330+
type: array
331+
required:
332+
- enabled
333+
- enabledProcedures
334+
type: object
335+
type: object
306336
deployment:
307337
description: Deployment defines configurable fields for the Console
308338
Deployment resource

src/go/k8s/pkg/console/configmap.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func (cm *ConfigMap) generateConsoleConfig(
149149
Kafka: cm.genKafka(username),
150150
Enterprise: cm.genEnterprise(),
151151
Redpanda: cm.genRedpanda(),
152+
Console: cm.genConsoleConfigField(),
152153
}
153154

154155
consoleConfig.Connect, err = cm.genConnect(ctx)
@@ -225,6 +226,18 @@ func (cm *ConfigMap) genEnterprise() (e Enterprise) {
225226
return e
226227
}
227228

229+
func (cm *ConfigMap) genConsoleConfigField() (c vectorizedv1alpha1.ConsoleConfigField) {
230+
if console := cm.consoleobj.Spec.Console; console != nil {
231+
return vectorizedv1alpha1.ConsoleConfigField{
232+
API: vectorizedv1alpha1.ConsoleAPI{
233+
Enabled: console.API.Enabled,
234+
EnabledProcedures: console.API.EnabledProcedures,
235+
},
236+
}
237+
}
238+
return c
239+
}
240+
228241
func (cm *ConfigMap) genCloud() CloudConfig {
229242
if cm.consoleobj.Spec.Cloud == nil ||
230243
cm.consoleobj.Spec.Cloud.PrometheusEndpoint == nil {

src/go/k8s/pkg/console/console.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ type ConsoleConfig struct {
3030
Kafka config.Kafka `json:"kafka" yaml:"kafka"`
3131
Connect config.Connect `json:"connect" yaml:"connect"`
3232

33-
License string `json:"license,omitempty" yaml:"license,omitempty"`
34-
Enterprise Enterprise `json:"enterprise,omitempty" yaml:"enterprise,omitempty"`
35-
Login EnterpriseLogin `json:"login,omitempty" yaml:"login,omitempty"`
36-
Cloud CloudConfig `json:"cloud,omitempty" yaml:"cloud,omitempty"`
37-
Redpanda Redpanda `json:"redpanda,omitempty" yaml:"redpanda,omitempty"`
38-
SecretStore EnterpriseSecretStore `json:"secretStore,omitempty" yaml:"secretStore,omitempty"`
33+
License string `json:"license,omitempty" yaml:"license,omitempty"`
34+
Enterprise Enterprise `json:"enterprise,omitempty" yaml:"enterprise,omitempty"`
35+
Login EnterpriseLogin `json:"login,omitempty" yaml:"login,omitempty"`
36+
Cloud CloudConfig `json:"cloud,omitempty" yaml:"cloud,omitempty"`
37+
Redpanda Redpanda `json:"redpanda,omitempty" yaml:"redpanda,omitempty"`
38+
SecretStore EnterpriseSecretStore `json:"secretStore,omitempty" yaml:"secretStore,omitempty"`
39+
Console vectorizedv1alpha1.ConsoleConfigField `json:"console,omitempty" yaml:"console,omitempty"`
3940
}
4041

4142
// SetDefaults sets sane defaults

0 commit comments

Comments
 (0)