-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Enroll additional nodes to cluster #77292
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3ee60ac
wip, no tests
jkakavas 3942411
Error handling and try all addresses in the enrollment token
jkakavas b800f79
Add functionality to enroll to cluster
jkakavas 2fe6523
Merge remote-tracking branch 'origin/master' into enroll-additional-n…
jkakavas 598b4e1
simplify arg parsing
jkakavas b6c2784
Update docs/changelog/77292.yaml
jkakavas 56fb2b8
remove explicit CLI tool
jkakavas 6d61210
update changelog
jkakavas 3930fce
array expanding
jkakavas eaaa797
feedback
jkakavas 74150d2
Merge remote-tracking branch 'origin/master' into enroll-additional-n…
jkakavas 47b12c3
revert changes to startup scripts for now
jkakavas ddcaa8f
Add CLI tool that allows to configure TLS for a node so that it can j…
jkakavas a5322ee
Merge remote-tracking branch 'origin/master' into enroll-additional-n…
jkakavas e70fe6e
fix algorithm identifier
jkakavas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
wip, no tests
- Loading branch information
commit 3ee60acc8e342dd080ebb8470d8ef6e0a08c93b7
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
565 changes: 565 additions & 0 deletions
565
...ecurity/cli/src/main/java/org/elasticsearch/xpack/security/cli/ConfigAdditionalNodes.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...ty/cli/src/test/java/org/elasticsearch/xpack/security/cli/ConfigAdditionalNodesTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.security.cli; | ||
|
||
import com.google.common.jimfs.Configuration; | ||
import com.google.common.jimfs.Jimfs; | ||
|
||
import org.elasticsearch.common.CheckedSupplier; | ||
import org.elasticsearch.common.settings.SecureString; | ||
import org.elasticsearch.core.CheckedFunction; | ||
import org.elasticsearch.core.PathUtilsForTesting; | ||
import org.elasticsearch.core.internal.io.IOUtils; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.xpack.security.tool.CommandLineHttpClient; | ||
import org.elasticsearch.xpack.security.tool.HttpResponse; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
|
||
import java.io.IOException; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.nio.file.FileSystem; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Map; | ||
|
||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Matchers.anyString; | ||
import static org.mockito.Matchers.eq; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class ConfigAdditionalNodesTests extends ESTestCase { | ||
|
||
static FileSystem jimfs; | ||
private Path confDir; | ||
private CommandLineHttpClient client; | ||
|
||
@BeforeClass | ||
public static void setupJimfs() { | ||
Configuration conf = Configuration.unix().toBuilder().setAttributeViews("posix").build(); | ||
jimfs = Jimfs.newFileSystem(conf); | ||
PathUtilsForTesting.installMock(jimfs); | ||
} | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
Path homeDir = jimfs.getPath("eshome"); | ||
IOUtils.rm(homeDir); | ||
confDir = homeDir.resolve("config"); | ||
Files.createDirectories(confDir); | ||
|
||
HttpResponse nodeEnrollResponse = new HttpResponse( | ||
HttpURLConnection.HTTP_OK, | ||
Map.of("status", randomFrom("yellow", "green")) | ||
); | ||
this.client = mock(CommandLineHttpClient.class); | ||
when( | ||
client.execute( | ||
anyString(), | ||
any(URL.class), | ||
anyString(), | ||
any(SecureString.class), | ||
any(CheckedSupplier.class), | ||
any(CheckedFunction.class) | ||
) | ||
).thenReturn(nodeEnrollResponse); | ||
|
||
} | ||
|
||
@AfterClass | ||
public static void closeJimfs() throws IOException { | ||
if (jimfs != null) { | ||
jimfs.close(); | ||
jimfs = null; | ||
} | ||
} | ||
|
||
|
||
} |
12 changes: 12 additions & 0 deletions
12
x-pack/plugin/security/src/main/bin/elasticsearch-enroll-node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
# or more contributor license agreements. Licensed under the Elastic License | ||
# 2.0; you may not use this file except in compliance with the Elastic License | ||
# 2.0. | ||
|
||
ES_MAIN_CLASS=org.elasticsearch.xpack.security.cli.ConfigAdditionalNodes \ | ||
ES_ADDITIONAL_SOURCES="x-pack-env;x-pack-security-env" \ | ||
ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/security-cli \ | ||
"$(dirname "$0")/elasticsearch-cli" \ | ||
"$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.