|
| 1 | +/* |
| 2 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +you may not use this file except in compliance with the License. |
| 4 | +You may obtain a copy of the License at |
| 5 | +
|
| 6 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +
|
| 8 | +Unless required by applicable law or agreed to in writing, software |
| 9 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +See the License for the specific language governing permissions and |
| 12 | +limitations under the License. |
| 13 | +*/ |
| 14 | + |
| 15 | +package v1beta1 |
| 16 | + |
| 17 | +// DEPRECATED TYPES |
| 18 | +// These types are local mirrors of the old rabbitmq-cluster-operator types, |
| 19 | +// kept only for backward compatibility with existing CRs during migration. |
| 20 | +// They will be removed in a future release once all CRs have been migrated |
| 21 | +// to use the new explicit fields in RabbitMqSpecCore. |
| 22 | + |
| 23 | +import ( |
| 24 | + appsv1 "k8s.io/api/apps/v1" |
| 25 | + corev1 "k8s.io/api/core/v1" |
| 26 | + "k8s.io/apimachinery/pkg/api/resource" |
| 27 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 28 | +) |
| 29 | + |
| 30 | +// DeprecatedEmbeddedLabelsAnnotations is an embedded subset of the fields included in |
| 31 | +// k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta. Only labels and annotations are included. |
| 32 | +type DeprecatedEmbeddedLabelsAnnotations struct { |
| 33 | + // Map of string keys and values that can be used to organize and categorize (scope and select) objects. |
| 34 | + // +optional |
| 35 | + Labels map[string]string `json:"labels,omitempty"` |
| 36 | + // Annotations is an unstructured key value map stored with a resource. |
| 37 | + // +optional |
| 38 | + Annotations map[string]string `json:"annotations,omitempty"` |
| 39 | +} |
| 40 | + |
| 41 | +// DeprecatedStatefulSetOverride mirrors the old rabbitmq-cluster-operator StatefulSet type. |
| 42 | +// Used for webhook validation of the override.statefulSet JSON field. |
| 43 | +type DeprecatedStatefulSetOverride struct { |
| 44 | + // +optional |
| 45 | + *DeprecatedEmbeddedLabelsAnnotations `json:"metadata,omitempty"` |
| 46 | + // +optional |
| 47 | + Spec *DeprecatedStatefulSetSpec `json:"spec,omitempty"` |
| 48 | +} |
| 49 | + |
| 50 | +// DeprecatedStatefulSetSpec mirrors a subset of the old rabbitmq-cluster-operator StatefulSetSpec type. |
| 51 | +type DeprecatedStatefulSetSpec struct { |
| 52 | + // +optional |
| 53 | + Replicas *int32 `json:"replicas,omitempty"` |
| 54 | + // +optional |
| 55 | + Selector *metav1.LabelSelector `json:"selector,omitempty"` |
| 56 | + // +optional |
| 57 | + Template *DeprecatedPodTemplateSpec `json:"template,omitempty"` |
| 58 | + // +optional |
| 59 | + VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` |
| 60 | + // +optional |
| 61 | + ServiceName string `json:"serviceName,omitempty"` |
| 62 | + // +optional |
| 63 | + PodManagementPolicy appsv1.PodManagementPolicyType `json:"podManagementPolicy,omitempty"` |
| 64 | + // +optional |
| 65 | + UpdateStrategy *appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"` |
| 66 | + // +optional |
| 67 | + MinReadySeconds int32 `json:"minReadySeconds,omitempty"` |
| 68 | + // +optional |
| 69 | + PersistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty"` |
| 70 | +} |
| 71 | + |
| 72 | +// DeprecatedPodTemplateSpec mirrors the old rabbitmq-cluster-operator PodTemplateSpec type. |
| 73 | +type DeprecatedPodTemplateSpec struct { |
| 74 | + // +optional |
| 75 | + *DeprecatedEmbeddedObjectMeta `json:"metadata,omitempty"` |
| 76 | + // +optional |
| 77 | + Spec *corev1.PodSpec `json:"spec,omitempty"` |
| 78 | +} |
| 79 | + |
| 80 | +// DeprecatedEmbeddedObjectMeta mirrors the old rabbitmq-cluster-operator EmbeddedObjectMeta type. |
| 81 | +type DeprecatedEmbeddedObjectMeta struct { |
| 82 | + // +optional |
| 83 | + Name string `json:"name,omitempty"` |
| 84 | + // +optional |
| 85 | + Namespace string `json:"namespace,omitempty"` |
| 86 | + // +optional |
| 87 | + Labels map[string]string `json:"labels,omitempty"` |
| 88 | + // +optional |
| 89 | + Annotations map[string]string `json:"annotations,omitempty"` |
| 90 | +} |
| 91 | + |
| 92 | +// DeprecatedPersistenceSpec mirrors the old rabbitmq-cluster-operator RabbitmqClusterPersistenceSpec type. |
| 93 | +type DeprecatedPersistenceSpec struct { |
| 94 | + // The name of the StorageClass to claim a PersistentVolume from. |
| 95 | + StorageClassName *string `json:"storageClassName,omitempty"` |
| 96 | + // The requested size of the persistent volume attached to each Pod in the RabbitmqCluster. |
| 97 | + // The format of this field matches that defined by kubernetes/apimachinery. |
| 98 | + // See https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity for more info on the format of this field. |
| 99 | + // +kubebuilder:default:="10Gi" |
| 100 | + Storage *resource.Quantity `json:"storage,omitempty"` |
| 101 | +} |
| 102 | + |
| 103 | +// DeprecatedRabbitmqConfigSpec mirrors the old rabbitmq-cluster-operator RabbitmqClusterConfigurationSpec type. |
| 104 | +type DeprecatedRabbitmqConfigSpec struct { |
| 105 | + // List of plugins to enable in addition to essential plugins: rabbitmq_management, |
| 106 | + // rabbitmq_prometheus, and rabbitmq_peer_discovery_k8s. |
| 107 | + // +optional |
| 108 | + // +kubebuilder:validation:MaxItems=100 |
| 109 | + AdditionalPlugins []string `json:"additionalPlugins,omitempty"` |
| 110 | + // Modify to add to the rabbitmq.conf file in addition to default configurations set by the operator. |
| 111 | + // Modifying this property on an existing RabbitmqCluster will trigger a StatefulSet rolling restart |
| 112 | + // and will cause rabbitmq downtime. |
| 113 | + // For more information on this config, see https://www.rabbitmq.com/configure.html#config-file |
| 114 | + // +optional |
| 115 | + // +kubebuilder:validation:MaxLength=100000 |
| 116 | + AdditionalConfig string `json:"additionalConfig,omitempty"` |
| 117 | + // Specify any rabbitmq advanced.config configurations to apply to the cluster. |
| 118 | + // For more information on advanced config, see https://www.rabbitmq.com/configure.html#advanced-config-file |
| 119 | + // +optional |
| 120 | + // +kubebuilder:validation:MaxLength=100000 |
| 121 | + AdvancedConfig string `json:"advancedConfig,omitempty"` |
| 122 | + // Modify to add to the rabbitmq-env.conf file. Modifying this property on an existing |
| 123 | + // RabbitmqCluster will trigger a StatefulSet rolling restart and will cause rabbitmq downtime. |
| 124 | + // For more information on env config, see https://www.rabbitmq.com/man/rabbitmq-env.conf.5.html |
| 125 | + // +optional |
| 126 | + // +kubebuilder:validation:MaxLength=100000 |
| 127 | + EnvConfig string `json:"envConfig,omitempty"` |
| 128 | + // Erlang Inet configuration to apply to the Erlang VM running rabbit. |
| 129 | + // See also: https://www.erlang.org/doc/apps/erts/inet_cfg.html |
| 130 | + // +optional |
| 131 | + // +kubebuilder:validation:MaxLength=2000 |
| 132 | + ErlangInetConfig string `json:"erlangInetConfig,omitempty"` |
| 133 | +} |
| 134 | + |
| 135 | +// DeprecatedSecretBackendSpec mirrors the old rabbitmq-cluster-operator SecretBackend type. |
| 136 | +type DeprecatedSecretBackendSpec struct { |
| 137 | + // +optional |
| 138 | + ExternalSecret *corev1.LocalObjectReference `json:"externalSecret,omitempty"` |
| 139 | + // +optional |
| 140 | + Vault *DeprecatedVaultSpec `json:"vault,omitempty"` |
| 141 | +} |
| 142 | + |
| 143 | +// DeprecatedVaultSpec mirrors the old rabbitmq-cluster-operator VaultSpec type. |
| 144 | +// VaultSpec will add Vault annotations (see https://www.vaultproject.io/docs/platform/k8s/injector/annotations) |
| 145 | +// to RabbitMQ Pods. It requires a Vault Agent Sidecar Injector |
| 146 | +// (https://www.vaultproject.io/docs/platform/k8s/injector) to be installed in the K8s cluster. |
| 147 | +type DeprecatedVaultSpec struct { |
| 148 | + // Role in Vault. |
| 149 | + // If vault.defaultUserPath is set, this role must have capability to read the pre-created default user |
| 150 | + // credential in Vault. |
| 151 | + // If vault.tls is set, this role must have capability to create and update certificates in the Vault PKI |
| 152 | + // engine for the domains "<namespace>" and "<namespace>.svc". |
| 153 | + // +optional |
| 154 | + Role string `json:"role,omitempty"` |
| 155 | + // Vault annotations that override the Vault annotations set by the cluster-operator. |
| 156 | + // For a list of valid Vault annotations, see |
| 157 | + // https://www.vaultproject.io/docs/platform/k8s/injector/annotations |
| 158 | + // +optional |
| 159 | + Annotations map[string]string `json:"annotations,omitempty"` |
| 160 | + // Path in Vault to access a KV (Key-Value) secret with the fields username and password |
| 161 | + // for the default user. For example "secret/data/rabbitmq/config". |
| 162 | + // +optional |
| 163 | + DefaultUserPath string `json:"defaultUserPath,omitempty"` |
| 164 | + // Sidecar container that updates the default user's password in RabbitMQ when it changes in Vault. |
| 165 | + // Additionally, it updates /var/lib/rabbitmq/.rabbitmqadmin.conf (used by rabbitmqadmin CLI). |
| 166 | + // Set to empty string to disable the sidecar container. |
| 167 | + // +optional |
| 168 | + DefaultUserUpdaterImage string `json:"defaultUserUpdaterImage,omitempty"` |
| 169 | + // +optional |
| 170 | + TLS *DeprecatedVaultTLSSpec `json:"tls,omitempty"` |
| 171 | +} |
| 172 | + |
| 173 | +// DeprecatedVaultTLSSpec mirrors the old rabbitmq-cluster-operator VaultSpec TLS fields. |
| 174 | +type DeprecatedVaultTLSSpec struct { |
| 175 | + // Path in Vault PKI engine. For example "pki/issue/hashicorp-com". Required. |
| 176 | + // +optional |
| 177 | + PkiIssuerPath string `json:"pkiIssuerPath,omitempty"` |
| 178 | + // Specifies an optional path to retrieve the root CA from vault. |
| 179 | + // Useful if certificates are issued by an intermediate CA. |
| 180 | + // +optional |
| 181 | + PkiRootPath string `json:"pkiRootPath,omitempty"` |
| 182 | + // Specifies the requested Subject Alternative Names (SANs), in a comma-delimited list. |
| 183 | + // These will be appended to the SANs added by the cluster-operator. |
| 184 | + // +optional |
| 185 | + AltNames string `json:"altNames,omitempty"` |
| 186 | + // Specifies the requested certificate Common Name (CN). |
| 187 | + // Defaults to <serviceName>.<namespace>.svc if not provided. |
| 188 | + // +optional |
| 189 | + CommonName string `json:"commonName,omitempty"` |
| 190 | + // Specifies the requested IP Subject Alternative Names, in a comma-delimited list. |
| 191 | + // +optional |
| 192 | + IpSans string `json:"ipSans,omitempty"` |
| 193 | +} |
0 commit comments