Skip to content

Commit 04ab686

Browse files
authored
26 27 fix bootstrap key and configuration (#28)
* added additionalServerConfiguration in CRD #26 * fixed bootstrap secrets bug #27
1 parent af014dc commit 04ab686

15 files changed

Lines changed: 162 additions & 20 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ go.work.sum
2626
/bin/
2727
/bin/controller-gen
2828
/bin/controller-gen-v0.15.0
29+
/config/samples/ts_v1alpha1_typesensecluster_blueprints.yaml

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ OPERATOR_SDK_VERSION ?= v1.38.0
5252
# Image URL to use all building/pushing image targets
5353
DOCKER_HUB_NAME ?= $(shell docker info | sed '/Username:/!d;s/.* //')
5454
IMG_NAME ?= typesense-operator
55-
IMG_TAG ?= 0.2.7
55+
IMG_TAG ?= 0.2.8
5656
IMG ?= $(DOCKER_HUB_NAME)/$(IMG_NAME):$(IMG_TAG)
5757

5858
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.

charts/typesense-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ type: application
1313
# This is the chart version. This version number should be incremented each time you make changes
1414
# to the chart and its templates, including the app version.
1515
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16-
version: 0.2.7
16+
version: 0.2.8
1717
# This is the version number of the application being deployed. This version number should be
1818
# incremented each time you make changes to the application. Versions are not expected to
1919
# follow Semantic Versioning. They should reflect the version the application is using.
2020
# It is recommended to use it with quotes.
21-
appVersion: "0.2.7"
21+
appVersion: "0.2.8"

charts/typesense-operator/templates/typesensecluster-crd.yaml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ spec:
5656
spec:
5757
description: TypesenseClusterSpec defines the desired state of TypesenseCluster
5858
properties:
59+
additionalServerConfiguration:
60+
description: |-
61+
LocalObjectReference contains enough information to let you locate the
62+
referenced object inside the same namespace.
63+
properties:
64+
name:
65+
default: ""
66+
description: |-
67+
Name of the referent.
68+
This field is effectively required, but due to backwards compatibility is
69+
allowed to be empty. Instances of this type with an empty value here are
70+
almost certainly wrong.
71+
TODO: Add other useful fields. apiVersion, kind, uid?
72+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
73+
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
74+
type: string
75+
type: object
76+
x-kubernetes-map-type: atomic
5977
adminApiKey:
6078
description: |-
6179
SecretReference represents a Secret Reference. It has enough information to retrieve secret
@@ -79,6 +97,9 @@ spec:
7997
type: integer
8098
corsDomains:
8199
type: string
100+
enableCors:
101+
default: false
102+
type: boolean
82103
image:
83104
type: string
84105
ingress:
@@ -102,6 +123,10 @@ spec:
102123
- host
103124
- ingressClassName
104125
type: object
126+
nodeSelector:
127+
additionalProperties:
128+
type: string
129+
type: object
105130
peeringPort:
106131
default: 8107
107132
exclusiveMinimum: true
@@ -116,6 +141,61 @@ spec:
116141
resetPeersOnError:
117142
default: true
118143
type: boolean
144+
resources:
145+
description: ResourceRequirements describes the compute resource requirements.
146+
properties:
147+
claims:
148+
description: |-
149+
Claims lists the names of resources, defined in spec.resourceClaims,
150+
that are used by this container.
151+
152+
153+
This is an alpha field and requires enabling the
154+
DynamicResourceAllocation feature gate.
155+
156+
157+
This field is immutable. It can only be set for containers.
158+
items:
159+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
160+
properties:
161+
name:
162+
description: |-
163+
Name must match the name of one entry in pod.spec.resourceClaims of
164+
the Pod where this field is used. It makes that resource available
165+
inside a container.
166+
type: string
167+
required:
168+
- name
169+
type: object
170+
type: array
171+
x-kubernetes-list-map-keys:
172+
- name
173+
x-kubernetes-list-type: map
174+
limits:
175+
additionalProperties:
176+
anyOf:
177+
- type: integer
178+
- type: string
179+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
180+
x-kubernetes-int-or-string: true
181+
description: |-
182+
Limits describes the maximum amount of compute resources allowed.
183+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
184+
type: object
185+
requests:
186+
additionalProperties:
187+
anyOf:
188+
- type: integer
189+
- type: string
190+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
191+
x-kubernetes-int-or-string: true
192+
description: |-
193+
Requests describes the minimum amount of compute resources required.
194+
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
195+
otherwise to an implementation-defined value. Requests cannot exceed Limits.
196+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
197+
type: object
198+
type: object
119199
scrapers:
120200
items:
121201
properties:
@@ -149,6 +229,44 @@ spec:
149229
required:
150230
- storageClassName
151231
type: object
232+
tolerations:
233+
items:
234+
description: |-
235+
The pod this Toleration is attached to tolerates any taint that matches
236+
the triple <key,value,effect> using the matching operator <operator>.
237+
properties:
238+
effect:
239+
description: |-
240+
Effect indicates the taint effect to match. Empty means match all taint effects.
241+
When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
242+
type: string
243+
key:
244+
description: |-
245+
Key is the taint key that the toleration applies to. Empty means match all taint keys.
246+
If the key is empty, operator must be Exists; this combination means to match all values and all keys.
247+
type: string
248+
operator:
249+
description: |-
250+
Operator represents a key's relationship to the value.
251+
Valid operators are Exists and Equal. Defaults to Equal.
252+
Exists is equivalent to wildcard for value, so that a pod can
253+
tolerate all taints of a particular category.
254+
type: string
255+
tolerationSeconds:
256+
description: |-
257+
TolerationSeconds represents the period of time the toleration (which must be
258+
of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
259+
it is not set, which means tolerate the taint forever (do not evict). Zero and
260+
negative values will be treated as 0 (evict immediately) by the system.
261+
format: int64
262+
type: integer
263+
value:
264+
description: |-
265+
Value is the taint value the toleration matches to.
266+
If the operator is Exists, the value should be empty, otherwise just a regular string.
267+
type: string
268+
type: object
269+
type: array
152270
required:
153271
- image
154272
- storage

charts/typesense-operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ controllerManager:
1212
- ALL
1313
image:
1414
repository: akyriako78/typesense-operator
15-
tag: 0.2.7
15+
tag: 0.2.8
1616
resources:
1717
limits:
1818
cpu: 500m

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kind: Kustomization
55
images:
66
- name: controller
77
newName: akyriako78/typesense-operator
8-
newTag: 0.2.7-dev.1
8+
newTag: 0.2.8

config/samples/ts_v1alpha1_typesensecluster_kind.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ reclaimPolicy: Delete
77
allowVolumeExpansion: false
88
volumeBindingMode: WaitForFirstConsumer
99
---
10+
apiVersion: v1
11+
kind: Secret
12+
metadata:
13+
labels:
14+
app.kubernetes.io/name: typesense-operator
15+
app.kubernetes.io/managed-by: kustomize
16+
name: typesense-common-bootstrap-key
17+
type: Opaque
18+
data:
19+
typesense-api-key: SXdpVG9CcnFYTHZYeTJNMG1TS1hPaGt0dlFUY3VWUloxc1M5REtsRUNtMFFwQU93R1hoanVIVWJLQnE2ejdlSQ==
20+
---
1021
apiVersion: ts.opentelekomcloud.com/v1alpha1
1122
kind: TypesenseCluster
1223
metadata:
@@ -20,6 +31,8 @@ spec:
2031
storage:
2132
size: 10Mi
2233
storageClassName: typesense-local-path
34+
adminApiKey:
35+
name: typesense-common-bootstrap-key
2336
ingress:
2437
referer: referer.example.com
2538
host: host.example.com
@@ -32,7 +45,6 @@ metadata:
3245
name: c-kind-2-config
3346
data:
3447
TYPESENSE_ENABLE_SEARCH_ANALYTICS: "true"
35-
TYPESENSE_ENABLE_CORS: "true"
3648
---
3749
apiVersion: ts.opentelekomcloud.com/v1alpha1
3850
kind: TypesenseCluster

internal/controller/typesensecluster_configmap.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
appsv1 "k8s.io/api/apps/v1"
88
v1 "k8s.io/api/core/v1"
99
apierrors "k8s.io/apimachinery/pkg/api/errors"
10+
"k8s.io/utils/ptr"
1011
ctrl "sigs.k8s.io/controller-runtime"
1112
"sigs.k8s.io/controller-runtime/pkg/client"
1213
"strings"
@@ -25,6 +26,7 @@ func (r *TypesenseClusterReconciler) ReconcileConfigMap(ctx context.Context, ts
2526
configMapExists = false
2627
} else {
2728
r.logger.Error(err, fmt.Sprintf("unable to fetch config map: %s", configMapName))
29+
return ptr.To[bool](false), err
2830
}
2931
}
3032

internal/controller/typesensecluster_constants.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ const (
44
ClusterNodesConfigMap = "%s-nodeslist"
55
ClusterAdminApiKeySecret = "%s-admin-key"
66
ClusterAdminApiKeySecretKeyName = "typesense-api-key"
7-
ClusterHeadlessService = "%s-sts-svc"
8-
ClusterRestService = "%s-svc"
9-
ClusterStatefulSet = "%s-sts"
10-
ClusterAppLabel = "%s-sts"
11-
ClusterReverseProxyAppLabel = "%s-rp"
12-
ClusterReverseProxyIngress = "%s-reverse-proxy"
13-
ClusterReverseProxyConfigMap = "%s-reverse-proxy-config"
14-
ClusterReverseProxy = "%s-reverse-proxy"
15-
ClusterReverseProxyService = "%s-reverse-proxy-svc"
16-
ClusterScraperCronJob = "%s-scraper"
17-
ClusterScraperCronJobContainer = "%s-docsearch-scraper"
7+
8+
ClusterHeadlessService = "%s-sts-svc"
9+
ClusterRestService = "%s-svc"
10+
ClusterStatefulSet = "%s-sts"
11+
ClusterAppLabel = "%s-sts"
12+
13+
ClusterReverseProxyAppLabel = "%s-rp"
14+
ClusterReverseProxyIngress = "%s-reverse-proxy"
15+
ClusterReverseProxyConfigMap = "%s-reverse-proxy-config"
16+
ClusterReverseProxy = "%s-reverse-proxy"
17+
ClusterReverseProxyService = "%s-reverse-proxy-svc"
18+
19+
ClusterScraperCronJob = "%s-scraper"
20+
ClusterScraperCronJobContainer = "%s-docsearch-scraper"
1821
)

internal/controller/typesensecluster_ingress.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (r *TypesenseClusterReconciler) ReconcileIngress(ctx context.Context, ts ts
5050
ingressExists = false
5151
} else {
5252
r.logger.Error(err, fmt.Sprintf("unable to fetch ingress: %s", ingressName))
53+
return err
5354
}
5455
}
5556

0 commit comments

Comments
 (0)