-
Notifications
You must be signed in to change notification settings - Fork 21
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 some settings to specify a remote Openshift cluster URL #111
Conversation
@@ -64,6 +67,9 @@ public OpenshiftRequestContextFactory(final Settings settings, final RequestUtil | |||
ConfigurationSettings.DEFAULT_OPENSHIFT_OPS_PROJECTS); | |||
this.kibanaPrefix = settings.get(ConfigurationSettings.KIBANA_CONFIG_INDEX_NAME, ConfigurationSettings.DEFAULT_USER_PROFILE_PREFIX); | |||
this.kibanaIndexMode = settings.get(ConfigurationSettings.OPENSHIFT_KIBANA_INDEX_MODE, UNIQUE); | |||
this.openshiftMasterUrl = settings.get(ConfigurationSettings.OPENSHIFT_MASTER, ConfigurationSettings.DEFAULT_MASTER); | |||
this.openshiftCaPath = settings.get(ConfigurationSettings.OPENSHIFT_CA_PATH, null); |
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.
What is the default CA path?
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.
There is no default CA path. If this parameter is not set by the user then the CA detected or set by the K8S plugin is not overwritten.
if (openshiftCaPath != null) { | ||
builder.withCaCertFile(openshiftCaPath); | ||
} | ||
|
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.
Are there additional types of Exceptions which can be thrown and need to be handled? e.g. if the user specifies an incorrect openshiftCaPath
will the api throw a FileNotFound
or PermissionDenied
or some other type of exception? I want to make sure e.g. if the user made a typo they can easily identify the problem, or if the user did not set the right file permission, etc.
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.
If the CA path is incorrect the following exception is thrown :
io.fabric8.kubernetes.client.KubernetesClientException: An error has occurred.
at io.fabric8.kubernetes.client.KubernetesClientException.launderThrowable(KubernetesClientException.java:57)
at io.fabric8.kubernetes.client.utils.HttpClientUtils.createHttpClient(HttpClientUtils.java:137)
at io.fabric8.kubernetes.client.BaseClient.<init>(BaseClient.java:41)
at io.fabric8.openshift.client.DefaultOpenShiftClient.<init>(DefaultOpenShiftClient.java:174)
at io.fabric8.openshift.client.DefaultOpenShiftClient.<init>(DefaultOpenShiftClient.java:170)
at io.fabric8.elasticsearch.plugin.OpenshiftClientFactory.create(OpenshiftClientFactory.java:50)
[....]
Caused by: java.io.FileNotFoundException: /tmp/junit2122595593726896985/ca.crt.does_not_exist (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at io.fabric8.kubernetes.client.internal.CertUtils.getInputStreamFromDataOrFile(CertUtils.java:55)
at io.fabric8.kubernetes.client.internal.CertUtils.createTrustStore(CertUtils.java:61)
at io.fabric8.kubernetes.client.internal.SSLUtils.trustManagers(SSLUtils.java:113)
at io.fabric8.kubernetes.client.internal.SSLUtils.trustManagers(SSLUtils.java:107)
at io.fabric8.kubernetes.client.utils.HttpClientUtils.createHttpClient(HttpClientUtils.java:68)
... 29 more
In case of bad permissions :
io.fabric8.kubernetes.client.KubernetesClientException: An error has occurred.
at io.fabric8.kubernetes.client.KubernetesClientException.launderThrowable(KubernetesClientException.java:57)
at io.fabric8.kubernetes.client.utils.HttpClientUtils.createHttpClient(HttpClientUtils.java:137)
at io.fabric8.kubernetes.client.BaseClient.<init>(BaseClient.java:41)
at io.fabric8.openshift.client.DefaultOpenShiftClient.<init>(DefaultOpenShiftClient.java:174)
at io.fabric8.openshift.client.DefaultOpenShiftClient.<init>(DefaultOpenShiftClient.java:170)
at io.fabric8.elasticsearch.plugin.OpenshiftClientFactory.create(OpenshiftClientFactory.java:50)
[...]
Caused by: java.io.FileNotFoundException: /tmp/you_cant_read_it.crt (Permission denied)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at io.fabric8.kubernetes.client.internal.CertUtils.getInputStreamFromDataOrFile(CertUtils.java:55)
at io.fabric8.kubernetes.client.internal.CertUtils.createTrustStore(CertUtils.java:61)
at io.fabric8.kubernetes.client.internal.SSLUtils.trustManagers(SSLUtils.java:113)
at io.fabric8.kubernetes.client.internal.SSLUtils.trustManagers(SSLUtils.java:107)
at io.fabric8.kubernetes.client.utils.HttpClientUtils.createHttpClient(HttpClientUtils.java:68)
... 29 more
Please also add some unit tests for this new feature |
I'm not certain this change is required at all since you can alter all these values using env variables [1]. I would go further in that if we are going to accept these changes to prefer using if checks to build up the config instead of providing defaults and setting them. I think we should prefer the client defaults as we do now instead of redefining them. |
Not sure we can use env variables since the K8S client is already used inside a local Kubernetes cluster. |
I'm working on a new PR that will add some unit tests and preserve the client defaults instead of redefining them : https://github.com/fabric8io/openshift-elasticsearch-plugin/compare/master...barkbay:external_openshift.diff I will update this PR when I have got time to run some e2e integration tests against our clusters. |
@barkbay Please clarify the usecase you have:
This LGTM other then what appears to be an unexpected deployment topology. Please also rebase and squash the commits |
A picture is worth a thousand words ;) |
e135ef0
to
0156dec
Compare
@barkbay FYI, we have been slow to adopt statefulsets due do internal discussions regarding their ability to correctly support the ES usecase. |
@jcantrill Could you tell me a little bit more about the drawbacks of deploying ES with statefulsets ? |
@barkbay, from https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/, the section on "Deployment and Scaling Guarantees":
The StatefulSet should not specify a pod.Spec.TerminationGracePeriodSeconds of 0. This practice is unsafe and strongly discouraged. For further explanation, please refer to force deleting StatefulSet Pods. When the nginx example above is created, three Pods will be deployed in the order web-0, web-1, web-2. web-1 will not be deployed before web-0 is Running and Ready, and web-2 will not be deployed until web-1 is Running and Ready. If web-0 should fail, after web-1 is Running and Ready, but before web-2 is launched, web-2 will not be launched until web-0 is successfully relaunched and becomes Running and Ready. If a user were to scale the deployed example by patching the StatefulSet such that replicas=1, web-2 would be terminated first. web-1 would not be terminated until web-2 is fully shutdown and deleted. If web-0 were to fail after web-2 has been terminated and is completely shutdown, but prior to web-1’s termination, web-1 would not be terminated until web-0 is Running and Ready. Pods are created, terminated in a specific order. Which means, if a given pod fails to come up, of fails to terminate, then we have a problem. How do statefulsets handle the case where we have to apply maintenance to one member out of order? Disk failure, etc.? Do statefulsets allow dynamic scaling? For example For Elasticsearch, how do statefulsets know when it is okay to remove those two pods? When data is properly replicated? How have we told Elasticsearch that the expected cluster size is now 3 instead of 5? |
Pods are created, terminated in a specific order because of the default
With a replica of two and
With
Nothing specific to ES or K8S here. IMHO dropping more than one node at the same time is a very bad idea with any distributed storage system (ES, Cassandra, Zookeeper, Ceph). |
f8fe852
to
c6b98f5
Compare
c6b98f5
to
fc96d27
Compare
Hi, Please, could you have an other look at this PR ? We have to maintain our own build pipeline for this very small patch, we would be glad to have it merged into the plugin source code. Tanks. |
/ok-to-test |
License check failed: run |
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.
minor nits
@@ -25,6 +25,7 @@ | |||
import org.apache.logging.log4j.Logger; | |||
import org.elasticsearch.ElasticsearchException; | |||
import org.elasticsearch.ElasticsearchSecurityException; | |||
import org.elasticsearch.common.inject.Inject; |
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.
remove. DI is manual in lieu of using a library to wire dependencies
@@ -89,6 +89,10 @@ | |||
static final String OPENSHIFT_ACL_ROLE_STRATEGY = "openshift.acl.role_strategy"; | |||
static final String DEFAULT_ACL_ROLE_STRATEGY = "user"; | |||
|
|||
static final String OPENSHIFT_MASTER = "openshift.master"; |
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.
Please set to 'openshift.master.url' to be consistent with the config setting
fc96d27
to
78fc68f
Compare
78fc68f
to
90a6109
Compare
License check failed: run |
90a6109
to
271132c
Compare
Tests failed. |
271132c
to
cdb07a7
Compare
cdb07a7
to
ab1178a
Compare
Tests failed. |
ab1178a
to
529c4c1
Compare
@@ -64,6 +67,15 @@ public PluginSettings(final Settings settings) { | |||
this.opsIndexPatterns = new HashSet<String>(Arrays.asList(settings.getAsArray(OPENSHIFT_KIBANA_OPS_INDEX_PATTERNS, DEFAULT_KIBANA_OPS_INDEX_PATTERNS))); | |||
this.expireInMillis = settings.getAsLong(OPENSHIFT_ACL_EXPIRE_IN_MILLIS, new Long(1000 * 60)); | |||
|
|||
this.masterUrl = settings.get(OPENSHIFT_MASTER); |
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.
settings.get
returns null
if there is no such setting?
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.
yes, this is why the reference is tested at https://github.com/fabric8io/openshift-elasticsearch-plugin/pull/111/files#diff-064e72178bca90921d549aa255acd4b6R197
529c4c1
to
627d18c
Compare
627d18c
to
03168f5
Compare
Do you think that this PR can be merged for the next release ? |
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.
lgtm - @jcantrill what say you?
[merge] |
Merge failed. |
@barkbay please look at the merge test failures. I'm not certain why this would not be caught in the test job |
closed as stale |
Hi,
Our ElasticSearch cluster is hosted on an remote K8S cluster. Therefore we have to be able to set the URL of the Openshift cluster when the plugin want to check the authorizations of a user.
This PR allows you to specify a remote Openshift cluster URL while allowing the Kubernetes plugin to discover the topology of the ElasticSearch cluster the usual way.
I would love to hear your thoughts.
Thanks