Skip to content

Commit

Permalink
Merge pull request #245 from beagles/redis
Browse files Browse the repository at this point in the history
Re-introduce redis
  • Loading branch information
openshift-merge-bot[bot] authored Nov 27, 2024
2 parents c06a12f + c373c65 commit e53cc6f
Show file tree
Hide file tree
Showing 46 changed files with 747 additions and 426 deletions.
5 changes: 5 additions & 0 deletions api/bases/designate.openstack.org_designatecentrals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ spec:
from the Secret
type: string
type: object
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
replicas:
default: 1
description: Replicas - Designate Central Replicas
Expand Down
5 changes: 5 additions & 0 deletions api/bases/designate.openstack.org_designateproducers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ spec:
from the Secret
type: string
type: object
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
replicas:
default: 1
description: Replicas - Designate Producer Replicas
Expand Down
21 changes: 21 additions & 0 deletions api/bases/designate.openstack.org_designates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,11 @@ spec:
password from the Secret
type: string
type: object
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
replicas:
default: 1
description: Replicas - Designate Central Replicas
Expand Down Expand Up @@ -1043,6 +1048,11 @@ spec:
password from the Secret
type: string
type: object
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
replicas:
default: 1
description: Replicas - Designate Producer Replicas
Expand Down Expand Up @@ -1430,6 +1440,11 @@ spec:
description: RabbitMQ instance name Needed to request a transportURL
that is created and used in Designate
type: string
redisServiceName:
default: designate-redis
description: RedisServiceName is the name of the Redis instance to
be used (must be in the same namespace as designate)
type: string
resources:
description: Resources - Compute Resources required by this service
(Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
Expand Down Expand Up @@ -1497,6 +1512,7 @@ spec:
- designateProducer
- designateWorker
- rabbitMqClusterName
- redisServiceName
- secret
type: object
status:
Expand Down Expand Up @@ -1594,6 +1610,11 @@ spec:
ContainerImage)
format: int64
type: integer
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
transportURLSecret:
description: TransportURLSecret - Secret containing RabbitMQ transportURL
type: string
Expand Down
8 changes: 8 additions & 0 deletions api/v1beta1/designate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ type DesignateSpecBase struct {
// +kubebuilder:default=designate
// DesignateNetworkAttachment is a NetworkAttachment resource name for the Designate Control Network
DesignateNetworkAttachment string `json:"designateNetworkAttachment"`

// +kubebuilder:validation:Required
// +kubebuilder:default="designate-redis"
// RedisServiceName is the name of the Redis instance to be used (must be in the same namespace as designate)
RedisServiceName string `json:"redisServiceName"`
}

// DesignateStatus defines the observed state of Designate
Expand Down Expand Up @@ -227,6 +232,9 @@ type DesignateStatus struct {
// then the controller has not processed the latest changes injected by
// the opentack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// List of Redis Host IP addresses
RedisHostIPs []string `json:"redisHostIPs,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta1/designatecentral_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type DesignateCentralSpecBase struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.Ca `json:"tls,omitempty"`

// List of Redis Host IP addresses
RedisHostIPs []string `json:"redisHostIPs,omitempty"`
}

// DesignateCentralStatus defines the observed state of DesignateCentral
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta1/designateproducer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type DesignateProducerSpecBase struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.Ca `json:"tls,omitempty"`

// List of Redis Host IP addresses
RedisHostIPs []string `json:"redisHostIPs,omitempty"`
}

// DesignateProducerStatus defines the observed state of DesignateProducer
Expand Down
15 changes: 15 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ spec:
from the Secret
type: string
type: object
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
replicas:
default: 1
description: Replicas - Designate Central Replicas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ spec:
from the Secret
type: string
type: object
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
replicas:
default: 1
description: Replicas - Designate Producer Replicas
Expand Down
21 changes: 21 additions & 0 deletions config/crd/bases/designate.openstack.org_designates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,11 @@ spec:
password from the Secret
type: string
type: object
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
replicas:
default: 1
description: Replicas - Designate Central Replicas
Expand Down Expand Up @@ -1043,6 +1048,11 @@ spec:
password from the Secret
type: string
type: object
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
replicas:
default: 1
description: Replicas - Designate Producer Replicas
Expand Down Expand Up @@ -1430,6 +1440,11 @@ spec:
description: RabbitMQ instance name Needed to request a transportURL
that is created and used in Designate
type: string
redisServiceName:
default: designate-redis
description: RedisServiceName is the name of the Redis instance to
be used (must be in the same namespace as designate)
type: string
resources:
description: Resources - Compute Resources required by this service
(Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
Expand Down Expand Up @@ -1497,6 +1512,7 @@ spec:
- designateProducer
- designateWorker
- rabbitMqClusterName
- redisServiceName
- secret
type: object
status:
Expand Down Expand Up @@ -1594,6 +1610,11 @@ spec:
ContainerImage)
format: int64
type: integer
redisHostIPs:
description: List of Redis Host IP addresses
items:
type: string
type: array
transportURLSecret:
description: TransportURLSecret - Secret containing RabbitMQ transportURL
type: string
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- redis.openstack.org
resources:
- redises
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- route.openshift.io
resources:
Expand Down
6 changes: 6 additions & 0 deletions config/samples/designate_redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: redis.openstack.org/v1beta1
kind: Redis
metadata:
name: designate-redis
spec:
replicas: 1
9 changes: 9 additions & 0 deletions config/samples/designate_redis_tls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: redis.openstack.org/v1beta1
kind: Redis
metadata:
name: designate-redis
spec:
replicas: 1
tls:
secretName: cert-designate-redis-svc
caBundleSecretName: combined-ca-bundle
1 change: 1 addition & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Append samples you want in your CSV to this file as resources ##
resources:
- designate_v1beta1_designate.yaml
- designate_redis.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
31 changes: 30 additions & 1 deletion controllers/designate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"
"sort"
"time"

k8s_errors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -37,6 +38,7 @@ import (
designatev1beta1 "github.com/openstack-k8s-operators/designate-operator/api/v1beta1"
"github.com/openstack-k8s-operators/designate-operator/pkg/designate"
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
redisv1 "github.com/openstack-k8s-operators/infra-operator/apis/redis/v1beta1"
"github.com/openstack-k8s-operators/lib-common/modules/common"
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/env"
Expand Down Expand Up @@ -115,6 +117,7 @@ type DesignateReconciler struct {
// +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbaccounts/finalizers,verbs=update;patch
// +kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneapis,verbs=get;list;watch
// +kubebuilder:rbac:groups=rabbitmq.openstack.org,resources=transporturls,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=redis.openstack.org,resources=redises,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch
// +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;create;update;patch;delete;watch
Expand Down Expand Up @@ -296,6 +299,7 @@ func (r *DesignateReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
Owns(&designatev1beta1.DesignateBackendbind9{}).
Owns(&designatev1beta1.DesignateUnbound{}).
Owns(&rabbitmqv1.TransportURL{}).
Owns(&redisv1.Redis{}).
Owns(&batchv1.Job{}).
Owns(&corev1.ConfigMap{}).
Owns(&corev1.ServiceAccount{}).
Expand Down Expand Up @@ -588,9 +592,18 @@ func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *des
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
}

instance.Status.Conditions.MarkTrue(designatev1beta1.DesignateRabbitMqTransportURLReadyCondition, designatev1beta1.DesignateRabbitMqTransportURLReadyMessage)
instance.Status.Conditions.MarkTrue(
designatev1beta1.DesignateRabbitMqTransportURLReadyCondition,
designatev1beta1.DesignateRabbitMqTransportURLReadyMessage)

// end transportURL
hostIPs, err := getRedisServiceIPs(ctx, instance, helper)
if err != nil {
return ctrl.Result{}, err
}

sort.Strings(hostIPs)
instance.Status.RedisHostIPs = hostIPs

instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)

Expand Down Expand Up @@ -1521,6 +1534,7 @@ func (r *DesignateReconciler) centralDeploymentCreateOrUpdate(ctx context.Contex
deployment.Spec.Secret = instance.Spec.Secret
deployment.Spec.TransportURLSecret = instance.Status.TransportURLSecret
deployment.Spec.ServiceAccount = instance.RbacResourceName()
deployment.Spec.RedisHostIPs = instance.Status.RedisHostIPs
deployment.Spec.TLS = instance.Spec.DesignateAPI.TLS.Ca
deployment.Spec.NodeSelector = instance.Spec.DesignateCentral.NodeSelector

Expand Down Expand Up @@ -1629,6 +1643,7 @@ func (r *DesignateReconciler) producerDeploymentCreateOrUpdate(ctx context.Conte
deployment.Spec.Secret = instance.Spec.Secret
deployment.Spec.TransportURLSecret = instance.Status.TransportURLSecret
deployment.Spec.ServiceAccount = instance.RbacResourceName()
deployment.Spec.RedisHostIPs = instance.Status.RedisHostIPs
deployment.Spec.TLS = instance.Spec.DesignateAPI.TLS.Ca
deployment.Spec.NodeSelector = instance.Spec.DesignateProducer.NodeSelector

Expand Down Expand Up @@ -1855,3 +1870,17 @@ func (r *DesignateReconciler) checkDesignateUnboundGeneration(
}
return true, nil
}

func getRedisServiceIPs(
ctx context.Context,
instance *designatev1beta1.Designate,
helper *helper.Helper,
) ([]string, error) {
getOptions := metav1.GetOptions{}
service, err := helper.GetKClient().CoreV1().Services(instance.Namespace).Get(ctx, instance.Spec.RedisServiceName, getOptions)
if err != nil {
return []string{}, err
}
// TODO: Ensure that the correct port is exposed
return service.Spec.ClusterIPs, nil
}
Loading

0 comments on commit e53cc6f

Please sign in to comment.