Skip to content

Commit

Permalink
Merge pull request #7 from akyriako/2-add-overwrite-in-statefulset-fo…
Browse files Browse the repository at this point in the history
…r-peering-address

2 add overwrite in statefulset for peering address
  • Loading branch information
akyriako authored Dec 7, 2024
2 parents 57e20b8 + 0e8f717 commit 5b63fcc
Show file tree
Hide file tree
Showing 14 changed files with 192 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ 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/.* //')
IMG_NAME ?= typesense-operator
IMG_TAG ?= 0.1.0
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.
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -202,19 +202,24 @@ make deploy IMG=<some-registry>/typesense-operator:<tag>

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<br/>obs.csi.everest.io | csi-disk<br/>csi-obs |
| bm | Bare Metal | democratic-csi (iscsi/nfs) | iscsi<br/>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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions charts/typesense-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 3 additions & 1 deletion charts/typesense-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions charts/typesense-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ controllerManager:
- --metrics-bind-address=:8443
- --leader-elect
- --health-probe-bind-address=:8081
- --zap-log-level=info
logLevel: debug
containerSecurityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
image:
repository: akyriako78/typesense-operator
tag: 0.1.0
tag: 0.2.0-rc.0
resources:
limits:
cpu: 500m
Expand Down
8 changes: 0 additions & 8 deletions config/kind/typesense-local-path.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## Append samples of your project ##
resources:
- 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
- ts_v1alpha1_typesensecluster.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
30 changes: 2 additions & 28 deletions config/samples/ts_v1alpha1_typesensecluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
size: 100Mi
storageClassName: standard
27 changes: 27 additions & 0 deletions config/samples/ts_v1alpha1_typesensecluster_aws.yaml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions config/samples/ts_v1alpha1_typesensecluster_azure.yaml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions config/samples/ts_v1alpha1_typesensecluster_bm.yaml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions config/samples/ts_v1alpha1_typesensecluster_kind.yaml
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions config/samples/ts_v1alpha1_typesensecluster_opentelekomcloud.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions internal/controller/typesensecluster_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 5b63fcc

Please sign in to comment.