Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8s: Allow connectors to be deployed with operator. #9

Merged
merged 5 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/go/k8s/api/redpanda/v1alpha1/redpanda_clusterspec_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type RedpandaClusterSpec struct {

Console *RedpandaConsole `json:"console,omitempty"`

Connectors *RedpandaConnectors `json:"connectors,omitempty"`

Auth *Auth `json:"auth,omitempty"`

TLS *TLS `json:"tls,omitempty"`
Expand Down Expand Up @@ -164,6 +166,17 @@ type ConsoleCreateObj struct {
Create bool `json:"create"`
}

type RedpandaConnectors struct {
Enabled *bool `json:"enabled,omitempty"`

Deployment *ConnectorsCreateObj `json:"deployment,omitempty"`
Test *ConnectorsCreateObj `json:"test,omitempty"`
}

type ConnectorsCreateObj struct {
Create *bool `json:"enabled,omitempty"`
}
Comment on lines +169 to +178
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be only part of the configuration. It only reflects Redpanda values where user could define Connectors values in standard helm deployment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Consider this the first part. For now I want to unblock users so they can deploy connectors.


// Auth is a top-level field of the values file
type Auth struct {
SASL *SASL `json:"sasl"`
Expand Down
57 changes: 56 additions & 1 deletion src/go/k8s/api/redpanda/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/go/k8s/config/crd/bases/cluster.redpanda.com_redpandas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ spec:
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
connectors:
properties:
deployment:
properties:
enabled:
type: boolean
type: object
enabled:
type: boolean
test:
properties:
enabled:
type: boolean
type: object
type: object
console:
properties:
affinity:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func (r *RedpandaReconciler) helmReleaseRequiresUpdate(ctx context.Context, hr,
case !reflect.DeepEqual(hr.GetValues(), hrTemplate.GetValues()):
log.Info("values found different")
return true
case helmChartRequiresUpdate(&hr.Spec.Chart, &hrTemplate.Spec.Chart):
case helmChartRequiresUpdate(log, &hr.Spec.Chart, &hrTemplate.Spec.Chart):
log.Info("chartTemplate found different")
return true
case hr.Spec.Interval != hrTemplate.Spec.Interval:
Expand All @@ -510,13 +510,13 @@ func (r *RedpandaReconciler) helmReleaseRequiresUpdate(ctx context.Context, hr,
// helmChartRequiresUpdate compares the v2beta1.HelmChartTemplate of the
// v2beta1.HelmRelease to the given v1beta2.HelmChart to determine if an
// update is required.
func helmChartRequiresUpdate(template, chart *helmv2beta1.HelmChartTemplate) bool {
func helmChartRequiresUpdate(log logr.Logger, template, chart *helmv2beta1.HelmChartTemplate) bool {
switch {
case template.Spec.Chart != chart.Spec.Chart:
fmt.Println("chart is different")
log.Info("chart is different")
return true
case template.Spec.Version != "" && template.Spec.Version != chart.Spec.Version:
fmt.Println("spec version is different")
log.Info("spec version is different")
return true
default:
return false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
apiVersion: cluster.redpanda.com/v1alpha1
kind: Redpanda
metadata:
finalizers:
- operator.redpanda.com/finalizer
name: redpanda
spec:
chartRef:
chartVersion: "5.6.46"
clusterSpec:
statefulset:
replicas: 1
connectors:
enabled: true
status:
conditions:
- message: Redpanda reconciliation succeeded
reason: RedpandaClusterDeployed
status: "True"
type: Ready
helmRelease: redpanda
helmReleaseReady: true
helmRepository: redpanda-repository
helmRepositoryReady: true
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redpanda
spec:
replicas: 1
status:
availableReplicas: 1
currentReplicas: 1
readyReplicas: 1
replicas: 1
updatedReplicas: 1
---
apiVersion: apps/v1
kind: pod
metadata:
name: redpanda
labels:
app.kubernetes.io/component: connectors
app.kubernetes.io/instance: redpanda
status:
phase: Running
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- command: ../../../hack/get-redpanda-info.sh redpanda ../../_e2e_artifacts_v2
13 changes: 13 additions & 0 deletions src/go/k8s/tests/e2e-v2/connectors/00-create-redpanda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: cluster.redpanda.com/v1alpha1
kind: Redpanda
metadata:
name: redpanda
spec:
chartRef:
chartVersion: "5.6.46"
clusterSpec:
statefulset:
replicas: 1
connectors:
enabled: true
4 changes: 4 additions & 0 deletions src/go/k8s/tests/e2e-v2/connectors/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- command: ../../../hack/get-redpanda-info.sh redpanda ../../_e2e_artifacts_v2
18 changes: 18 additions & 0 deletions src/go/k8s/tests/e2e-v2/connectors/01-delete-redpandas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
- apiVersion: cluster.redpanda.com/v1alpha1
kind: Redpanda
- apiVersion: batch/v1
kind: Job
- apiVersion: v1
kind: PersistentVolumeClaim
- apiVersion: v1
kind: Pod
labels:
app.kubernetes.io/name: redpanda
- apiVersion: v1
kind: Service
labels:
app.kubernetes.io/name: redpanda
Loading