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

Namespace access #201

Merged
merged 18 commits into from
Aug 18, 2021
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
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ manager: generate fmt vet
go build -o bin/manager main.go

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
go run ./main.go
#
# Since this runs outside a cluster and there's a requirement on cluster-level service
# communincation, the connection between them needs to be accounted for.
# https://github.com/telepresenceio/telepresence is one way to do this (just run
# `telepresence connect` and services like `test-service.test-namespace.svc.cluster.local`
# will resolve properly).
run: generate fmt vet manifests just-run

just-run: ## Just runs 'go run main.go' without regenerating any manifests or deploying RBACs
KUBE_CONFIG=${HOME}/.kube/config OPERATOR_NAMESPACE=rabbitmq-system ENABLE_WEBHOOKS=false go run ./main.go

# Install CRDs into a cluster
install: manifests
Expand Down
6 changes: 5 additions & 1 deletion api/v1beta1/queue_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ type QueueSpec struct {
}

type RabbitmqClusterReference struct {
// Cannot be updated
// The name of the RabbitMQ cluster to reference.
// +kubebuilder:validation:Required
Name string `json:"name"`
// The namespace of the RabbitMQ cluster to reference.
// Defaults to the namespace of the requested resource if omitted.
// +kubebuilder:validation:Optional
Namespace string `json:"namespace"`
}

// QueueStatus defines the observed state of Queue
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_bindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ spec:
be created in. Required property.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_exchanges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ spec:
be created in. Required property.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_federations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ spec:
upstream will be created in. Required property.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_permissions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ spec:
user and vhost are. Required property.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ spec:
be created in. Required property.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_queues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ spec:
be created in. Required property.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_schemareplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ spec:
would be set for. Must be an existing cluster.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_shovels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ spec:
be created in. Required property.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ spec:
created for. This cluster must exist for the User object to be created.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/rabbitmq.com_vhosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ spec:
be created in. Required property.
properties:
name:
description: Cannot be updated
description: The name of the RabbitMQ cluster to reference.
type: string
namespace:
description: The namespace of the RabbitMQ cluster to reference.
Defaults to the namespace of the requested resource if omitted.
type: string
required:
- name
Expand Down
5 changes: 5 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ spec:
requests:
cpu: 100m
memory: 100Mi
env:
- name: OPERATOR_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
terminationGracePeriodSeconds: 10
10 changes: 10 additions & 0 deletions controllers/binding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ func (r *BindingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
logger.Info("Could not generate rabbitClient for non existent cluster: " + err.Error())
return reconcile.Result{RequeueAfter: 10 * time.Second}, err
}
if errors.Is(err, internal.ResourceNotAllowedError) {
logger.Info("Could not create binding resource: " + err.Error())
binding.Status.Conditions = []topology.Condition{topology.NotReady(internal.ResourceNotAllowedError.Error())}
if writerErr := clientretry.RetryOnConflict(clientretry.DefaultRetry, func() error {
return r.Status().Update(ctx, binding)
}); writerErr != nil {
logger.Error(writerErr, failedStatusUpdate)
}
return reconcile.Result{}, nil
}
if err != nil {
logger.Error(err, failedParseClusterRef)
return reconcile.Result{}, err
Expand Down
Loading