Skip to content

Commit

Permalink
Fix elasticsearch update for terminationPolicy > deletionPolicy
Browse files Browse the repository at this point in the history
Signed-off-by: raihankhan <[email protected]>
  • Loading branch information
raihankhan committed Sep 25, 2024
1 parent ed029a0 commit b3dd1a9
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
certificates:
- alias: database-client
secretName: es-cluster-client-cert
terminationPolicy: WipeOut
deletionPolicy: WipeOut
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ spec:
enableSSL: true
databaseRef:
name: es-cluster
terminationPolicy: WipeOut
deletionPolicy: WipeOut
```
> Note: Elasticsearch Database and Elasticsearch dashboard should have to be deployed in the same namespace. In this tutorial, we use demo namespace for both cases.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ spec:
enableSSL: true
databaseRef:
name: es-cluster
terminationPolicy: WipeOut
deletionPolicy: WipeOut
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ spec:
enableSSL: true
databaseRef:
name: os-cluster
terminationPolicy: WipeOut
deletionPolicy: WipeOut
```
> Note: OpenSearch Database and OpenSearch dashboard should have to be deployed in the same namespace. In this tutorial, we use `demo` namespace for both cases.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ spec:
enableSSL: true
databaseRef:
name: os-cluster
terminationPolicy: WipeOut
deletionPolicy: WipeOut
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ spec:
resources:
requests:
storage: 1Gi
terminationPolicy: Delete
deletionPolicy: Delete
```
```bash
Expand All @@ -202,7 +202,7 @@ Here,
- `spec.replicas` - specifies the number of Elasticsearch nodes.
- `spec.storageType` - specifies the type of storage that will be used for Elasticsearch database. It can be `Durable` or `Ephemeral`. The default value of this field is `Durable`. If `Ephemeral` is used then KubeDB will create the Elasticsearch database using `EmptyDir` volume. In this case, you don't have to specify `spec.storage` field. This is useful for testing purposes.
- `spec.storage` specifies the StorageClass of PVC dynamically allocated to store data for this database. This storage spec will be passed to the StatefulSet created by the KubeDB operator to run database pods. You can specify any StorageClass available in your cluster with appropriate resource requests. If you don't specify `spec.storageType: Ephemeral`, then this field is required.
- `spec.terminationPolicy` or `spec.deletionPolicy` specifies what KubeDB should do when a user try to delete Elasticsearch CR. Termination policy `Delete` will delete the database pods, secret and PVC when the Elasticsearch CR is deleted.
- `spec.deletionPolicy` or `spec.deletionPolicy` specifies what KubeDB should do when a user try to delete Elasticsearch CR. Termination policy `Delete` will delete the database pods, secret and PVC when the Elasticsearch CR is deleted.

> Note: `spec.storage` section is used to create PVC for database pod. It will create PVC with storage size specified in the `storage.resources.requests` field. Don't specify `limits` here. PVC does not get resized automatically.
Expand Down Expand Up @@ -657,7 +657,7 @@ namespace "demo" deleted
If you are just testing some basic functionalities, you might want to avoid additional hassles due to some safety features that are great for the production environment. You can follow these tips to avoid them.

1. **Use `storageType: Ephemeral`**. Databases are precious. You might not want to lose your data in your production environment if the database pod fails. So, we recommend to use `spec.storageType: Durable` and provide storage spec in `spec.storage` section. For testing purposes, you can just use `spec.storageType: Ephemeral`. KubeDB will use [emptyDir](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) for storage. You will not require to provide `spec.storage` section.
2. **Use `terminationPolicy: WipeOut`**. It is nice to be able to resume the database from the previous one. So, we preserve all your `PVCs` and auth `Secrets`. If you don't want to resume the database, you can just use `spec.terminationPolicy: WipeOut`. It will clean up every resouce that was created with the Elasticsearch CR. For more details, please visit [here](/docs/guides/elasticsearch/concepts/elasticsearch/index.md#specterminationpolicy).
2. **Use `deletionPolicy: WipeOut`**. It is nice to be able to resume the database from the previous one. So, we preserve all your `PVCs` and auth `Secrets`. If you don't want to resume the database, you can just use `spec.deletionPolicy: WipeOut`. It will clean up every resouce that was created with the Elasticsearch CR. For more details, please visit [here](/docs/guides/elasticsearch/concepts/elasticsearch/index.md#specdeletionPolicy).

## Next Steps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
resources:
requests:
storage: 1Gi
terminationPolicy: Delete
deletionPolicy: Delete
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ spec:
resources:
requests:
storage: 1Gi
terminationPolicy: DoNotTerminate
deletionPolicy: DoNotTerminate
```
```bash
Expand All @@ -197,7 +197,7 @@ Here,
- `spec.replicas` - specifies the number of OpenSearch nodes.
- `spec.storageType` - specifies the type of storage that will be used for OpenSearch database. It can be `Durable` or `Ephemeral`. The default value of this field is `Durable`. If `Ephemeral` is used then KubeDB will create the OpenSearch database using `EmptyDir` volume. In this case, you don't have to specify `spec.storage` field. This is useful for testing purposes.
- `spec.storage` specifies the StorageClass of PVC dynamically allocated to store data for this database. This storage spec will be passed to the StatefulSet created by the KubeDB operator to run database pods. You can specify any StorageClass available in your cluster with appropriate resource requests. If you don't specify `spec.storageType: Ephemeral`, then this field is required.
- `spec.terminationPolicy` or `spec.deletionPolicy` specifies what KubeDB should do when a user try to delete the operation of Elasticsearch CR. Termination policy `DoNotTerminate` prevents a user from deleting this object if the admission webhook is enabled.
- `spec.deletionPolicy` or `spec.deletionPolicy` specifies what KubeDB should do when a user try to delete the operation of Elasticsearch CR. Termination policy `DoNotTerminate` prevents a user from deleting this object if the admission webhook is enabled.

> Note: `spec.storage` section is used to create PVC for database pod. It will create PVC with storage size specified in the `storage.resources.requests` field. Don't specify `limits` here. PVC does not get resized automatically.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
resources:
requests:
storage: 1Gi
terminationPolicy: DoNotTerminate
deletionPolicy: DoNotTerminate

0 comments on commit b3dd1a9

Please sign in to comment.