├── .bashrc ├── .gitignore ├── .travis.yml ├── Dockerfile ├── LICENCE ├── README.md └── build.sh /.bashrc: -------------------------------------------------------------------------------- 1 | PS1="\u@\h: \w> " 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | *.retry 3 | *.pyc 4 | configuration/test 5 | group_vars 6 | .cache/ 7 | .python-version 8 | configuration.egg-info/ 9 | *.class 10 | 11 | plugins/020_btrace/btrace 12 | plugins/020_btrace/test/Start.class 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | services: 4 | - docker 5 | 6 | script: 7 | - ./build.sh build 8 | 9 | before_deploy: 10 | - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" 11 | 12 | deploy: 13 | - provider: script 14 | script: ./build.sh deploy 15 | on: 16 | all_branches: true 17 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:8.1.1911 2 | ARG LAUNCHER_HASH=master 3 | VOLUME /data 4 | RUN groupadd flokkr 5 | RUN yum install epel-release -y && \ 6 | yum -y update && \ 7 | yum install -y jq git \ 8 | java-1.8.0-openjdk-devel \ 9 | java-latest-openjdk-devel \ 10 | python3-pip \ 11 | unzip \ 12 | wget sudo nc which && \ 13 | alternatives --set python /usr/bin/python3 && \ 14 | yum clean all && \ 15 | rm /etc/krb5.conf 16 | RUN pip3 install robotframework robotframework-requests 17 | RUN wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 && chmod +x /usr/bin/dumb-init 18 | RUN echo "%flokkr ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/flokkr 19 | ENV CONF_DIR=/opt JAVA_HOME=/usr/lib/jvm/java-openjdk/ 20 | 21 | WORKDIR /opt 22 | ENV PERMISSION_FIX=true 23 | ADD .bashrc /root/ 24 | RUN git clone https://github.com/flokkr/launcher.git && git --work-tree=/opt/launcher --git-dir=/opt/launcher/.git checkout ${LAUNCHER_HASH} 25 | RUN find -name onbuild.sh | xargs -n1 bash -c 26 | ENTRYPOINT ["/usr/bin/dumb-init", "--", "/opt/launcher/launcher.sh"] 27 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flokkr base image 2 | 3 | This repository contains the base docker image [for all other](https://github.com/flokkr?utf8=%E2%9C%93&q=docker&type=&language=) hadoop/bigdata related docker images. 4 | 5 | It contains all the configuration loading and starting script. The detailed documentation is part of each container's README, but usually copied from the `readme-parts/` directory of this repository. 6 | 7 | ## Configuration and extensions 8 | 9 | The flokkr containers support multiple configuration loading mechanism and various extensions. All of the these are defined in the [flokkr baseimage](https://github.com/flokkr/docker-baseimage) and could be activated by environment variables. 10 | 11 | The available plugins: 12 | 13 | | Name | Description | 14 | | ------------ | ---------------------------------------- | 15 | | installer | Download a tar file and replace existing product with that. Useful -- for example -- to test RC releases. | 16 | | envtoconf | **Simple configuration loading**, suggested for stand-alone docker files. Converts environment variables to xml/property configuration based on naming convention | 17 | | retry | Retries the run of the process. | 18 | | consul | **Complex configuration loading from consul**, downloads configuration from consul server and restart when the configuration is changed. Suggested for multi-host setups. | 19 | | btrace | Instruments the java option with custom Btrace script (with modifying the JAVA_OPTS) | 20 | | sleep | Wait for a defined amount of seconds. Useful for dirty workarounds (for example wait for all containers to be started and registered in dns server) | 21 | | kerberos | Downloads kerberos keytabs and java keystores from the rest endpoint of the unsecure [krb5 dev server](https://github.com/flokkr/docker-krb5) 22 | | permissionfix| Workaround for docker: fixes the permission of the data volume | 23 | ### Plugin details 24 | 25 | #### ENVTOCONF: Simple configuration loading 26 | 27 | Could be activated by ```CONFIG_TYPE=simple``` settings, but it's the default. 28 | 29 | Every configuration could be defined with environment variables, and they will be converted finally to *hadoop xml, properties, conf* or other format. The destination format (and the destination file name) is defined with the name of the environment variable according to a naming convention. 30 | 31 | The generated files will be saved to the `$CONF_DIR` directory. 32 | 33 | The source code of the converter utility can be found in a [separated repository](https://github.com/elek/envtoconf). 34 | 35 | ##### Naming convention for set config keys from enviroment variables 36 | 37 | To set any configuration variable you should follow the following pattern: 38 | 39 | ``` 40 | NAME.EXTENSION_configkey=VALUE 41 | ``` 42 | 43 | The extension could be any extension which has a predefined transformation (currently xml, yaml, properties, configuration, yaml, env, sh, conf, cfg) 44 | 45 | examples: 46 | 47 | ``` 48 | CORE-SITE_fs.default.name: "hdfs://localhost:9000" 49 | HDFS-SITE_dfs_namenode_rpc-address: "localhost:9000" 50 | HBASE-SITE.XML_hbase_zookeeper_quorum: "localhost" 51 | ``` 52 | 53 | In some rare cases the transformation and the extension should be different. For example the kafka `server.properties` should be in the format `key=value` which is the `cfg` transformation in our system. In that case you can postfix the extension with an additional format specifier: 54 | 55 | 56 | ``` 57 | NAME.EXTENSION!FORMAT_configkey=VALUE 58 | ``` 59 | 60 | For example: 61 | 62 | ``` 63 | SERVER.CONF!CFG_zookeeper.address=zookeeper:2181 64 | ``` 65 | 66 | ##### Available transformation 67 | 68 | * xml: HADOOP xml file format 69 | 70 | * properties: key value pairs with ```:``` as separator 71 | 72 | * cfg: key value pairs with ```=``` as separator 73 | 74 | * conf: key value pairs with space as separator (spark-defaults is an example) 75 | 76 | * env: key value pairs with ```=``` as separator 77 | 78 | * sh: as the env but also includes the export keyword 79 | 80 | ##### Configuration reference 81 | 82 | The plugin itself could be configured with the following environment variables. 83 | 84 | | Name | Default | Description | 85 | | ----------- | ---------------------------------------- | ---------------------------------------- | 86 | | CONF_DIR | *Set in the docker container definitions* | The location where the configuration files will be saved. | 87 | | CONFIG_TYPE | simple | For compatibility reason. If the value is simple, the conversion is active. | 88 | 89 | #### CONSUL: Consul config loading 90 | 91 | Could be activated with ```CONFIG_TYPE=consul``` 92 | 93 | * The starter script list the configuration file names based on a consul key prefix. All the files will be downloaded from the consul key value store and the application process will be started with consul-template (enable an automatic restart in case of configuration file change) 94 | 95 | The source code of the consul based configuration loading and launcher is available at the [elek/consul-launcher](https://github.com/elek/consul-launcher) repository. 96 | 97 | | Name | Default | Description | 98 | | ----------- | ---------------------------------------- | ---------------------------------------- | 99 | | CONF_DIR | *Set in the docker container definitions* | The location where the configuration files will be saved. | 100 | | CONFIG_TYPE | consul | For compatibility reason. If the value is consul, the consul based configuration handling is active. | 101 | | CONSUL_PATH | conf | The path of the subtree in the consul where the configurations are. | 102 | | CONSUL_KEY | | The path where the configuration for this container should be downloaded from. The effective path will be ```$CONSUL_PATH/$CONSUL_KEY``` | 103 | 104 | #### BTRACE: btrace instrumentation 105 | 106 | Could be enabled with setting ```BTRACE_ENABLED=true``` or just setting ```BTRACE_SCRIPT```. 107 | 108 | It adds btrace javaagent configuration to the JAVA_OPTS (or any other opts defined by BTRACE_OPTS_VAR). The standard output is redirected to ```/tmp/output.log```, and the btrace output will be displayed on the standard output (over a ```/tmp/btrace.out``` file) 109 | 110 | | Name | Default | Description | 111 | | --------------- | ---------------------------------------- | ---------------------------------------- | 112 | | CONF_DIR | *Set in the docker container definitions* | The location where the configuration files will be saved. | 113 | | BTRACE_SCRIPT | | The location of the compiled btrace script. Could be absolute or relative to the ```/opt/plugins/020_btrace/btrace``` | 114 | | BTRACE_OPTS_VAR | JAVA_OPTS | The name of the shell variable where the agent parameters should be injected. | 115 | 116 | 117 | #### Configuration 118 | 119 | * `CONSUL_PATH` defines the root of the subtree where the configuration are downloaded from. The root could also contain a configuration `config.ini`. Default is `conf` 120 | 121 | * `CONSUL_KEY` is optional. It defines a subdirectory to download the the config files. If both `CONSUL_PATH` and `CONSUL_KEY` are defined, the config files will be downloaded from `$CONSUL_PATH/$CONSUL_KEY` but the config file will be read from `$CONSUL_PATH/config.ini` 122 | 123 | #### INSTALLER: replace built in components 124 | 125 | The original products usually unpacked to the /opt directory during the container build (eg. /opt/hadoop, /opt/spark, etc...). The install plugin deletes the original product directory and replaces it with a newly one downloaded from the internet. 126 | 127 | | Name | Default | Description | 128 | | ------------- | -------- | ---------------------------------------- | 129 | | INSTALLER_XXX | | The value of the environment variable should be an url. If set, the URL will be downloaded and untar-ed to the /opt/xxx directory. For example set ```INSTALER_HADOOP=http://home.apache.org/~shv/hadoop-2.7.4-RC0/https://home.apache.org/~shv/hadoop-2.7.4-RC0/hadoop-2.7.4-RC0.tar.gz``` to test an RC. | 130 | 131 | #### SLEEP: sleep for a specified amount of time. 132 | 133 | | Name | Default | Description | 134 | | ------------- | -------- | ---------------------------------------- | 135 | | SLEEP_SECONDS | | If set, the ```sleep``` bash command will be called with the value of the environment variable. Better to not use this plugin, if possible. | 136 | 137 | #### RETRY: process running retry 138 | 139 | The plugin tries to run the entrypoint of the image multiple times. If the process has been exited with non zero exit code, it tries to rerun the command after a sleep. The sleep time increasing with every iteration and the whole process will be stopped anyway after a fix amount of retry. If the process run enough time (60s) the failure counter and sleep time is reseted. 140 | 141 | ### Configuration 142 | 143 | | Name | Default | Description | 144 | | ------------- | -------- | ---------------------------------------- | 145 | | RETRY_NUMBER | 10 | Number of times the process will be restarted (in case of non-zero exit code | 146 | | RETRY_NORMAL_RUN_DURATION | 60 | After this amount of seconds the RETRY_NUMBER counter will be reseted. Example: After 5 tries the process is started and run successfully 5 minutes. After a non-zero exit, it will be rerun RETRY_NUM (10) times. Example 2: After 5 tries the process is starts, runs for 40 seconds, and exits. The retry will continue with the remaining 5 try. | 147 | 148 | #### KERBEROS: download kerberos keytabs and ssl key/truststore 149 | 150 | Our total UNSECURE [kerberos server](https://github.com/flokkr/docker-krb5) contains a REST endpoint to download on-the-fly generated kerberos keytabs, java keystores (ssl keystores, trustores). This plugin could be configured to download the files. The plugin also copies krb5.cfg to /etc. 151 | 152 | ### Configuration 153 | 154 | | Name | Default | Description | 155 | | ------------------ | -------- | ---------------------------------------- | 156 | | KERBEROS_SERVER | krb5 | The name of the UNSECURE kerberos server where the REST endpoint is available on :8081 | 157 | | KERBEROS_KEYTABS | | Space separated list of keytab names. With every element a new keytab will generated to $CONF_DIR/$NAME.keytab with a key for $NAME/$HOSTNAME@EXAMPLE.COM. | 158 | | KERBEROS_KEYSTORES | | Space separated list of certificate names. For every name a new keystore file will be generated to the $CONF_DIR/$NAME.keystore which contains a key for cn=$NAME. Trust store will also be generated to $CONF_DIR/truststore. | 159 | 160 | ## Changelog 161 | 162 | ### Version 22 163 | 164 | * Permission fixer plugin 165 | 166 | ### Version 21 167 | 168 | * Custom flokkr group with sudo permission 169 | 170 | ### Version 20 171 | 172 | * Consul start bugfix 173 | 174 | ### Version 19 175 | 176 | * Retry plugin 177 | * Kerberos plugin 178 | 179 | ### Version 18 180 | 181 | * Sleep and installer plugins 182 | 183 | ### Version 17 184 | 185 | - Refactored (hopefully simplified) architecture with plugin chain 186 | - BTrace support 187 | 188 | ### Version 16 189 | 190 | - Use fixed version from envtoconf 191 | 192 | ### Version 15 193 | 194 | - Fixes in the configuration generation and handling 195 | 196 | ### Version 14 197 | 198 | * Python installation has been removed 199 | * Environment based configuration has been switched from python to a more simple [go implementation](https://github.com/elek/envtoconf) 200 | 201 | ### Version 13 202 | 203 | * Spring configserver based configuration has been removed 204 | * Consul based configuration reader ported to go 205 | * Client side configuration file has been removed 206 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xe 4 | HASH=$(git describe --tags) 5 | TAG=${TRAVIS_BRANCH:-latest} 6 | 7 | build() { 8 | LAUNCHER_HASH=$(curl https://api.github.com/repos/flokkr/launcher/commits/master | jq -r '.sha') 9 | echo "Using launcher $LAUNCHER_HASH" 10 | docker build -t flokkr/base:$TAG --build-arg LAUNCHER_HASH=$LAUNCHER_HASH --label io.github.flokkr.base.version=$HASH --label io.github.flokkr.launcher.version=$LAUNCHER_HASH . 11 | } 12 | 13 | deploy() { 14 | docker push flokkr/base:${TAG} 15 | } 16 | 17 | 18 | while getopts ":t:" opt; do 19 | case $opt in 20 | t) 21 | export TAG=${OPTARG} 22 | ;; 23 | \?) 24 | echo "Invalid option: -$OPTARG" >&2 25 | ;; 26 | esac 27 | done 28 | 29 | 30 | shift $(($OPTIND -1)) 31 | eval $* 32 | --------------------------------------------------------------------------------