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: Update #5028

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 14 additions & 1 deletion src/go/k8s/pkg/resources/cluster_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package resources

import (
"context"
"fmt"

"github.com/go-logr/logr"
redpandav1alpha1 "github.com/redpanda-data/redpanda/src/go/k8s/apis/redpanda/v1alpha1"
Expand Down Expand Up @@ -53,7 +54,19 @@ func (r *ClusterRoleResource) Ensure(ctx context.Context) error {
if r.pandaCluster.ExternalListener() == nil {
return nil
}
_, err := CreateIfNotExists(ctx, r, r.obj(), r.logger)

obj := r.obj()
created, err := CreateIfNotExists(ctx, r, obj, r.logger)
if err != nil || created {
return err
}
var cr v1.ClusterRole
err = r.Get(ctx, r.Key(), &cr)
if err != nil {
return fmt.Errorf("error while fetching ClusterRole resource: %w", err)
}

_, err = Update(ctx, &cr, obj, r.Client, r.logger)
return err
}

Expand Down
8 changes: 4 additions & 4 deletions src/go/k8s/pkg/resources/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func (r *StatefulSetResource) obj(
})
}

setCloudStorage(ss, r.pandaCluster)
setVolumes(ss, r.pandaCluster)

rpkStatusContainer := r.rpkStatusContainer(tlsVolumeMounts)
if rpkStatusContainer != nil {
Expand Down Expand Up @@ -586,9 +586,9 @@ func (r *StatefulSetResource) composeCURLMaintenanceCommand(
return cmd
}

// setCloudStorage manipulates v1.StatefulSet object in order to add cloud storage specific
// properties to Redpanda pod.
func setCloudStorage(
// setVolumes manipulates v1.StatefulSet object in order to add cloud storage and
// Redpanda data volume
func setVolumes(
ss *appsv1.StatefulSet, cluster *redpandav1alpha1.Cluster,
) {
pvcDataDir := preparePVCResource(datadirName, cluster.Namespace, cluster.Spec.Storage, ss.Labels)
Expand Down