diff --git a/README.md b/README.md index 501a20f..b4cb2f6 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,17 @@ Kubernetes Cloud Plugin for Elasticsearch: The Kubernetes Cloud plugin allows to use Kubernetes API for the unicast discovery mechanism. -## Version 1.0.x for Elasticsearch: 1.4 -## Version 1.1.x/1.2.x for Elasticsearch: 1.5 -## Version 1.3.x for Elasticsearch: 1.6 - Installation ============ ``` -plugin install io.fabric8/elasticsearch-cloud-kubernetes/1.2.1 +plugin install io.fabric8/elasticsearch-cloud-kubernetes/1.7.6 ``` +Versions available +================== + +* `1.7.6` for Elasticsearch `1.7.6` + Kubernetes Pod Discovery =============================== @@ -22,11 +23,14 @@ Kubernetes Pod discovery allows to use the kubernetes APIs to perform automatic Here is a simple sample configuration: ```yaml +discovery: + cloud: k8s: servicedns: ${SERVICE_DNS} -discovery: - type: io.fabric8.elasticsearch.discovery.k8s.K8sDiscoveryModule + +discovery: + type: io.fabric8.elasticsearch.discovery.k8s.K8sDiscoveryModule path: data: /data/data @@ -35,19 +39,6 @@ path: work: /data/work ``` -If you want to use Kubernetes service endpoints instead (remember this will require auth to the -Kubernetes API server if you do this), then use: - -``` -service: ${SERVICE} -namespace: ${NAMESPACE} -``` - -Depending on which once you choose, you can then either: - -* Set the `SERVICE` & `NAMESPACE` environment variables to specify the service to discover endpoints for, e.g. `elasticsearch-cluster`. -* Set the `SERVICE_DNS` environment variable to specify the service name to look up endpoints for in DNS, e.g. `elasticsearch-cluster`. - ## Kubernetes auth The preferred way to authenticate to Kubernetes is to use [service accounts](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/design/service_accounts.md). @@ -57,7 +48,7 @@ As an example, to create a service account do something like: ``` cat < spec: - serviceAccount: elasticsearch + serviceAccountName: elasticsearch ``` This will mount the service account token at `/var/run/secrets/kubernetes.io/servicaccount/token` & will be automatically read by the fabric8 kubernetes client when the request is made to the API server. -There are also a number of different environment variables that you may find useful: - -. `KUBERNETES_TRUST_CERT=false`: disable certificate validation. Set to true to trust the Kubernetes API server certificate. -. `KUBECONFIG`: path to a standard Kubernetes config file to use for authentication configuration. - # Kubernetes example -In this example, we're going to use `servicedns` to look up the Elasticsearch cluster nodes to join. +In this example, we're going to use a headle service to look up the Elasticsearch cluster nodes to join. The following manifest uses 3 replication controllers to created Elasticsearch pods in 3 different modes: @@ -101,218 +87,236 @@ We use 2 services as well: * One to target the client pods so that all requests to the cluster go through the client nodes * A headless service to list all cluster endpoints managed by all 3 RCs. -The DNS lookup is on the headless service name so that all existing nodes from the cluster are discovered on startup & the cluster is joined. +```yaml +kind: "List" +apiVersion: "v1" +items: +- apiVersion: "v1" + kind: "Service" + metadata: + name: "elasticsearch" + spec: + ports: + - port: 9200 + targetPort: "http" + selector: + component: "elasticsearch" + type: "client" + provider: "fabric8" + type: "LoadBalancer" +- apiVersion: "v1" + kind: "Service" + metadata: + name: "elasticsearch-cluster" + spec: + clusterIP: "None" + ports: + - port: 9300 + targetPort: 9300 + selector: + provider: "fabric8" + component: "elasticsearch" +- apiVersion: "v1" + kind: "ReplicationController" + metadata: + name: "elasticsearch-data" + spec: + replicas: 1 + selector: + component: "elasticsearch" + type: "data" + provider: "fabric8" + template: + metadata: + labels: + component: "elasticsearch" + type: "data" + provider: "fabric8" + spec: + serviceAccount: elasticsearch + serviceAccountName: elasticsearch + containers: + - env: + - name: "SERVICE" + value: "elasticsearch-cluster" + - name: "KUBERNETES_NAMESPACE" + valueFrom: + fieldRef: + fieldPath: "metadata.namespace" + - name: "NODE_MASTER" + value: "false" + image: "fabric8/elasticsearch-k8s:2.4.0" + name: "elasticsearch" + ports: + - containerPort: 9300 + name: "transport" + volumeMounts: + - mountPath: "/usr/share/elasticsearch/data" + name: "elasticsearch-data" + readOnly: false + volumes: + - emptyDir: + medium: "" + name: "elasticsearch-data" +- apiVersion: "v1" + kind: "ReplicationController" + metadata: + name: "elasticsearch-master" + spec: + replicas: 1 + selector: + component: "elasticsearch" + type: "master" + provider: "fabric8" + template: + metadata: + labels: + component: "elasticsearch" + type: "master" + provider: "fabric8" + spec: + serviceAccount: elasticsearch +kind: "List" +apiVersion: "v1" +items: + +- apiVersion: v1 + kind: ServiceAccount + metadata: + name: elasticsearch + +- apiVersion: "v1" + kind: "Service" + metadata: + name: "elasticsearch" + spec: + type: "LoadBalancer" + selector: + component: "elasticsearch" + type: "client" + provider: "fabric8" + ports: + - name: http + port: 9200 + protocol: TCP + - name: transport + port: 9300 + protocol: TCP + loadBalancerSourceRanges: + - 10.0.0.0/8 -```json -{ - "id": "elasticsearch-list", - "kind": "List", - "apiVersion": "v1beta2", - "name": "elasticsearch-config", - "description": "Configuration for elasticsearch", - "items": [ - { - "id": "elasticsearch", - "apiVersion": "v1beta1", - "kind": "Service", - "containerPort": 9200, - "port": 9200, - "selector": { - "component": "elasticsearch", - "type": "client", - "provider": "fabric8" - } - }, - { - "id": "elasticsearch-cluster", - "apiVersion": "v1beta1", - "PortalIP": "None", - "kind": "Service", - "containerPort": 9300, - "port": 9300, - "selector": { - "component": "elasticsearch", - "provider": "fabric8" - } - }, - { - "id": "elasticsearch-client-rc", - "kind": "ReplicationController", - "apiVersion": "v1beta1", - "desiredState": { - "replicas": 1, - "replicaSelector": { - "component": "elasticsearch", - "type": "client", - "provider": "fabric8" - }, - "podTemplate": { - "desiredState": { - "manifest": { - "version": "v1beta1", - "id": "elasticsearchPod", - "containers": [ - { - "name": "elasticsearch-container", - "image": "fabric8/elasticsearch-k8s:1.5.0", - "imagePullPolicy": "PullIfNotPresent", - "env": [ - { - "name": "SERVICE_DNS", - "value": "elasticsearch-cluster" - }, - { - "name": "KUBERNETES_TRUST_CERT", - "value": "true" - }, - { - "name": "NODE_DATA", - "value": "false" - }, - { - "name": "NODE_MASTER", - "value": "false" - } - ], - "ports": [ - { - "containerPort": 9200 - }, - { - "containerPort": 9300 - } - ] - } - ] - } - }, - "labels": { - "component": "elasticsearch", - "type": "client", - "provider": "fabric8" - } - } - }, - "labels": { - "component": "elasticsearch", - "type": "client", - "provider": "fabric8" - } - }, - { - "id": "elasticsearch-data-rc", - "kind": "ReplicationController", - "apiVersion": "v1beta1", - "desiredState": { - "replicas": 1, - "replicaSelector": { - "component": "elasticsearch", - "type": "data", - "provider": "fabric8" - }, - "podTemplate": { - "desiredState": { - "manifest": { - "version": "v1beta1", - "id": "elasticsearchPod", - "containers": [ - { - "name": "elasticsearch-container", - "image": "fabric8/elasticsearch-k8s:1.5.0", - "imagePullPolicy": "PullIfNotPresent", - "env": [ - { - "name": "SERVICE_DNS", - "value": "elasticsearch-cluster" - }, - { - "name": "KUBERNETES_TRUST_CERT", - "value": "true" - }, - { - "name": "NODE_MASTER", - "value": "false" - } - ], - "ports": [ - { - "containerPort": 9300 - } - ] - } - ] - } - }, - "labels": { - "component": "elasticsearch", - "type": "data", - "provider": "fabric8" - } - } - }, - "labels": { - "component": "elasticsearch", - "type": "data", - "provider": "fabric8" - } - }, - { - "id": "elasticsearch-master-rc", - "kind": "ReplicationController", - "apiVersion": "v1beta1", - "desiredState": { - "replicas": 1, - "replicaSelector": { - "component": "elasticsearch", - "type": "master", - "provider": "fabric8" - }, - "podTemplate": { - "desiredState": { - "manifest": { - "version": "v1beta1", - "id": "elasticsearchPod", - "containers": [ - { - "name": "elasticsearch-container", - "image": "fabric8/elasticsearch-k8s:1.5.0", - "imagePullPolicy": "PullIfNotPresent", - "env": [ - { - "name": "SERVICE_DNS", - "value": "elasticsearch-cluster" - }, - { - "name": "KUBERNETES_TRUST_CERT", - "value": "true" - }, - { - "name": "NODE_DATA", - "value": "false" - } - ], - "ports": [ - { - "containerPort": 9300 - } - ] - } - ] - } - }, - "labels": { - "component": "elasticsearch", - "type": "master", - "provider": "fabric8" - } - } - }, - "labels": { - "component": "elasticsearch", - "type": "master", - "provider": "fabric8" - } - } - ] -} +- apiVersion: "v1" + kind: "Service" + metadata: + name: "elasticsearch-cluster" + spec: + clusterIP: "None" + ports: + - port: 9300 + targetPort: 9300 + selector: + provider: "fabric8" + component: "elasticsearch" +- apiVersion: "v1" + kind: "ReplicationController" + metadata: + name: "elasticsearch-data" + spec: + replicas: 1 + selector: + component: "elasticsearch" + type: "data" + provider: "fabric8" + template: + metadata: + labels: + component: "elasticsearch" + type: "data" + provider: "fabric8" + spec: + serviceAccount: elasticsearch + serviceAccountName: elasticsearch + containers: + - env: + - name: "SERVICE_DNS" + value: "elasticsearch-cluster" + - name: "NODE_MASTER" + value: "false" + image: "fabric8/elasticsearch-k8s:1.7.6" + name: "elasticsearch" + ports: + - containerPort: 9300 + name: "transport" + volumeMounts: + - mountPath: "/usr/share/elasticsearch/data" + name: "elasticsearch-data" + readOnly: false + volumes: + - emptyDir: + medium: "" + name: "elasticsearch-data" +- apiVersion: "v1" + kind: "ReplicationController" + metadata: + name: "elasticsearch-master" + spec: + replicas: 1 + selector: + component: "elasticsearch" + type: "master" + provider: "fabric8" + template: + metadata: + labels: + component: "elasticsearch" + type: "master" + provider: "fabric8" + spec: + serviceAccount: elasticsearch + serviceAccountName: elasticsearch + containers: + - env: + - name: "SERVICE_DNS" + value: "elasticsearch-cluster" + - name: "NODE_DATA" + value: "false" + image: "fabric8/elasticsearch-k8s:1.7.6" + name: "elasticsearch" + ports: + - containerPort: 9300 + name: "transport" +- apiVersion: "v1" + kind: "ReplicationController" + metadata: + name: "elasticsearch-client" + spec: + replicas: 1 + selector: + component: "elasticsearch" + type: "client" + provider: "fabric8" + template: + metadata: + labels: + component: "elasticsearch" + type: "client" + provider: "fabric8" + spec: + serviceAccount: elasticsearch + serviceAccountName: elasticsearch + containers: + - env: + - name: "SERVICE_DNS" + value: "elasticsearch-cluster" + - name: "NODE_DATA" + value: "false" + - name: "NODE_MASTER" + value: "false" + image: "fabric8/elasticsearch-k8s:1.7.6" + name: "elasticsearch" + ports: + - containerPort: 9200 + name: "http" + - containerPort: 9300 + name: "transport" ``` diff --git a/elasticsearch.yml b/elasticsearch.yml index 13d4675..ec911fe 100644 --- a/elasticsearch.yml +++ b/elasticsearch.yml @@ -1,6 +1,24 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + node.data: ${NODE_DATA} node.master: ${NODE_MASTER} +network.host: 0.0.0.0 + cloud: k8s: servicedns: ${SERVICE_DNS} diff --git a/header.txt b/header.txt new file mode 100644 index 0000000..12de4d4 --- /dev/null +++ b/header.txt @@ -0,0 +1,13 @@ +Copyright (C) ${project.inceptionYear} ${owner} + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/kubernetes.yml b/kubernetes.yml new file mode 100644 index 0000000..4dc02fb --- /dev/null +++ b/kubernetes.yml @@ -0,0 +1,141 @@ +kind: "List" +apiVersion: "v1" +items: + +- apiVersion: v1 + kind: ServiceAccount + metadata: + name: elasticsearch + +- apiVersion: "v1" + kind: "Service" + metadata: + name: "elasticsearch" + spec: + type: "LoadBalancer" + selector: + component: "elasticsearch" + type: "client" + provider: "fabric8" + ports: + - name: http + port: 9200 + protocol: TCP + - name: transport + port: 9300 + protocol: TCP + +- apiVersion: "v1" + kind: "Service" + metadata: + name: "elasticsearch-cluster" + spec: + clusterIP: "None" + ports: + - port: 9300 + targetPort: 9300 + selector: + provider: "fabric8" + component: "elasticsearch" +- apiVersion: "v1" + kind: "ReplicationController" + metadata: + name: "elasticsearch-data" + spec: + replicas: 1 + selector: + component: "elasticsearch" + type: "data" + provider: "fabric8" + template: + metadata: + labels: + component: "elasticsearch" + type: "data" + provider: "fabric8" + spec: + serviceAccount: elasticsearch + serviceAccountName: elasticsearch + containers: + - env: + - name: "SERVICE_DNS" + value: "elasticsearch-cluster" + - name: "NODE_MASTER" + value: "false" + image: "fabric8/elasticsearch-k8s:1.7.6" + name: "elasticsearch" + ports: + - containerPort: 9300 + name: "transport" + volumeMounts: + - mountPath: "/usr/share/elasticsearch/data" + name: "elasticsearch-data" + readOnly: false + volumes: + - emptyDir: + medium: "" + name: "elasticsearch-data" +- apiVersion: "v1" + kind: "ReplicationController" + metadata: + name: "elasticsearch-master" + spec: + replicas: 1 + selector: + component: "elasticsearch" + type: "master" + provider: "fabric8" + template: + metadata: + labels: + component: "elasticsearch" + type: "master" + provider: "fabric8" + spec: + serviceAccount: elasticsearch + serviceAccountName: elasticsearch + containers: + - env: + - name: "SERVICE_DNS" + value: "elasticsearch-cluster" + - name: "NODE_DATA" + value: "false" + image: "fabric8/elasticsearch-k8s:1.7.6" + name: "elasticsearch" + ports: + - containerPort: 9300 + name: "transport" +- apiVersion: "v1" + kind: "ReplicationController" + metadata: + name: "elasticsearch-client" + spec: + replicas: 1 + selector: + component: "elasticsearch" + type: "client" + provider: "fabric8" + template: + metadata: + labels: + component: "elasticsearch" + type: "client" + provider: "fabric8" + spec: + serviceAccount: elasticsearch + serviceAccountName: elasticsearch + containers: + - env: + - name: "SERVICE_DNS" + value: "elasticsearch-cluster" + - name: "NODE_DATA" + value: "false" + - name: "NODE_MASTER" + value: "false" + image: "fabric8/elasticsearch-k8s:1.7.6" + name: "elasticsearch" + ports: + - containerPort: 9200 + name: "http" + - containerPort: 9300 + name: "transport" diff --git a/pom.xml b/pom.xml index b3aba40..60e974e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,358 +1,306 @@ - + + + 4.0.0 + io.fabric8 + elasticsearch-cloud-kubernetes + 1.7.6-SNAPSHOT - - 1.6.0 - 2.2.4 - 4.10.4 - true - onerror - - 9300 - INFO - ${project.build.testOutputDirectory}/elasticsearch.yml - + Elasticsearch Kubernetes cloud plugin + The Kubernetes Cloud plugin allows to use Kubernetes for the unicast discovery mechanism. + https://github.com/jimmidyson/elasticsearch-cloud-kubernetes/ + 2015 - - - org.hamcrest - hamcrest-core - 1.3.RC2 - test - - - org.hamcrest - hamcrest-library - 1.3.RC2 - test - + + org.sonatype.oss + oss-parent + 9 + - - org.apache.lucene - lucene-test-framework - ${lucene.version} - test - + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + scm:git:git@github.com:fabric8io/elasticsearch-cloud-kubernetes.git + scm:git:git@github.com:fabric8io/elasticsearch-cloud-kubernetes.git + http://github.com/fabric8io/elasticsearch-cloud-kubernetes + - - - org.elasticsearch - elasticsearch - ${elasticsearch.version} - + + GitHub + https://github.com/fabric8io/elasticsearch-cloud-kubernetes/issues/ + - - - io.fabric8 - kubernetes-api - ${fabric8.version} - + + 2.2.4 + cloud-kubernetes + 1.7.6 + 1.3.83 + 5.5.2 + true + onerror + + 9300 + INFO + ${project.build.testOutputDirectory}/elasticsearch.yml + - - - org.slf4j - slf4j-log4j12 - 1.7.7 - + + + junit + junit + 4.12 + + + org.hamcrest + hamcrest-core + 1.3.RC2 + test + + + org.hamcrest + hamcrest-library + 1.3.RC2 + test + - - - log4j - log4j - 1.2.17 - test - + + org.apache.lucene + lucene-test-framework + ${lucene.version} + test + - - org.elasticsearch - elasticsearch - ${elasticsearch.version} - test-jar - test - + + + org.elasticsearch + elasticsearch + ${elasticsearch.version} + - + + + com.fasterxml.jackson.core + jackson-databind + 2.5.3 + - - - - org.kuali.maven.wagons - maven-s3-wagon - 1.1.19 - - + + + io.fabric8 + kubernetes-api + ${fabric8.version} + - - - src/main/resources - true - - - - - src/test/resources - true - - plugin-test.properties - elasticsearch.yml - - - - src/test/resources - false - - log4j.xml - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - - - - com.carrotsearch.randomizedtesting - junit4-maven-plugin - 2.0.14 - - - tests - test - - junit4 - - - 20 - pipe,warn - true - - - - - - - - - 1 - - - - - - - **/*Tests.class - **/*Test.class - - - **/Abstract*.class - **/*StressTest.class - - - ${tests.jvm.argline} - - - -Xmx512m - -Xss256k - -XX:MaxDirectMemorySize=512m - -Des.logger.prefix= - - ${tests.shuffle} - ${tests.verbose} - ${tests.seed} - ${tests.failfast} - - - ${tests.jvm.argline} - ${tests.iters} - ${tests.maxfailures} - ${tests.failfast} - ${tests.class} - ${tests.method} - ${tests.nightly} - ${tests.badapples} - ${tests.weekly} - ${tests.slow} - ${tests.k8s} - ${tests.config} - ${tests.awaitsfix} - ${tests.slow} - ${tests.timeoutSuite} - ${tests.showSuccess} - ${tests.integration} - ${tests.cluster_seed} - ${tests.client.ratio} - false - network - ${es.logger.level} - true - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.15 - - true - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar - - - - - - maven-assembly-plugin - 2.4 - - false - ${project.build.directory}/releases/ - - ${basedir}/src/main/assemblies/plugin.xml - - - - - package - - single - - - - - - org.jolokia - docker-maven-plugin - 0.12.0 - - - - docker.io/fabric8/elasticsearch-k8s:${elasticsearch.version} - - elasticsearch:${elasticsearch.version} - - ${basedir}/src/main/assemblies/docker-image.xml - /usr/share/elasticsearch/ - - - true - true - - - - - - - - org.apache.maven.plugins - maven-release-plugin - 2.5 - - docker-push - - - - - - - docker-push - + + + io.fabric8 + kubernetes-client + ${kubernetes-client.version} + + + + + org.slf4j + slf4j-log4j12 + 1.7.7 + + + + + log4j + log4j + 1.2.17 + test + + + + org.elasticsearch + elasticsearch + ${elasticsearch.version} + test-jar + test + + + + + + + + org.kuali.maven.wagons + maven-s3-wagon + 1.1.19 + + + + + + src/main/plugin-metadata + true + + + + + src/test/resources + true + + plugin-test.properties + elasticsearch.yml + + + + src/test/resources + false + + log4j.xml + + + - - org.jolokia - docker-maven-plugin - - - - build - - package - - - - - org.codehaus.mojo - exec-maven-plugin - 1.4.0 - - - - exec - - package - - - - docker - - push - -f - docker.io/fabric8/elasticsearch-k8s:${elasticsearch.version} - - - + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.15 + + true + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar + + + + + + maven-assembly-plugin + 2.4 + + false + ${project.build.directory}/releases/ + + ${basedir}/src/main/assemblies/plugin.xml + + + + + package + + single + + + + + + io.fabric8 + docker-maven-plugin + 0.15.7 + + + + fabric8/elasticsearch:${elasticsearch.version} + + ${project.basedir}/src/main/docker + + + + fabric8/elasticsearch-k8s:${elasticsearch.version} + + fabric8/elasticsearch:${elasticsearch.version} + + ${basedir}/src/main/assemblies/docker-image.xml + /usr/share/elasticsearch/ + + + true + true + -Djava.net.preferIPv4Stack=true + + + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5 + + docker-deploy + deploy docker:build docker:push + + + + com.mycila + license-maven-plugin + 2.11 + + true +
header.txt
+ + Red Hat, Inc. + + + .editorconfig + license.txt + +
+
-
- - + + + + + docker-build + + clean install docker:build + + + + docker-deploy + + clean install docker:build docker:push + + +
diff --git a/resources/es-plugin.properties b/resources/es-plugin.properties new file mode 100644 index 0000000..028a92e --- /dev/null +++ b/resources/es-plugin.properties @@ -0,0 +1,2 @@ +plugin=io.fabric8.elasticsearch.plugin.cloud.k8s.CloudK8sPlugin +version=${project.version} diff --git a/src/main/assemblies/plugin.xml b/src/main/assemblies/plugin.xml index 634831c..a290915 100644 --- a/src/main/assemblies/plugin.xml +++ b/src/main/assemblies/plugin.xml @@ -1,21 +1,39 @@ - + plugin zip false + + + ${basedir}/src/main/plugin-metadata/plugin-security.policy + + false + + + ${basedir}/src/main/plugin-metadata/plugin-descriptor.properties + + true + + / diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile new file mode 100644 index 0000000..d343e28 --- /dev/null +++ b/src/main/docker/Dockerfile @@ -0,0 +1 @@ +FROM elasticsearch:1.7.6 \ No newline at end of file diff --git a/src/main/docker/config/elasticsearch.yml b/src/main/docker/config/elasticsearch.yml new file mode 100644 index 0000000..2644bc7 --- /dev/null +++ b/src/main/docker/config/elasticsearch.yml @@ -0,0 +1,17 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +network.host: 0.0.0.0 diff --git a/src/main/docker/config/logging.yml b/src/main/docker/config/logging.yml new file mode 100644 index 0000000..3046ddb --- /dev/null +++ b/src/main/docker/config/logging.yml @@ -0,0 +1,31 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# you can override this using by setting a system property, for example -Des.logger.level=DEBUG +es.logger.level: INFO +rootLogger: ${es.logger.level}, console +logger: + # log action execution errors for easier debugging + action: DEBUG + # reduce the logging for aws, too much is logged under the default INFO + com.amazonaws: WARN + +appender: + console: + type: console + layout: + type: consolePattern + conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" diff --git a/src/main/java/io/fabric8/elasticsearch/discovery/k8s/K8sUnicastHostsProvider.java b/src/main/java/io/fabric8/elasticsearch/discovery/k8s/K8sUnicastHostsProvider.java index 1cba70a..26b41ba 100644 --- a/src/main/java/io/fabric8/elasticsearch/discovery/k8s/K8sUnicastHostsProvider.java +++ b/src/main/java/io/fabric8/elasticsearch/discovery/k8s/K8sUnicastHostsProvider.java @@ -51,8 +51,8 @@ static final public class Fields { @Inject public K8sUnicastHostsProvider(Settings settings, - TransportService transportService, - NetworkService networkService) { + TransportService transportService, + NetworkService networkService) { super(settings); this.transportService = transportService; this.networkService = networkService; diff --git a/src/main/plugin-metadata/plugin-descriptor.properties b/src/main/plugin-metadata/plugin-descriptor.properties new file mode 100644 index 0000000..c0ac594 --- /dev/null +++ b/src/main/plugin-metadata/plugin-descriptor.properties @@ -0,0 +1,23 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name=${elasticsearch.plugin.name} +version=${project.version} +jvm=true +classname=io.fabric8.elasticsearch.plugin.discovery.kubernetes.KubernetesDiscoveryPlugin +description=${project.name} +elasticsearch.version=${elasticsearch.version} +java.version=1.8 diff --git a/src/main/plugin-metadata/plugin-security.policy b/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 0000000..f57cea6 --- /dev/null +++ b/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +grant { + permission java.lang.RuntimePermission "accessDeclaredMembers"; + permission java.lang.RuntimePermission "setFactory"; + permission java.lang.reflect.ReflectPermission "suppressAccessChecksv"; + permission java.io.FilePermission "<>", "read,execute,readlink"; + permission java.net.NetPermission "getProxySelector"; + permission java.net.NetPermission "getCookieHandler"; +}; diff --git a/src/test/java/io/fabric8/cloud/k8s/AbstractK8sTest.java b/src/test/java/io/fabric8/cloud/k8s/AbstractK8sTest.java index ee1f061..352d9f9 100644 --- a/src/test/java/io/fabric8/cloud/k8s/AbstractK8sTest.java +++ b/src/test/java/io/fabric8/cloud/k8s/AbstractK8sTest.java @@ -8,6 +8,7 @@ import org.elasticsearch.env.FailedToResolveConfigException; import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.test.ElasticsearchIntegrationTest; +import org.junit.Assert; import java.lang.annotation.Documented; import java.lang.annotation.Inherited; @@ -23,7 +24,7 @@ public abstract class AbstractK8sTest extends ElasticsearchIntegrationTest { * Annotation for tests that require GCE to run. GCE tests are disabled by default. * See README file for details. */ - @Documented + @Documented @Inherited @Retention(RetentionPolicy.RUNTIME) @TestGroup(enabled = false, sysProperty = SYSPROP_K8S) @@ -47,10 +48,10 @@ protected Settings nodeSettings(int nodeOrdinal) { if (Strings.hasText(System.getProperty("tests.config"))) { settings.loadFromUrl(environment.resolveConfig(System.getProperty("tests.config"))); } else { - fail("to run integration tests, you need to set -Dtest.k8s=true and -Dtests.config=/path/to/elasticsearch.yml"); + Assert.fail("to run integration tests, you need to set -Dtest.k8s=true and -Dtests.config=/path/to/elasticsearch.yml"); } } catch (FailedToResolveConfigException exception) { - fail("your test configuration file is incorrect: " + System.getProperty("tests.config")); + Assert.fail("your test configuration file is incorrect: " + System.getProperty("tests.config")); } return settings.build(); } diff --git a/src/test/java/io/fabric8/k8s/itest/K8sSimpleITest.java b/src/test/java/io/fabric8/k8s/itest/K8sSimpleITest.java index ad4763b..6e2a3f6 100644 --- a/src/test/java/io/fabric8/k8s/itest/K8sSimpleITest.java +++ b/src/test/java/io/fabric8/k8s/itest/K8sSimpleITest.java @@ -7,6 +7,7 @@ import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.hamcrest.Matchers; +import org.junit.Assert; import org.junit.Test; @AbstractK8sTest.K8sTest @@ -32,7 +33,7 @@ public void one_node_should_run() { System.out.println(clusterState.getState().getNodes().getSize()); - assertThat(clusterState.getState().getNodes().getSize(), Matchers.greaterThanOrEqualTo(2)); + Assert.assertThat(clusterState.getState().getNodes().getSize(), Matchers.greaterThanOrEqualTo(2)); } @Override