github.com/spotahome/redis-operator@v1.2.4/api/redisfailover/v1/types.go (about) 1 package v1 2 3 import ( 4 corev1 "k8s.io/api/core/v1" 5 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 6 ) 7 8 // +genclient 9 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 10 11 // RedisFailover represents a Redis failover 12 // +kubebuilder:printcolumn:name="NAME",type="string",JSONPath=".metadata.name" 13 // +kubebuilder:printcolumn:name="REDIS",type="integer",JSONPath=".spec.redis.replicas" 14 // +kubebuilder:printcolumn:name="SENTINELS",type="integer",JSONPath=".spec.sentinel.replicas" 15 // +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" 16 // +kubebuilder:resource:singular=redisfailover,path=redisfailovers,shortName=rf,scope=Namespaced 17 type RedisFailover struct { 18 metav1.TypeMeta `json:",inline"` 19 metav1.ObjectMeta `json:"metadata,omitempty"` 20 Spec RedisFailoverSpec `json:"spec"` 21 } 22 23 // RedisFailoverSpec represents a Redis failover spec 24 type RedisFailoverSpec struct { 25 Redis RedisSettings `json:"redis,omitempty"` 26 Sentinel SentinelSettings `json:"sentinel,omitempty"` 27 Auth AuthSettings `json:"auth,omitempty"` 28 LabelWhitelist []string `json:"labelWhitelist,omitempty"` 29 BootstrapNode *BootstrapSettings `json:"bootstrapNode,omitempty"` 30 } 31 32 // RedisCommandRename defines the specification of a "rename-command" configuration option 33 type RedisCommandRename struct { 34 From string `json:"from,omitempty"` 35 To string `json:"to,omitempty"` 36 } 37 38 // RedisSettings defines the specification of the redis cluster 39 type RedisSettings struct { 40 Image string `json:"image,omitempty"` 41 ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` 42 Replicas int32 `json:"replicas,omitempty"` 43 Port int32 `json:"port,omitempty"` 44 Resources corev1.ResourceRequirements `json:"resources,omitempty"` 45 CustomConfig []string `json:"customConfig,omitempty"` 46 CustomCommandRenames []RedisCommandRename `json:"customCommandRenames,omitempty"` 47 Command []string `json:"command,omitempty"` 48 ShutdownConfigMap string `json:"shutdownConfigMap,omitempty"` 49 StartupConfigMap string `json:"startupConfigMap,omitempty"` 50 Storage RedisStorage `json:"storage,omitempty"` 51 InitContainers []corev1.Container `json:"initContainers,omitempty"` 52 Exporter Exporter `json:"exporter,omitempty"` 53 ExtraContainers []corev1.Container `json:"extraContainers,omitempty"` 54 Affinity *corev1.Affinity `json:"affinity,omitempty"` 55 SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"` 56 ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"` 57 ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` 58 Tolerations []corev1.Toleration `json:"tolerations,omitempty"` 59 TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` 60 NodeSelector map[string]string `json:"nodeSelector,omitempty"` 61 PodAnnotations map[string]string `json:"podAnnotations,omitempty"` 62 ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"` 63 HostNetwork bool `json:"hostNetwork,omitempty"` 64 DNSPolicy corev1.DNSPolicy `json:"dnsPolicy,omitempty"` 65 PriorityClassName string `json:"priorityClassName,omitempty"` 66 ServiceAccountName string `json:"serviceAccountName,omitempty"` 67 TerminationGracePeriodSeconds int64 `json:"terminationGracePeriod,omitempty"` 68 ExtraVolumes []corev1.Volume `json:"extraVolumes,omitempty"` 69 ExtraVolumeMounts []corev1.VolumeMount `json:"extraVolumeMounts,omitempty"` 70 } 71 72 // SentinelSettings defines the specification of the sentinel cluster 73 type SentinelSettings struct { 74 Image string `json:"image,omitempty"` 75 ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` 76 Replicas int32 `json:"replicas,omitempty"` 77 Resources corev1.ResourceRequirements `json:"resources,omitempty"` 78 CustomConfig []string `json:"customConfig,omitempty"` 79 Command []string `json:"command,omitempty"` 80 StartupConfigMap string `json:"startupConfigMap,omitempty"` 81 Affinity *corev1.Affinity `json:"affinity,omitempty"` 82 SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"` 83 ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"` 84 ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` 85 Tolerations []corev1.Toleration `json:"tolerations,omitempty"` 86 TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` 87 NodeSelector map[string]string `json:"nodeSelector,omitempty"` 88 PodAnnotations map[string]string `json:"podAnnotations,omitempty"` 89 ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"` 90 InitContainers []corev1.Container `json:"initContainers,omitempty"` 91 Exporter Exporter `json:"exporter,omitempty"` 92 ExtraContainers []corev1.Container `json:"extraContainers,omitempty"` 93 ConfigCopy SentinelConfigCopy `json:"configCopy,omitempty"` 94 HostNetwork bool `json:"hostNetwork,omitempty"` 95 DNSPolicy corev1.DNSPolicy `json:"dnsPolicy,omitempty"` 96 PriorityClassName string `json:"priorityClassName,omitempty"` 97 ServiceAccountName string `json:"serviceAccountName,omitempty"` 98 ExtraVolumes []corev1.Volume `json:"extraVolumes,omitempty"` 99 ExtraVolumeMounts []corev1.VolumeMount `json:"extraVolumeMounts,omitempty"` 100 } 101 102 // AuthSettings contains settings about auth 103 type AuthSettings struct { 104 SecretPath string `json:"secretPath,omitempty"` 105 } 106 107 // BootstrapSettings contains settings about a potential bootstrap node 108 type BootstrapSettings struct { 109 Host string `json:"host,omitempty"` 110 Port string `json:"port,omitempty"` 111 AllowSentinels bool `json:"allowSentinels,omitempty"` 112 } 113 114 // Exporter defines the specification for the redis/sentinel exporter 115 type Exporter struct { 116 Enabled bool `json:"enabled,omitempty"` 117 Image string `json:"image,omitempty"` 118 ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` 119 ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"` 120 Args []string `json:"args,omitempty"` 121 Env []corev1.EnvVar `json:"env,omitempty"` 122 Resources *corev1.ResourceRequirements `json:"resources,omitempty"` 123 } 124 125 // SentinelConfigCopy defines the specification for the sentinel exporter 126 type SentinelConfigCopy struct { 127 ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"` 128 } 129 130 // RedisStorage defines the structure used to store the Redis Data 131 type RedisStorage struct { 132 KeepAfterDeletion bool `json:"keepAfterDeletion,omitempty"` 133 EmptyDir *corev1.EmptyDirVolumeSource `json:"emptyDir,omitempty"` 134 PersistentVolumeClaim *EmbeddedPersistentVolumeClaim `json:"persistentVolumeClaim,omitempty"` 135 } 136 137 // EmbeddedPersistentVolumeClaim is an embedded version of k8s.io/api/core/v1.PersistentVolumeClaim. 138 // It contains TypeMeta and a reduced ObjectMeta. 139 type EmbeddedPersistentVolumeClaim struct { 140 metav1.TypeMeta `json:",inline"` 141 142 // EmbeddedMetadata contains metadata relevant to an EmbeddedResource. 143 EmbeddedObjectMetadata `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 144 145 // Spec defines the desired characteristics of a volume requested by a pod author. 146 // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims 147 // +optional 148 Spec corev1.PersistentVolumeClaimSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 149 150 // Status represents the current information/status of a persistent volume claim. 151 // Read-only. 152 // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims 153 // +optional 154 Status corev1.PersistentVolumeClaimStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 155 } 156 157 // EmbeddedObjectMetadata contains a subset of the fields included in k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta 158 // Only fields which are relevant to embedded resources are included. 159 type EmbeddedObjectMetadata struct { 160 // Name must be unique within a namespace. Is required when creating resources, although 161 // some resources may allow a client to request the generation of an appropriate name 162 // automatically. Name is primarily intended for creation idempotence and configuration 163 // definition. 164 // Cannot be updated. 165 // More info: http://kubernetes.io/docs/user-guide/identifiers#names 166 // +optional 167 Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` 168 169 // Map of string keys and values that can be used to organize and categorize 170 // (scope and select) objects. May match selectors of replication controllers 171 // and services. 172 // More info: http://kubernetes.io/docs/user-guide/labels 173 // +optional 174 Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"` 175 176 // Annotations is an unstructured key value map stored with a resource that may be 177 // set by external tools to store and retrieve arbitrary metadata. They are not 178 // queryable and should be preserved when modifying objects. 179 // More info: http://kubernetes.io/docs/user-guide/annotations 180 // +optional 181 Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` 182 } 183 184 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 185 186 // RedisFailoverList represents a Redis failover list 187 type RedisFailoverList struct { 188 metav1.TypeMeta `json:",inline"` 189 metav1.ListMeta `json:"metadata"` 190 191 Items []RedisFailover `json:"items"` 192 }