From 2f69934ac145be7ac1fb464debba9032db581fb6 Mon Sep 17 00:00:00 2001 From: Kyriakos Akriotis Date: Fri, 6 Dec 2024 18:22:49 +0100 Subject: [PATCH 1/3] added TYPESENSE_PEERING_ADDRESS in env vars, added logLevel in chart #2 --- Makefile | 4 ++-- charts/typesense-operator/templates/deployment.yaml | 4 +++- charts/typesense-operator/values.yaml | 4 ++-- config/kind/typesense-local-path.yaml | 8 -------- internal/controller/typesensecluster_statefulset.go | 7 +++++++ 5 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 config/kind/typesense-local-path.yaml diff --git a/Makefile b/Makefile index 3cec6c2..e91ef83 100644 --- a/Makefile +++ b/Makefile @@ -50,9 +50,9 @@ endif # This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. OPERATOR_SDK_VERSION ?= v1.38.0 # Image URL to use all building/pushing image targets -DOCKER_HUB_NAME ?= $(shell docker info | sed '/Username:/!d;s/.* //') +DOCKER_HUB_NAME ?= akyriako78# $(shell docker info | sed '/Username:/!d;s/.* //') IMG_NAME ?= typesense-operator -IMG_TAG ?= 0.1.0 +IMG_TAG ?= 0.1.1-dev.3 IMG ?= $(DOCKER_HUB_NAME)/$(IMG_NAME):$(IMG_TAG) # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. diff --git a/charts/typesense-operator/templates/deployment.yaml b/charts/typesense-operator/templates/deployment.yaml index 30d1cac..b243f3b 100644 --- a/charts/typesense-operator/templates/deployment.yaml +++ b/charts/typesense-operator/templates/deployment.yaml @@ -20,7 +20,9 @@ spec: kubectl.kubernetes.io/default-container: manager spec: containers: - - args: {{- toYaml .Values.controllerManager.manager.args | nindent 8 }} + - args: + {{- toYaml .Values.controllerManager.manager.args | nindent 8 }} + - --zap-log-level={{ .Values.controllerManager.manager.logLevel }} command: - /manager env: diff --git a/charts/typesense-operator/values.yaml b/charts/typesense-operator/values.yaml index a3667d2..ab48682 100644 --- a/charts/typesense-operator/values.yaml +++ b/charts/typesense-operator/values.yaml @@ -4,7 +4,7 @@ controllerManager: - --metrics-bind-address=:8443 - --leader-elect - --health-probe-bind-address=:8081 - - --zap-log-level=info + logLevel: debug containerSecurityContext: allowPrivilegeEscalation: false capabilities: @@ -12,7 +12,7 @@ controllerManager: - ALL image: repository: akyriako78/typesense-operator - tag: 0.1.0 + tag: 0.1.1-dev.3 resources: limits: cpu: 500m diff --git a/config/kind/typesense-local-path.yaml b/config/kind/typesense-local-path.yaml deleted file mode 100644 index dfede57..0000000 --- a/config/kind/typesense-local-path.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: storage.k8s.io/v1 -kind: StorageClass -metadata: - name: typesense-local-path -provisioner: rancher.io/local-path -reclaimPolicy: Delete -allowVolumeExpansion: false -volumeBindingMode: WaitForFirstConsumer \ No newline at end of file diff --git a/internal/controller/typesensecluster_statefulset.go b/internal/controller/typesensecluster_statefulset.go index 4e3dd06..4e1d0a4 100644 --- a/internal/controller/typesensecluster_statefulset.go +++ b/internal/controller/typesensecluster_statefulset.go @@ -117,6 +117,13 @@ func (r *TypesenseClusterReconciler) createStatefulSet( Name: "TYPESENSE_PEERING_PORT", Value: strconv.Itoa(ts.Spec.PeeringPort), }, + { + Name: "TYPESENSE_PEERING_ADDRESS", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }}, + }, { Name: "TYPESENSE_ENABLE_CORS", Value: strconv.FormatBool(ts.Spec.IsCorsEnabled()), From 13a2ebbe8200eab769b797b34113992ec502a7a1 Mon Sep 17 00:00:00 2001 From: Kyriakos Akriotis Date: Fri, 6 Dec 2024 19:51:13 +0100 Subject: [PATCH 2/3] added samples per cloud provider #2 --- config/samples/kustomization.yaml | 6 ++- .../samples/ts_v1alpha1_typesensecluster.yaml | 30 +------------- .../ts_v1alpha1_typesensecluster_aws.yaml | 27 +++++++++++++ .../ts_v1alpha1_typesensecluster_azure.yaml | 26 +++++++++++++ .../ts_v1alpha1_typesensecluster_bm.yaml | 27 +++++++++++++ .../ts_v1alpha1_typesensecluster_kind.yaml | 35 +++++++++++++++++ ...ha1_typesensecluster_opentelekomcloud.yaml | 39 +++++++++++++++++++ 7 files changed, 161 insertions(+), 29 deletions(-) create mode 100644 config/samples/ts_v1alpha1_typesensecluster_aws.yaml create mode 100644 config/samples/ts_v1alpha1_typesensecluster_azure.yaml create mode 100644 config/samples/ts_v1alpha1_typesensecluster_bm.yaml create mode 100644 config/samples/ts_v1alpha1_typesensecluster_kind.yaml create mode 100644 config/samples/ts_v1alpha1_typesensecluster_opentelekomcloud.yaml diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 4aa5d11..16a8190 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -1,4 +1,8 @@ ## Append samples of your project ## resources: -- ts_v1alpha1_typesensecluster.yaml +- ts_v1alpha1_typesensecluster_aws.yaml +- ts_v1alpha1_typesensecluster_azure.yaml +- ts_v1alpha1_typesensecluster_bm.yaml +- ts_v1alpha1_typesensecluster_kind.yaml +- ts_v1alpha1_typesensecluster_opentelekomcloud.yaml # +kubebuilder:scaffold:manifestskustomizesamples diff --git a/config/samples/ts_v1alpha1_typesensecluster.yaml b/config/samples/ts_v1alpha1_typesensecluster.yaml index aeca36f..19f1251 100644 --- a/config/samples/ts_v1alpha1_typesensecluster.yaml +++ b/config/samples/ts_v1alpha1_typesensecluster.yaml @@ -9,31 +9,5 @@ spec: image: typesense/typesense:27.1 replicas: 3 storage: - size: 10Mi - storageClassName: typesense-local-path ---- -apiVersion: ts.opentelekomcloud.com/v1alpha1 -kind: TypesenseCluster -metadata: - labels: - app.kubernetes.io/name: typesense-operator - app.kubernetes.io/managed-by: kustomize - name: cluster-2 -spec: - image: typesense/typesense:26.0 - replicas: 3 - storage: - storageClassName: typesense-local-path ---- -apiVersion: ts.opentelekomcloud.com/v1alpha1 -kind: TypesenseCluster -metadata: - labels: - app.kubernetes.io/name: typesense-operator - app.kubernetes.io/managed-by: kustomize - name: cluster-4 -spec: - image: typesense/typesense:27.1 - replicas: 3 - storage: - storageClassName: iscsi \ No newline at end of file + size: 100Mi + storageClassName: standard \ No newline at end of file diff --git a/config/samples/ts_v1alpha1_typesensecluster_aws.yaml b/config/samples/ts_v1alpha1_typesensecluster_aws.yaml new file mode 100644 index 0000000..3920d84 --- /dev/null +++ b/config/samples/ts_v1alpha1_typesensecluster_aws.yaml @@ -0,0 +1,27 @@ +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-1 +spec: + image: typesense/typesense:27.1 + replicas: 3 + storage: + size: 100Mi + storageClassName: gp2 +--- +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-2 +spec: + image: typesense/typesense:27.1 + replicas: 1 + storage: + size: 100Mi + storageClassName: gp2 \ No newline at end of file diff --git a/config/samples/ts_v1alpha1_typesensecluster_azure.yaml b/config/samples/ts_v1alpha1_typesensecluster_azure.yaml new file mode 100644 index 0000000..04d9020 --- /dev/null +++ b/config/samples/ts_v1alpha1_typesensecluster_azure.yaml @@ -0,0 +1,26 @@ +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-1 +spec: + image: typesense/typesense:27.1 + replicas: 3 + storage: + size: 10Mi + storageClassName: managed-csi +--- +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-2 +spec: + image: typesense/typesense:26.0 + replicas: 1 + storage: + storageClassName: managed-csi \ No newline at end of file diff --git a/config/samples/ts_v1alpha1_typesensecluster_bm.yaml b/config/samples/ts_v1alpha1_typesensecluster_bm.yaml new file mode 100644 index 0000000..634a315 --- /dev/null +++ b/config/samples/ts_v1alpha1_typesensecluster_bm.yaml @@ -0,0 +1,27 @@ +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-1 +spec: + image: typesense/typesense:27.1 + replicas: 3 + storage: + size: 100Mi + storageClassName: iscsi +--- +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-2 +spec: + image: typesense/typesense:27.1 + replicas: 1 + storage: + size: 100Mi + storageClassName: nfs \ No newline at end of file diff --git a/config/samples/ts_v1alpha1_typesensecluster_kind.yaml b/config/samples/ts_v1alpha1_typesensecluster_kind.yaml new file mode 100644 index 0000000..04d5002 --- /dev/null +++ b/config/samples/ts_v1alpha1_typesensecluster_kind.yaml @@ -0,0 +1,35 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: typesense-local-path +provisioner: rancher.io/local-path +reclaimPolicy: Delete +allowVolumeExpansion: false +volumeBindingMode: WaitForFirstConsumer +--- +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-1 +spec: + image: typesense/typesense:27.1 + replicas: 3 + storage: + size: 10Mi + storageClassName: typesense-local-path +--- +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-2 +spec: + image: typesense/typesense:26.0 + replicas: 1 + storage: + storageClassName: typesense-local-path \ No newline at end of file diff --git a/config/samples/ts_v1alpha1_typesensecluster_opentelekomcloud.yaml b/config/samples/ts_v1alpha1_typesensecluster_opentelekomcloud.yaml new file mode 100644 index 0000000..74bb1fd --- /dev/null +++ b/config/samples/ts_v1alpha1_typesensecluster_opentelekomcloud.yaml @@ -0,0 +1,39 @@ +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-1 +spec: + image: typesense/typesense:27.1 + replicas: 3 + storage: + size: 10Mi + storageClassName: csi-disk +--- +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-2 +spec: + image: typesense/typesense:26.0 + replicas: 1 + storage: + storageClassName: csi-disk +--- +apiVersion: ts.opentelekomcloud.com/v1alpha1 +kind: TypesenseCluster +metadata: + labels: + app.kubernetes.io/name: typesense-operator + app.kubernetes.io/managed-by: kustomize + name: cluster-3 +spec: + image: typesense/typesense:26.0 + replicas: 3 + storage: + storageClassName: csi-obs \ No newline at end of file From 0e8f717162d551314b0c12bc522bab3469004136 Mon Sep 17 00:00:00 2001 From: Kyriakos Akriotis Date: Sat, 7 Dec 2024 08:32:03 +0100 Subject: [PATCH 3/3] bump images and chart version, changes in README.md #2 --- Makefile | 4 ++-- README.md | 32 +++++++++++++-------------- charts/typesense-operator/Chart.yaml | 4 ++-- charts/typesense-operator/values.yaml | 2 +- config/samples/kustomization.yaml | 1 + 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index e91ef83..591cb15 100644 --- a/Makefile +++ b/Makefile @@ -50,9 +50,9 @@ endif # This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. OPERATOR_SDK_VERSION ?= v1.38.0 # Image URL to use all building/pushing image targets -DOCKER_HUB_NAME ?= akyriako78# $(shell docker info | sed '/Username:/!d;s/.* //') +DOCKER_HUB_NAME ?= $(shell docker info | sed '/Username:/!d;s/.* //') IMG_NAME ?= typesense-operator -IMG_TAG ?= 0.1.1-dev.3 +IMG_TAG ?= 0.2.0-rc.0 IMG ?= $(DOCKER_HUB_NAME)/$(IMG_NAME):$(IMG_TAG) # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. diff --git a/README.md b/README.md index 3776c8d..6fb0d40 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ You’ll need a Kubernetes cluster to run against. You can use [KIND](https://si ### Deploy Using Helm -On the other hand if you are deploying on a production environment, it is **highly recommended** to deploy the +If you are deploying on a production environment, it is **highly recommended** to deploy the controller to the cluster using a **Helm chart** from its repo: ```sh @@ -202,19 +202,24 @@ make deploy IMG=/typesense-operator: 3. Install Instances of Custom Resources: -If you are running on KIND, first install a custom storage class required by the samples +Provision one of the samples available in `config/samples`: -```shell -kubectl apply -f config/kind/ -``` - -and then the samples: +| Suffix | Description | CSI Driver | Storage Class | +|---------------|--------------------|--------------------------------------------|-----------------------| +| | Generic | | standard | +| azure | Microsoft Azure | disk.csi.azure.com | managed-csi | +| aws | AWS | ebs.csi.aws.com | gp2 | +| opentelekomcloud | Open Telekom Cloud | disk.csi.everest.io
obs.csi.everest.io | csi-disk
csi-obs | +| bm | Bare Metal | democratic-csi (iscsi/nfs) | iscsi
nfs | +| kind | KiND | | rancher.io/local-path | ```sh -kubectl apply -f config/samples/ +kubectl apply -f config/samples/ts_v1alpha1_typesensecluster_{{Suffix}} ``` -```yaml +e.g. for AWS looks like: + +```yaml title=ts_v1alpha1_typesensecluster_aws.yaml apiVersion: ts.opentelekomcloud.com/v1alpha1 kind: TypesenseCluster metadata: @@ -226,15 +231,10 @@ spec: image: typesense/typesense:27.1 replicas: 3 storage: - size: 10Mi - storageClassName: typesense-local-path + size: 100Mi + storageClassName: gp2 ``` -> [!CAUTION] -> - The samples are tailored for KIND, change the `storageClassName` value according to your target environment. -> - The 3rd sample is designed to portray a failing installation, `storageClassName` is set to `iscsi` which will fail on -> any Kubernetes cluster that is not using [democratic-csi](https://github.com/democratic-csi/democratic-csi). - #### Uninstall CRDs To delete the CRDs from the cluster: diff --git a/charts/typesense-operator/Chart.yaml b/charts/typesense-operator/Chart.yaml index 90d8c1b..c7f6473 100644 --- a/charts/typesense-operator/Chart.yaml +++ b/charts/typesense-operator/Chart.yaml @@ -13,9 +13,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.1.0" +appVersion: "0.2.0-rc.0" diff --git a/charts/typesense-operator/values.yaml b/charts/typesense-operator/values.yaml index ab48682..030818e 100644 --- a/charts/typesense-operator/values.yaml +++ b/charts/typesense-operator/values.yaml @@ -12,7 +12,7 @@ controllerManager: - ALL image: repository: akyriako78/typesense-operator - tag: 0.1.1-dev.3 + tag: 0.2.0-rc.0 resources: limits: cpu: 500m diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 16a8190..b461735 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -5,4 +5,5 @@ resources: - ts_v1alpha1_typesensecluster_bm.yaml - ts_v1alpha1_typesensecluster_kind.yaml - ts_v1alpha1_typesensecluster_opentelekomcloud.yaml +- ts_v1alpha1_typesensecluster.yaml # +kubebuilder:scaffold:manifestskustomizesamples