|
| 1 | +// Copyright 2024 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package v1beta1 |
| 16 | + |
| 17 | +import ( |
| 18 | + refs "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" |
| 19 | + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1" |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | +) |
| 22 | + |
| 23 | +var RedisClusterGVK = GroupVersion.WithKind("RedisCluster") |
| 24 | + |
| 25 | +// RedisClusterSpec defines the desired state of RedisCluster |
| 26 | +// +kcc:proto=google.cloud.redis.cluster.v1.Cluster |
| 27 | +type RedisClusterSpec struct { |
| 28 | + |
| 29 | + /* Immutable. The Project that this resource belongs to. */ |
| 30 | + ProjectRef refs.ProjectRef `json:"projectRef"` |
| 31 | + |
| 32 | + /* Immutable. Location of the resource. */ |
| 33 | + Location *string `json:"location"` |
| 34 | + |
| 35 | + // The RedisCluster name. If not given, the metadata.name will be used. |
| 36 | + // + optional |
| 37 | + ResourceID *string `json:"resourceID,omitempty"` |
| 38 | + |
| 39 | + // Optional. The authorization mode of the Redis cluster. |
| 40 | + // If not provided, auth feature is disabled for the cluster. |
| 41 | + AuthorizationMode *string `json:"authorizationMode,omitempty"` |
| 42 | + |
| 43 | + // Optional. The in-transit encryption for the Redis cluster. |
| 44 | + // If not provided, encryption is disabled for the cluster. |
| 45 | + TransitEncryptionMode *string `json:"transitEncryptionMode,omitempty"` |
| 46 | + |
| 47 | + // Required. Number of shards for the Redis cluster. |
| 48 | + ShardCount *int32 `json:"shardCount,omitempty"` |
| 49 | + |
| 50 | + // Required. Each PscConfig configures the consumer network where IPs will |
| 51 | + // be designated to the cluster for client access through Private Service |
| 52 | + // Connect Automation. Currently, only one PscConfig is supported. |
| 53 | + PscConfigs []PscConfigSpec `json:"pscConfigs,omitempty"` |
| 54 | + |
| 55 | + // Optional. The type of a redis node in the cluster. NodeType determines the |
| 56 | + // underlying machine-type of a redis node. |
| 57 | + NodeType *string `json:"nodeType,omitempty"` |
| 58 | + |
| 59 | + // Optional. Persistence config (RDB, AOF) for the cluster. |
| 60 | + PersistenceConfig *ClusterPersistenceConfig `json:"persistenceConfig,omitempty"` |
| 61 | + |
| 62 | + // Optional. Key/Value pairs of customer overrides for mutable Redis Configs |
| 63 | + RedisConfigs map[string]string `json:"redisConfigs,omitempty"` |
| 64 | + |
| 65 | + // Optional. The number of replica nodes per shard. |
| 66 | + ReplicaCount *int32 `json:"replicaCount,omitempty"` |
| 67 | + |
| 68 | + // Optional. This config will be used to determine how the customer wants us |
| 69 | + // to distribute cluster resources within the region. |
| 70 | + ZoneDistributionConfig *ZoneDistributionConfig `json:"zoneDistributionConfig,omitempty"` |
| 71 | + |
| 72 | + // Optional. The delete operation will fail when the value is set to true. |
| 73 | + DeletionProtectionEnabled *bool `json:"deletionProtectionEnabled,omitempty"` |
| 74 | +} |
| 75 | + |
| 76 | +type PscConfigSpec struct { |
| 77 | + // Required. The network where the IP address of the discovery endpoint will |
| 78 | + // be reserved, in the form of |
| 79 | + // projects/{network_project}/global/networks/{network_id}. |
| 80 | + // +required |
| 81 | + NetworkRef *refs.ComputeNetworkRef `json:"networkRef,omitempty"` |
| 82 | +} |
| 83 | + |
| 84 | +// RedisClusterStatus defines the config connector machine state of RedisCluster |
| 85 | +type RedisClusterStatus struct { |
| 86 | + /* Conditions represent the latest available observations of the |
| 87 | + object's current state. */ |
| 88 | + Conditions []v1alpha1.Condition `json:"conditions,omitempty"` |
| 89 | + |
| 90 | + // ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. |
| 91 | + // +optional |
| 92 | + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` |
| 93 | + |
| 94 | + // A unique specifier for the RedisCluster resource in GCP. |
| 95 | + // +optional |
| 96 | + ExternalRef *string `json:"externalRef,omitempty"` |
| 97 | + |
| 98 | + // ObservedState is the state of the resource as most recently observed in GCP. |
| 99 | + // +optional |
| 100 | + ObservedState *RedisClusterObservedState `json:"observedState,omitempty"` |
| 101 | +} |
| 102 | + |
| 103 | +// RedisClusterSpec defines the desired state of RedisCluster |
| 104 | +// +kcc:proto=google.cloud.redis.cluster.v1.Cluster |
| 105 | +type RedisClusterObservedState struct { |
| 106 | + |
| 107 | + // Output only. The timestamp associated with the cluster creation request. |
| 108 | + CreateTime *string `json:"createTime,omitempty"` |
| 109 | + |
| 110 | + // Output only. The current state of this cluster. |
| 111 | + // Can be CREATING, READY, UPDATING, DELETING and SUSPENDED |
| 112 | + State *string `json:"state,omitempty"` |
| 113 | + |
| 114 | + // Output only. System assigned, unique identifier for the cluster. |
| 115 | + Uid *string `json:"uid,omitempty"` |
| 116 | + |
| 117 | + // Output only. Redis memory size in GB for the entire cluster rounded up to |
| 118 | + // the next integer. |
| 119 | + SizeGb *int32 `json:"sizeGb,omitempty"` |
| 120 | + |
| 121 | + // Output only. Endpoints created on each given network, for Redis clients to |
| 122 | + // connect to the cluster. Currently only one discovery endpoint is supported. |
| 123 | + DiscoveryEndpoints []DiscoveryEndpoint `json:"discoveryEndpoints,omitempty"` |
| 124 | + |
| 125 | + // Output only. PSC connections for discovery of the cluster topology and |
| 126 | + // accessing the cluster. |
| 127 | + PscConnections []PscConnection `json:"pscConnections,omitempty"` |
| 128 | + |
| 129 | + // Output only. Additional information about the current state of the cluster. |
| 130 | + StateInfo *Cluster_StateInfo `json:"stateInfo,omitempty"` |
| 131 | + |
| 132 | + // Output only. Precise value of redis memory size in GB for the entire |
| 133 | + // cluster. |
| 134 | + PreciseSizeGb *float64 `json:"preciseSizeGb,omitempty"` |
| 135 | +} |
| 136 | + |
| 137 | +// +genclient |
| 138 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 139 | +// +kubebuilder:resource:categories=gcp |
| 140 | +// +kubebuilder:subresource:status |
| 141 | +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/system=true";"cnrm.cloud.google.com/stability-level=beta" |
| 142 | +// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date" |
| 143 | +// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded" |
| 144 | +// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'" |
| 145 | +// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'" |
| 146 | + |
| 147 | +// RedisCluster is the Schema for the RedisCluster API |
| 148 | +// +k8s:openapi-gen=true |
| 149 | +// +kubebuilder:storageversion |
| 150 | +type RedisCluster struct { |
| 151 | + metav1.TypeMeta `json:",inline"` |
| 152 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 153 | + |
| 154 | + Spec RedisClusterSpec `json:"spec,omitempty"` |
| 155 | + Status RedisClusterStatus `json:"status,omitempty"` |
| 156 | +} |
| 157 | + |
| 158 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 159 | +// RedisClusterList contains a list of RedisCluster |
| 160 | +type RedisClusterList struct { |
| 161 | + metav1.TypeMeta `json:",inline"` |
| 162 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 163 | + Items []RedisCluster `json:"items"` |
| 164 | +} |
| 165 | + |
| 166 | +func init() { |
| 167 | + SchemeBuilder.Register(&RedisCluster{}, &RedisClusterList{}) |
| 168 | +} |
0 commit comments