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

Add support for keystore with Kibana 7.9.0 #3566

Merged

Conversation

barkbay
Copy link
Contributor

@barkbay barkbay commented Jul 30, 2020

Starting Kibana 7.9.0 the keystore is located in the configuration directory instead of the data directory.

This PR allows the keystore init container and the Kibana container to share the config directory through an empty directory.

For consistency with what is done with Elasticsearch this PR creates symbolic links from the generated configuration to the shared configuration volume.

Fixes #3528

@barkbay barkbay added >bug Something isn't working v1.2.1 labels Jul 30, 2020
@barkbay
Copy link
Contributor Author

barkbay commented Jul 30, 2020

jenkins test this please

Copy link
Contributor

@sebgl sebgl left a comment

Choose a reason for hiding this comment

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

I'm good with the approach. It's a bit complicated, as already is for Elasticsearch, but I don't see any way around it.
Left a few comments with questions and cosmetic improvements.

pkg/controller/common/volume/shared_volumes.go Outdated Show resolved Hide resolved
pkg/controller/kibana/init_configuration.go Show resolved Hide resolved
pkg/controller/kibana/config_reconcile.go Outdated Show resolved Hide resolved
pkg/controller/kibana/config_reconcile.go Show resolved Hide resolved
InitContainerConfigVolumeMountPath = "/mnt/elastic-internal/kibana-config-local"

InternalConfigVolumeName = "elastic-internal-elasticsearch-config"
InternalConfigVolumeMountPath = "/mnt/elastic-internal/kibana-config"
Copy link
Contributor

Choose a reason for hiding this comment

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

internal is a bit confusing: why is /mnt/elastic-internal/kibana-config "internal" compared to /mnt/elastic-internal/kibana-config-local? Both living in elastic-internal sound like "internal" stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also to be consistent with what is done with Elasticsearch:

    - mountPath: /mnt/elastic-internal/elasticsearch-config
      name: elastic-internal-elasticsearch-config
      readOnly: true
    - mountPath: /usr/share/elasticsearch/config
      name: elastic-internal-elasticsearch-config-local

@@ -23,28 +23,43 @@ import (

// Constants to use for the config files in a Kibana pod.
const (
VolumeName = "config"
VolumeMountPath = "/usr/share/kibana/" + VolumeName
ConfigVolumeName = "elastic-internal-kibana-config-local"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would shared be more explicit than local to express how the volume is shared between init and main container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Naming has been chosen to be consistent with what is done with Elasticsearch:

EsConfigSharedVolume = SharedVolume{
Name: "elastic-internal-elasticsearch-config-local",
InitContainerMountPath: "/mnt/elastic-internal/elasticsearch-config-local",
EsContainerMountPath: esvolume.ConfigVolumeMountPath,
}

I agree that shared would be more explicit but I'm not sure we want to do this refactoring for a patch release ?

@@ -287,6 +251,21 @@ func (d *driver) deploymentParams(kb *kbv1.Kibana) (deployment.Params, error) {
}, nil
}

func (d *driver) buildVolumes(kb *kbv1.Kibana) []commonvolume.VolumeLike {
volumes := []commonvolume.VolumeLike{DataVolume, ConfigSharedVolume, ConfigVolume(*kb)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we mounting ConfigVolume() (if I'm not mistaken: the "raw" config from the secret resource) into the main Kibana container? Isn't it only required for the init container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Secret with the configuration is needed because I eventually decided to create some symbolic links. Even if it is not strictly required for Kibana I think that it is easier to reason about something that is close to what is done with Elasticsearch.

pkg/controller/kibana/keystore.go Outdated Show resolved Hide resolved
InitConfigScript = `#!/usr/bin/env bash
set -eux

init_config_initialized_flag=/usr/share/kibana/config/elastic-internal-init-config.ok
Copy link
Contributor

Choose a reason for hiding this comment

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

is it only to avoid the cost of re-doing ln -sf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to avoid the content of the script to be run twice, I agree it should be safe to remove it here. But I also want to avoid Setup Kibana configuration to be printed several times in the logs. It's harmless indeed, but I think it can be confusing for the user/support to see those messages while the container is already running for a while.

pkg/controller/kibana/init_configuration.go Outdated Show resolved Hide resolved
@@ -2,34 +2,38 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package initcontainer
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice to see the refactoring here 👍

Copy link
Contributor

@charith-elastic charith-elastic left a comment

Choose a reason for hiding this comment

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

LGTM

@barkbay barkbay merged commit 31eb722 into elastic:master Aug 4, 2020
@charith-elastic charith-elastic added >enhancement Enhancement of existing functionality and removed >bug Something isn't working labels Aug 4, 2020
barkbay added a commit to barkbay/cloud-on-k8s that referenced this pull request Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality v1.2.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TestUpdateKibanaSecureSettings is flaky
3 participants