Skip to content

Commit 8a17e7c

Browse files
committed
Make Repository URL configurable
In the flux based deployment the hardcoded Repository URL in `HelmRepository` flux custom resource now can be configured via Operator flag `helm-repository-url`.
1 parent e25a66a commit 8a17e7c

File tree

7 files changed

+71
-13
lines changed

7 files changed

+71
-13
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
project: operator
2+
kind: Added
3+
body: |
4+
Users in air-gapped environments that cannot access the official Redpanda Helm Chart repository (`https://charts.redpanda.com/`)
5+
can now specify an alternative Helm chart repository using the `helm-repository-url` flag. In the Redpanda Operator Helm chart,
6+
this flag is not exposed as an option in the Helm values. Instead, it must be set as an input in the `additionalCmdFlags` array.
7+
8+
The given repository must include the following charts:
9+
* Redpanda
10+
* Console
11+
* Connectors
12+
time: 2025-01-14T11:31:13.061026+01:00

operator/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
66

77

88
## Unreleased
9+
### Added
10+
* Users in air-gapped environments that cannot access the official Redpanda Helm Chart repository (`https://charts.redpanda.com/`)
11+
can now specify an alternative Helm chart repository using the `helm-repository-url` flag. In the Redpanda Operator Helm chart,
12+
this flag is not exposed as an option in the Helm values. Instead, it must be set as an input in the `additionalCmdFlags` array.
13+
14+
The given repository must include the following charts:
15+
* Redpanda
16+
* Console
17+
* Connectors
18+
919
### Changed
1020
* For any user that is mirroring configurator image (air-gapped environment) and changes entrypoint
1121
or wraps configurator with additional script the following constraint need to be meet:

operator/api/redpanda/v1alpha2/redpanda_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import (
3232
)
3333

3434
const (
35-
RedpandaChartRepository = "https://charts.redpanda.com/"
36-
3735
// ClusterConfigSynced is a condition indicating whether or not the
3836
// redpanda cluster's configuration is up to date with the desired config.
3937
ClusterConfigSynced = "ClusterConfigSynced"

operator/cmd/run/run.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func Command() *cobra.Command {
135135
unbinderSelector LabelSelectorValue
136136
autoDeletePVCs bool
137137
forceDefluxedMode bool
138+
helmRepositoryURL string
138139
)
139140

140141
cmd := &cobra.Command{
@@ -166,6 +167,7 @@ func Command() *cobra.Command {
166167
autoDeletePVCs,
167168
forceDefluxedMode,
168169
pprofAddr,
170+
helmRepositoryURL,
169171
)
170172
},
171173
}
@@ -198,6 +200,7 @@ func Command() *cobra.Command {
198200
cmd.Flags().Var(&unbinderSelector, "unbinder-label-selector", "if provided, a Kubernetes label selector that will filter Pods to be considered by the PVCUnbinder.")
199201
cmd.Flags().BoolVar(&autoDeletePVCs, "auto-delete-pvcs", false, "Use StatefulSet PersistentVolumeClaimRetentionPolicy to auto delete PVCs on scale down and Cluster resource delete.")
200202
cmd.Flags().BoolVar(&forceDefluxedMode, "force-defluxed-mode", false, "specifies the default value for useFlux of Redpanda CRs if not specified. May be used in conjunction with enable-helm-controllers=false")
203+
cmd.Flags().StringVar(&helmRepositoryURL, "helm-repository-url", "https://charts.redpanda.com/", "URL to overwrite official `https://charts.redpanda.com/` Redpanda Helm chart repository")
201204

202205
// 3rd party flags.
203206
clientOptions.BindFlags(cmd.Flags())
@@ -234,6 +237,7 @@ func Run(
234237
autoDeletePVCs bool,
235238
forceDefluxedMode bool,
236239
pprofAddr string,
240+
helmRepositoryURL string,
237241
) error {
238242
setupLog := ctrl.LoggerFrom(ctx).WithName("setup")
239243

@@ -387,6 +391,7 @@ func Run(
387391
EventRecorder: mgr.GetEventRecorderFor("RedpandaReconciler"),
388392
ClientFactory: internalclient.NewFactory(mgr.GetConfig(), mgr.GetClient()),
389393
DefaultDisableFlux: forceDefluxedMode,
394+
HelmRepositoryURL: helmRepositoryURL,
390395
}).SetupWithManager(ctx, mgr); err != nil {
391396
setupLog.Error(err, "unable to create controller", "controller", "Redpanda")
392397
return err

operator/internal/controller/redpanda/redpanda_controller.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ type RedpandaReconciler struct {
8383
EventRecorder kuberecorder.EventRecorder
8484
ClientFactory internalclient.ClientFactory
8585
DefaultDisableFlux bool
86+
// HelmRepositorySpec.URL points to Redpanda helm repository where the following charts can be located:
87+
// * Redpanda
88+
// * Console
89+
// * Connectors
90+
// If not provided the v1alpha2.RedpandaChartRepository constant will be used.
91+
HelmRepositoryURL string
8692
}
8793

8894
// flux resources main resources
@@ -825,7 +831,7 @@ func (r *RedpandaReconciler) reconcileHelmRelease(ctx context.Context, rp *v1alp
825831
}
826832

827833
func (r *RedpandaReconciler) reconcileHelmRepository(ctx context.Context, rp *v1alpha2.Redpanda) error {
828-
repo := r.helmRepositoryFromTemplate(rp)
834+
repo := r.HelmRepositoryFromTemplate(rp)
829835

830836
if err := r.apply(ctx, repo); err != nil {
831837
return fmt.Errorf("applying HelmRepository: %w", err)
@@ -949,7 +955,7 @@ func (r *RedpandaReconciler) createHelmReleaseFromTemplate(ctx context.Context,
949955
}, nil
950956
}
951957

952-
func (r *RedpandaReconciler) helmRepositoryFromTemplate(rp *v1alpha2.Redpanda) *sourcev1.HelmRepository {
958+
func (r *RedpandaReconciler) HelmRepositoryFromTemplate(rp *v1alpha2.Redpanda) *sourcev1.HelmRepository {
953959
return &sourcev1.HelmRepository{
954960
ObjectMeta: metav1.ObjectMeta{
955961
Name: rp.GetHelmRepositoryName(),
@@ -959,7 +965,7 @@ func (r *RedpandaReconciler) helmRepositoryFromTemplate(rp *v1alpha2.Redpanda) *
959965
Spec: sourcev1.HelmRepositorySpec{
960966
Suspend: !r.IsFluxEnabled(rp.Spec.ChartRef.UseFlux),
961967
Interval: metav1.Duration{Duration: 30 * time.Second},
962-
URL: v1alpha2.RedpandaChartRepository,
968+
URL: r.HelmRepositoryURL,
963969
},
964970
}
965971
}

operator/internal/controller/redpanda/redpanda_controller_test.go

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,10 +702,11 @@ func (s *RedpandaControllerSuite) SetupSuite() {
702702

703703
// TODO should probably run other reconcilers here.
704704
if err := (&redpanda.RedpandaReconciler{
705-
Client: mgr.GetClient(),
706-
Scheme: mgr.GetScheme(),
707-
EventRecorder: mgr.GetEventRecorderFor("Redpanda"),
708-
ClientFactory: s.clientFactory,
705+
Client: mgr.GetClient(),
706+
Scheme: mgr.GetScheme(),
707+
EventRecorder: mgr.GetEventRecorderFor("Redpanda"),
708+
ClientFactory: s.clientFactory,
709+
HelmRepositoryURL: "https://charts.redpanda.com/",
709710
}).SetupWithManager(s.ctx, mgr); err != nil {
710711
return err
711712
}
@@ -979,6 +980,31 @@ func TestIsFluxEnabled(t *testing.T) {
979980
}
980981
}
981982

983+
func TestHelmRepositoryURL(t *testing.T) {
984+
for _, tc := range []struct {
985+
helmRepoURL string
986+
}{
987+
{""},
988+
{"http://some-url.com/"},
989+
{"address-that-can-be-resolved"},
990+
} {
991+
r := redpanda.RedpandaReconciler{HelmRepositoryURL: tc.helmRepoURL}
992+
rp := &redpandav1alpha2.Redpanda{
993+
ObjectMeta: metav1.ObjectMeta{
994+
Name: "Redpanda-resource",
995+
},
996+
Spec: redpandav1alpha2.RedpandaSpec{
997+
ChartRef: redpandav1alpha2.ChartRef{
998+
ChartVersion: "5.x.x",
999+
},
1000+
ClusterSpec: &redpandav1alpha2.RedpandaClusterSpec{},
1001+
},
1002+
}
1003+
repo := r.HelmRepositoryFromTemplate(rp)
1004+
assert.Equal(t, tc.helmRepoURL, repo.Spec.URL)
1005+
}
1006+
}
1007+
9821008
// TestControllerRBAC asserts that the declared Roles and ClusterRoles of the
9831009
// RedpandaReconciler line up with all the resource types it needs to manage.
9841010
func TestControllerRBAC(t *testing.T) {

operator/internal/controller/vectorized/test/suite_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ var _ = BeforeSuite(func(suiteCtx SpecContext) {
199199

200200
// Redpanda Reconciler
201201
err = (&redpanda.RedpandaReconciler{
202-
Client: k8sManager.GetClient(),
203-
ClientFactory: internalclient.NewFactory(k8sManager.GetConfig(), k8sManager.GetClient()),
204-
Scheme: k8sManager.GetScheme(),
205-
EventRecorder: k8sManager.GetEventRecorderFor("RedpandaReconciler"),
202+
Client: k8sManager.GetClient(),
203+
ClientFactory: internalclient.NewFactory(k8sManager.GetConfig(), k8sManager.GetClient()),
204+
Scheme: k8sManager.GetScheme(),
205+
EventRecorder: k8sManager.GetEventRecorderFor("RedpandaReconciler"),
206+
HelmRepositoryURL: "https://charts.redpanda.com/",
206207
}).SetupWithManager(ctx, k8sManager)
207208
Expect(err).ToNot(HaveOccurred())
208209

0 commit comments

Comments
 (0)