Skip to content
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

Introduce Elasticsearch config and additional secret mounts to stack config policy #7233

Merged
merged 36 commits into from
Nov 15, 2023

Conversation

kvalliyurnatt
Copy link
Contributor

@kvalliyurnatt kvalliyurnatt commented Oct 13, 2023

This PR introduces two new fields to the stack config policy, under Elasticsearch

  1. Config: untyped yaml settings that will go into elasticsearch.yml
  2. SecretMounts: Additional secrets that need to be mounted into the Elasticsearch Pod.

These changes are part of an effort to allow users to configure Authentication policies through the Stack configuration.

This PR does the following.

StackConfigPolicy controller:

  • Reads the Elasticsearch Config and SecretMounts from the StackConfigPolicy CR
  • Validates that the secrets mentioned in the SecretMounts actually exist
  • Marshals the Config and SecretMounts and creates a new secret in the Elasticsearch cluster namespace
  • Replicates the Secrets in the SecretMounts to the Elasticsearch cluster namespace, so that the secrets can actually be mounted into Elasticsearch Pod

Elasticsearch controller:

  • Reads the secret create by the StackConfigPolicy controller which contains the Elasticsearch config and secret mounts
  • Merges the Elasticsearch config to the elasticsearch.yml that the controller creates
  • Adds the secrets from secretMounts as volume mounts to the Elasticsearch Pods.

Tasks pending:

  • Clean up code and remove redundant code
  • Add unit tests
  • Test complex scenarios with different Elasticsearch cluster configurations

@kvalliyurnatt kvalliyurnatt added >feature Adds or discusses adding a feature to the product v2.10.0 labels Oct 13, 2023
@barkbay barkbay changed the title [WIP] Intorduce Elasticsearch config and additional secret mounts to stack config policy [WIP] Introduce Elasticsearch config and additional secret mounts to stack config policy Oct 16, 2023
pkg/controller/stackconfigpolicy/controller.go Outdated Show resolved Hide resolved
pkg/controller/stackconfigpolicy/controller.go Outdated Show resolved Hide resolved
pkg/controller/stackconfigpolicy/controller.go Outdated Show resolved Hide resolved
pkg/controller/stackconfigpolicy/controller.go Outdated Show resolved Hide resolved
pkg/apis/elasticsearch/v1/name.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/resources.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/resources.go Outdated Show resolved Hide resolved
@rhr323 rhr323 added v2.11.0 and removed v2.10.0 labels Oct 23, 2023
@kvalliyurnatt kvalliyurnatt changed the title [WIP] Introduce Elasticsearch config and additional secret mounts to stack config policy Introduce Elasticsearch config and additional secret mounts to stack config policy Oct 24, 2023
@kvalliyurnatt kvalliyurnatt marked this pull request as ready for review October 24, 2023 23:23
pkg/apis/elasticsearch/v1/name.go Outdated Show resolved Hide resolved
pkg/apis/elasticsearch/v1/name.go Outdated Show resolved Hide resolved
Co-authored-by: Thibault Richard <thbkrkr@users.noreply.github.com>
kvalliyurnatt and others added 2 commits November 7, 2023 18:20
Co-authored-by: Thibault Richard <thbkrkr@users.noreply.github.com>
pkg/apis/elasticsearch/v1/name.go Show resolved Hide resolved
pkg/controller/common/labels/labels.go Outdated Show resolved Hide resolved
pkg/controller/stackconfigpolicy/controller.go Outdated Show resolved Hide resolved
pkg/controller/common/labels/labels.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/policy_config.go Outdated Show resolved Hide resolved
}

// reconcileSecretMounts creates the secrets in SecretMounts to the respective Elasticsearch namespace where they should be mounted to.
func reconcileSecretMounts(ctx context.Context, c k8s.Client, es esv1.Elasticsearch, policy *policyv1alpha1.StackConfigPolicy) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand if Secrets which are no longer referenced in a policy are deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently if a secret is removed from a stack config policy, that secret gets left behind(it is deleted only when the stack config policy itself is deleted or the elasticsearch cluster is). I was going to address this in a separate PR, as even today we don't reset a secret that is no longer referenced in the stackconfig policy I believe.

kvalliyurnatt and others added 2 commits November 8, 2023 09:24
Co-authored-by: Michael Morello <michael.morello@gmail.com>
Copy link
Collaborator

@pebrc pebrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a few nits.

pkg/apis/elasticsearch/v1/name.go Outdated Show resolved Hide resolved
pkg/controller/stackconfigpolicy/controller_test.go Outdated Show resolved Hide resolved
pkg/controller/stackconfigpolicy/controller_test.go Outdated Show resolved Hide resolved
kvalliyurnatt and others added 3 commits November 13, 2023 09:48
Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>
@kvalliyurnatt
Copy link
Contributor Author

buildkite test this -f p=gke

@kvalliyurnatt kvalliyurnatt enabled auto-merge (squash) November 14, 2023 22:15
@kvalliyurnatt kvalliyurnatt merged commit 20f0467 into elastic:main Nov 15, 2023
5 checks passed
robbavey pushed a commit to robbavey/cloud-on-k8s that referenced this pull request Dec 20, 2023
…config policy (elastic#7233)

Introduce two new fields in StackConfigPolicy, ElasticsearchConfig and SecretMounts. The ElasticsearchConfig field can be used to add configurations for the Elasticsearch clusters managed by the StackConfigurationPolicy, these configurations typically go into the elasticsearch.yml file.SecretMounts are used add additional secrets that need to be mounted into the Elasticsearch pods.

---------

Co-authored-by: Michael Morello <michael.morello@gmail.com>
Co-authored-by: Thibault Richard <thbkrkr@users.noreply.github.com>
Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>feature Adds or discusses adding a feature to the product v2.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants