-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Allow adding entries to the OpenSearch keystore #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| = Add entries to the OpenSearch Keystore | ||
| :description: Add entries to the OpenSearch Keystore | ||
|
|
||
| The OpenSearch keystore provides secure storage for sensitive configuration settings such as credentials and API keys. | ||
| You can populate the keystore by referencing Secrets from in your OpenSearch configuration. | ||
|
|
||
| [source,yaml] | ||
| ---- | ||
| --- | ||
| apiVersion: opensearch.stackable.tech/v1alpha1 | ||
| kind: OpenSearchCluster | ||
| metadata: | ||
| name: opensearch | ||
| spec: | ||
| clusterConfig: | ||
| keystore: | ||
| - key: s3.client.default.access_key # <1> | ||
| secretKeyRef: | ||
| name: s3-credentials # <2> | ||
| key: accessKey # <3> | ||
| - key: s3.client.default.secret_key | ||
| secretKeyRef: | ||
| name: s3-credentials | ||
| key: secretKey | ||
| nodes: | ||
| roleGroups: | ||
| default: | ||
| replicas: 1 | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: s3-credentials | ||
| stringData: | ||
| accessKey: my-access-key | ||
| secretKey: my-secret-key | ||
| ---- | ||
| <1> The key in the OpenSearch keystore which corresponds to a setting in OpenSearch (e.g. `s3.client.default.access_key`). | ||
| <2> The name of the Secret containing the value | ||
| <3> The key within that Secret | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,7 +30,7 @@ use validate::validate; | |||||||||||
| use crate::{ | ||||||||||||
| crd::{ | ||||||||||||
| NodeRoles, | ||||||||||||
| v1alpha1::{self}, | ||||||||||||
| v1alpha1::{self, OpenSearchKeystore}, | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| }, | ||||||||||||
| framework::{ | ||||||||||||
| ClusterName, ControllerName, HasName, HasUid, ListenerClassName, NameIsValidLabelValue, | ||||||||||||
|
|
@@ -166,9 +166,11 @@ pub struct ValidatedCluster { | |||||||||||
| pub uid: Uid, | ||||||||||||
| pub role_config: GenericRoleConfig, | ||||||||||||
| pub role_group_configs: BTreeMap<RoleGroupName, OpenSearchRoleGroupConfig>, | ||||||||||||
| pub keystores: Vec<OpenSearchKeystore>, | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| impl ValidatedCluster { | ||||||||||||
| #[allow(clippy::too_many_arguments)] | ||||||||||||
| pub fn new( | ||||||||||||
| image: ResolvedProductImage, | ||||||||||||
| product_version: ProductVersion, | ||||||||||||
|
|
@@ -177,6 +179,7 @@ impl ValidatedCluster { | |||||||||||
| uid: impl Into<Uid>, | ||||||||||||
| role_config: GenericRoleConfig, | ||||||||||||
| role_group_configs: BTreeMap<RoleGroupName, OpenSearchRoleGroupConfig>, | ||||||||||||
| keystores: Vec<OpenSearchKeystore>, | ||||||||||||
| ) -> Self { | ||||||||||||
| let uid = uid.into(); | ||||||||||||
| ValidatedCluster { | ||||||||||||
|
|
@@ -193,6 +196,7 @@ impl ValidatedCluster { | |||||||||||
| uid, | ||||||||||||
| role_config, | ||||||||||||
| role_group_configs, | ||||||||||||
| keystores, | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
@@ -378,10 +382,13 @@ mod tests { | |||||||||||
| use super::{Context, OpenSearchRoleGroupConfig, ValidatedCluster, ValidatedLogging}; | ||||||||||||
| use crate::{ | ||||||||||||
| controller::{OpenSearchNodeResources, ValidatedOpenSearchConfig}, | ||||||||||||
| crd::{NodeRoles, v1alpha1}, | ||||||||||||
| crd::{ | ||||||||||||
| NodeRoles, | ||||||||||||
| v1alpha1::{self, OpenSearchKeystore, SecretKeyRef}, | ||||||||||||
| }, | ||||||||||||
|
Comment on lines
+385
to
+388
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We decided to use the versioned module explicitly.
Suggested change
|
||||||||||||
| framework::{ | ||||||||||||
| ClusterName, ListenerClassName, NamespaceName, OperatorName, ProductVersion, | ||||||||||||
| RoleGroupName, builder::pod::container::EnvVarSet, | ||||||||||||
| RoleGroupName, SecretKey, SecretName, builder::pod::container::EnvVarSet, | ||||||||||||
| product_logging::framework::ValidatedContainerLogConfigChoice, | ||||||||||||
| role_utils::GenericProductSpecificCommonConfig, | ||||||||||||
| }, | ||||||||||||
|
|
@@ -494,6 +501,13 @@ mod tests { | |||||||||||
| ), | ||||||||||||
| ] | ||||||||||||
| .into(), | ||||||||||||
| vec![OpenSearchKeystore { | ||||||||||||
| key: "Keystore1".to_string(), | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||||||||
| secret_key_ref: SecretKeyRef { | ||||||||||||
| name: SecretName::from_str_unsafe("my-keystore-secret"), | ||||||||||||
| key: SecretKey::from_str_unsafe("my-keystore-file"), | ||||||||||||
| }, | ||||||||||||
| }], | ||||||||||||
| ) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -77,11 +77,14 @@ mod tests { | |||||||||||
| ContextNames, OpenSearchNodeResources, OpenSearchRoleGroupConfig, ValidatedCluster, | ||||||||||||
| ValidatedContainerLogConfigChoice, ValidatedLogging, ValidatedOpenSearchConfig, | ||||||||||||
| }, | ||||||||||||
| crd::{NodeRoles, v1alpha1}, | ||||||||||||
| crd::{ | ||||||||||||
| NodeRoles, | ||||||||||||
| v1alpha1::{self, OpenSearchKeystore, SecretKeyRef}, | ||||||||||||
| }, | ||||||||||||
|
Comment on lines
+80
to
+83
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| framework::{ | ||||||||||||
| ClusterName, ControllerName, ListenerClassName, NamespaceName, OperatorName, | ||||||||||||
| ProductName, ProductVersion, RoleGroupName, builder::pod::container::EnvVarSet, | ||||||||||||
| role_utils::GenericProductSpecificCommonConfig, | ||||||||||||
| ProductName, ProductVersion, RoleGroupName, SecretKey, SecretName, | ||||||||||||
| builder::pod::container::EnvVarSet, role_utils::GenericProductSpecificCommonConfig, | ||||||||||||
| }, | ||||||||||||
| }; | ||||||||||||
|
|
||||||||||||
|
|
@@ -191,6 +194,13 @@ mod tests { | |||||||||||
| ), | ||||||||||||
| ] | ||||||||||||
| .into(), | ||||||||||||
| vec![OpenSearchKeystore { | ||||||||||||
| key: "Keystore1".to_string(), | ||||||||||||
| secret_key_ref: SecretKeyRef { | ||||||||||||
| name: SecretName::from_str_unsafe("my-keystore-secret"), | ||||||||||||
| key: SecretKey::from_str_unsafe("my-keystore-file"), | ||||||||||||
| }, | ||||||||||||
| }], | ||||||||||||
| ) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.