├── CONTRIBUTING.adoc ├── LICENSE ├── MAINTAINERS ├── Makefile ├── README.adoc ├── adb-utils.spec ├── bash_completions ├── oadm ├── oc └── openshift ├── services └── openshift │ ├── openshift.service │ ├── openshift_option │ ├── scripts │ ├── get_ip_address │ ├── openshift │ ├── openshift_provision │ └── openshift_stop │ └── templates │ ├── adb │ └── image-streams-centos7.json │ ├── cdk │ ├── image-streams-rhel7.json │ ├── jenkins-ephemeral-template.json │ └── jenkins-persistent-template.json │ └── common │ ├── cakephp-mysql.json │ ├── cakephp.json │ ├── eap64-basic-s2i.json │ ├── eap64-mysql-persistent-s2i.json │ ├── jboss-image-streams.json │ ├── jws30-tomcat7-mysql-persistent-s2i.json │ ├── nodejs-mongodb.json │ └── nodejs.json └── utils ├── add_insecure_registry ├── cert-gen.sh └── sccli.py /CONTRIBUTING.adoc: -------------------------------------------------------------------------------- 1 | = Contributing to adb-utils 2 | 3 | The following is a set of guidelines for contributing to adb-utils, 4 | which is hosted in the https://github.com/projectatomic[Project Atomic 5 | Organization] on GitHub. These are just guidelines, please use your best 6 | judgment and feel free to propose changes to this document in a pull 7 | request. 8 | 9 | At this point, this document is not complete, but as decisions are made 10 | on 11 | https://www.redhat.com/mailman/listinfo/container-tools[container-tools@redhat.com] 12 | ML they will be added to this document. 13 | 14 | [[pull-requests]] 15 | == Pull Requests 16 | 17 | * All changes should be made by pull request (PR), even from core 18 | committers/maintainers. 19 | * All changes need 2 ACKs from maintainers before they will be approved 20 | for inclusion. If the author of the PR is a maintainer, the submission 21 | is considered 1 of the 2 ACKs. Therefore PRs from maintainers only 22 | require one additional ACK. By "2 ACKs" we mean that 2 maintainers must 23 | acknowledge that the change is a good one. The 2nd person to ACK the PR 24 | should merge the PR with a comment including their agreement. 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | Project/Code Maintainers 2 | ------------------------ 3 | - Praveen Kumar @praveenkumar 4 | - Lalatendu Mohanty @LalatenduMohanty 5 | - Brian Exelbierd @bexelbie 6 | - Navid Shaikh @navidshaikh 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 Red Hat, Inc. All rights reserved. This copyrighted material 2 | # is made available to anyone wishing to use, modify, copy, or 3 | # redistribute it subject to the terms and conditions of the GNU General 4 | # Public License v.2. 5 | # 6 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY 7 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 8 | # PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | # 10 | # You should have received a copy of the GNU General Public License 11 | # along with this program; if not, write to the Free Software 12 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 13 | # 14 | # Author: Praveen Kumar 15 | 16 | UPSTREAM_NAME := adb-utils 17 | VERSION := 2.3 18 | DOWNSTREAM_NAME := cdk-utils 19 | SOURCE := https://github.com/projectatomic/${UPSTREAM_NAME}/archive/v${VERSION}.tar.gz 20 | MASTER_SOURCE := https://github.com/projectatomic/adb-utils/archive/master.tar.gz 21 | 22 | .PHONY: clean upstream downstream master 23 | 24 | 25 | upstream: 26 | 27 | # Create SRPM for upstream release as per VERSION variable. 28 | sed -i ${UPSTREAM_NAME}.spec \ 29 | -e "s|^Source0:\(\s\+\)\(.*\)$ |Source0:\1\%{name}-\%{version}\.tar\.gz|" \ 30 | -e "s|^Version:\(\s\+\)\(.*\)$ |Version:\1${VERSION}|" 31 | git archive --format tar.gz --prefix ${UPSTREAM_NAME}-${VERSION}/ HEAD -o ${UPSTREAM_NAME}-${VERSION}.tar.gz 32 | rm -fr ${UPSTREAM_NAME}-${VERSION} 33 | rpmbuild --define "_sourcedir ${PWD}" --define "_srcrpmdir ${PWD}" --define "dist .el7" -bs ${UPSTREAM_NAME}.spec && \ 34 | rm -fr ${UPSTREAM_NAME}-${VERSION}.tar.gz 35 | git checkout ${UPSTREAM_NAME}.spec 36 | 37 | downstream: 38 | 39 | # Create SRPM for downstream with a proper release of upstream 40 | sed -i \ 41 | -e "s|^Name:\(\s\+\)\(.*\)$ |Name:\1cdk-utils|" ${UPSTREAM_NAME}.spec \ 42 | -e "s|^Source0:\(\s\+\)\(.*\)$ |Source0:\1\%{name}-\%{version}\.tar\.gz|" \ 43 | -e "s|^Version:\(\s\+\)\(.*\)$ |Version:\1${VERSION}|" 44 | 45 | mv ${UPSTREAM_NAME}.spec ${DOWNSTREAM_NAME}.spec 46 | curl -sL -O ${SOURCE} 47 | tar -xvf v${VERSION}.tar.gz && rm v${VERSION}.tar.gz 48 | mv ${UPSTREAM_NAME}-${VERSION} ${DOWNSTREAM_NAME}-${VERSION} 49 | 50 | tar -cvf ${DOWNSTREAM_NAME}-${VERSION}.tar.gz ${DOWNSTREAM_NAME}-${VERSION} && \ 51 | rm -fr ${DOWNSTREAM_NAME}-${VERSION} 52 | rpmbuild --define "_sourcedir ${PWD}" --define "_srcrpmdir ${PWD}" \ 53 | --define "dist .el7" -bs ${DOWNSTREAM_NAME}.spec && \ 54 | rm -fr ${DOWNSTREAM_NAME}-${VERSION}.tar.gz 55 | git checkout ${UPSTREAM_NAME}.spec 56 | 57 | downstream_local: 58 | 59 | # Create SRPM for downstream which include local changes without commit 60 | sed -i \ 61 | -e "s|^Name:\(\s\+\)\(.*\)$ |Name:\1cdk-utils|" ${UPSTREAM_NAME}.spec \ 62 | -e "s|^Source0:\(\s\+\)\(.*\)$ |Source0:\1\%{name}-\%{version}\.tar\.gz|" \ 63 | -e "s|^Version:\(\s\+\)\(.*\)$ |Version:\1${VERSION}|" 64 | 65 | mv ${UPSTREAM_NAME}.spec ${DOWNSTREAM_NAME}.spec 66 | mkdir -p ${DOWNSTREAM_NAME}-${VERSION} 67 | tar cf - --exclude=${DOWNSTREAM_NAME}-${VERSION} --exclude=.git . | (cd ${DOWNSTREAM_NAME}-${VERSION} && tar xvf - ) 68 | 69 | tar -cvf ${DOWNSTREAM_NAME}-${VERSION}.tar.gz ${DOWNSTREAM_NAME}-${VERSION} && \ 70 | rm -fr ${DOWNSTREAM_NAME}-${VERSION} 71 | rpmbuild --define "_sourcedir ${PWD}" --define "_srcrpmdir ${PWD}" \ 72 | --define "dist .el7" -bs ${DOWNSTREAM_NAME}.spec && \ 73 | rm -fr ${DOWNSTREAM_NAME}-${VERSION}.tar.gz 74 | git checkout ${UPSTREAM_NAME}.spec 75 | 76 | update_autocomplete: 77 | # Clone latest autocomplete script and put required location 78 | curl -sL https://github.com/openshift/origin/raw/master/contrib/completions/bash/oadm > bash_completions/oadm 79 | curl -sL https://github.com/openshift/origin/raw/master/contrib/completions/bash/oc > bash_completions/oc 80 | curl -sL https://github.com/openshift/origin/raw/master/contrib/completions/bash/openshift > bash_completions/openshift 81 | 82 | update_template: 83 | # Clone from upstream and put required location. 84 | # Nodejs 85 | curl -sL https://github.com/openshift/nodejs-ex/raw/master/openshift/templates/nodejs-mongodb.json > services/openshift/templates/common/nodejs-mongodb.json 86 | curl -sL https://github.com/openshift/nodejs-ex/raw/master/openshift/templates/nodejs.json > services/openshift/templates/common/nodejs.json 87 | # Cakephp 88 | curl -sL https://github.com/openshift/cakephp-ex/raw/master/openshift/templates/cakephp.json > services/openshift/templates/common/cakephp.json 89 | curl -sL https://github.com/openshift/cakephp-ex/raw/master/openshift/templates/cakephp-mysql.json > services/openshift/templates/common/cakephp-mysql.json 90 | # Jenkins 91 | curl -sL https://github.com/openshift/origin/raw/master/examples/jenkins/jenkins-ephemeral-template.json > services/openshift/templates/cdk/jenkins-ephemeral-template.json 92 | curl -sL https://github.com/openshift/origin/raw/master/examples/jenkins/jenkins-persistent-template.json > services/openshift/templates/cdk/jenkins-persistent-template.json 93 | # EAP 94 | curl -sL https://github.com/jboss-openshift/application-templates/raw/master/eap/eap64-mysql-persistent-s2i.json > services/openshift/templates/common/eap64-mysql-persistent-s2i.json 95 | curl -sL https://github.com/jboss-openshift/application-templates/raw/master/eap/eap64-basic-s2i.json > services/openshift/templates/common/eap64-basic-s2i.json 96 | # JWS tomcat 97 | curl -sL https://github.com/jboss-openshift/application-templates/raw/master/webserver/jws30-tomcat7-mysql-persistent-s2i.json > services/openshift/templates/common/jws30-tomcat7-mysql-persistent-s2i.json 98 | # Jboss Image Stream 99 | curl -sL https://github.com/jboss-openshift/application-templates/raw/master/jboss-image-streams.json > services/openshift/templates/common/jboss-image-streams.json 100 | # Image stream CentOS 101 | curl -sL https://github.com/openshift/origin/raw/master/examples/image-streams/image-streams-centos7.json > services/openshift/templates/adb/image-streams-centos7.json 102 | # Image stream RHEL 103 | curl -sL https://github.com/openshift/origin/raw/master/examples/image-streams/image-streams-rhel7.json > services/openshift/templates/cdk/image-streams-rhel7.json 104 | 105 | clean: 106 | 107 | rm -fr *.tar.gz 108 | rm -fr *.src.rpm 109 | rm -fr cdk-utils.spec 110 | 111 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | [[adb-utils]] 2 | = adb-utils 3 | :toc: 4 | :toc-placement!: 5 | 6 | Utility and Service scripts for the 7 | https://github.com/projectatomic/adb-atomic-developer-bundle[Atomic-Developer-Bundle 8 | (ADB)]. 9 | 10 | ''' 11 | toc::[] 12 | ''' 13 | 14 | == What does adb-utils include? 15 | 16 | adb-utils provides the following content to the ADB Vagrant box: 17 | 18 | * OpenShift as a service 19 | + 20 | adb-utils uses a systemd service unit file to launch and setup a 21 | containerized version of OpenShift. With the systemd unit file, 22 | OpenShift can be configured and run in the ADB by issuing the following 23 | command: `systemctl start openshift`. 24 | * SCCLI 25 | + 26 | The Service Change CLI (sccli) provides a single point of entry for 27 | managing services inside of the ADB. The Kubernetes and OpenShift 28 | services can not run simultaneously in the ADB because of port 29 | conflicts, the sccli provides an easy way to change and run a specific 30 | service. 31 | + 32 | This is primarily of interest to users who use the ADB as a VM, which 33 | they access via `vagrant ssh`. 34 | + 35 | sccli enables the user to switch services easily in a running vagrant 36 | box. Currently, `sccli` only provides an interface for managing 37 | OpenShift or a single node Kubernetes instance. 38 | + 39 | The `sccli` command does not generate any output, but provides the 40 | correct, specific return code which is consumed by the 41 | https://github.com/projectatomic/vagrant-service-manager[vagrant-service-manager]. 42 | The vagrant-service-manager plugin calls upon the `sccli` to manage the 43 | services inside of the ADB. 44 | + 45 | The usage of sccli is as below: 46 | + 47 | .... 48 | sccli [-h] {kubernetes,openshift,docker} ... 49 | 50 | CLI for managing services in ADB/CDK 51 | 52 | optional arguments: 53 | -h, --help show this help message and exit 54 | 55 | subcommands: 56 | Manage services for openshift|docker|kubernetes 57 | 58 | {kubernetes,openshift,docker} 59 | kubernetes start|restart|status|stop (default:start) 60 | openshift start|restart|status|stop (default:start) 61 | docker start|restart|status|stop (default:start) 62 | .... 63 | + 64 | For instance, to start Kubernetes service, use: 65 | + 66 | .... 67 | # sccli kubernetes start 68 | # echo $? 69 | .... 70 | + 71 | `echo $?` gives you the return code for the command and feeds it to the 72 | vagrant-service-manager. The vagrant-service-manager makes decisions 73 | based on these return codes. If the return code is 0, it implies that 74 | the service has behaved (started/restarted/stopped) as expected. If the 75 | return status is anything other than 0, it implies that the service has 76 | failed to behave as expected. 77 | + 78 | sccli accepts environment variables to modify how services are 79 | configured and deployed. For the OpenShift service, the following 80 | environment variables are recognized: 81 | + 82 | `DOCKER_REGISTRY`, defines which registry the OpenShift containers 83 | should be pulled from. The default value is `"docker.io"`. 84 | + 85 | `IMAGE_NAME`, defines which OpenShift image should be used. The default 86 | value is `"openshift/origin"`. 87 | + 88 | `IMAGE_TAG`, defines which version of OpenShift should be used. The 89 | default value is `"v1.1.1"`. 90 | + 91 | Thus, the version of OpenShift defaults to the containerized version at 92 | `docker.io/openshift/origin:v1.1.1`. If you desire a different version, 93 | pass the `DOCKER_REGISTRY`, `IMAGE_NAME` and/or `IMAGE_TAG` environment 94 | variables. 95 | + 96 | An example of changing these would be: 97 | + 98 | .... 99 | $ sudo DOCKER_REGISTRY="registry.mycompany.com" IMAGE_NAME="openshift_gold" IMAGE_TAG="v2016-01-03" sccli openshift start 100 | .... 101 | + 102 | Or, to use the `latest` version: 103 | + 104 | .... 105 | $ IMAGE_TAG="latest" sccli openshift start 106 | .... 107 | 108 | These utilities and unit files are packaged as an RPM and included in 109 | https://github.com/projectatomic/adb-atomic-developer-bundle[Atomic-Developer-Bundle 110 | (ADB)] version 1.7.0 or later. 111 | 112 | The public YUM repository is available at: 113 | http://mirror.centos.org/centos-7/7/atomic/x86_64/adb/ 114 | 115 | [[ip-detection-note]] 116 | == IP Detection Note 117 | 118 | This code uses the last IPv4 address available from the set of 119 | configured addresses that are __up__. i.e. if eth0, eth1, and eth2 are 120 | all up and have IPv4 addresses, the address on eth2 is used. 121 | 122 | [[steps-to-build-the-src-rpm]] 123 | == Steps to build the SRC RPM 124 | 125 | * Create source tar ball 126 | + 127 | `spectool -g -R adb-utils.spec` 128 | * Build the SRPM for el7 129 | + 130 | `rpmbuild --define "_srcrpmdir $PWD" --define "dist .el7" -bs adb-utils.spec` 131 | 132 | [[interested-in-contributing-to-this-project]] 133 | == Interested in Contributing to this Project? 134 | 135 | We welcome issues and pull requests. Want to be more involved, join us: 136 | 137 | * Mailing List: 138 | https://www.redhat.com/mailman/listinfo/container-tools[container-tools@redhat.com] 139 | * IRC: #atomic and #nulecule on https://freenode.net/[freenode] 140 | * Meetings: 141 | ** Planning and Integration Meeting: Every Wednesday at 1230 UTC in a 142 | Bluejean https://bluejeans.com/381583203[Video Conference]. Alternately, 143 | a local 144 | https://www.intercallonline.com/listNumbersByCode.action?confCode=8464006194[phone 145 | access number] may be available. (1 hour) 146 | ** Team Standup/Review: Every Monday at 1500 UTC in IRC 147 | https://freenode.net/[freenode] #nulecule (.5 hour) 148 | 149 | *Note:* These meetings, mailing lists, and irc channels may include 150 | discussions on other Project Atomic components. 151 | 152 | Documentation is written using 153 | http://docutils.sourceforge.net/docs/user/rst/quickref.html[reStructuredText]. 154 | An http://rst.ninjs.org[online reStructuredText editor] is available. 155 | -------------------------------------------------------------------------------- /adb-utils.spec: -------------------------------------------------------------------------------- 1 | Name: adb-utils 2 | Version: 2.3 3 | Release: 2%{?dist} 4 | Summary: Installs the necessary utils/service files to support ADB/CDK 5 | 6 | License: GPLV2 7 | BuildArch: noarch 8 | 9 | URL: https://github.com/projectatomic/%{name} 10 | Source0: https://github.com/projectatomic/%{name}/archive/v%{version}.tar.gz 11 | 12 | BuildRequires: systemd 13 | Requires: python-netifaces 14 | 15 | %description 16 | Includes the utils files and service files that are required for the running 17 | specific service and directly including it to kickstart file. 18 | 19 | %prep 20 | %setup -q -n %{name}-%{version} 21 | 22 | %install 23 | %{__mkdir_p} %{buildroot}/opt/adb/openshift 24 | %{__mkdir_p} %{buildroot}/opt/adb/openshift/templates 25 | %{__mkdir_p} %{buildroot}%{_sysconfdir}/sysconfig/ 26 | %{__mkdir_p} %{buildroot}%{_unitdir} 27 | %{__mkdir_p} %{buildroot}%{_bindir} 28 | 29 | %{__install} -pm644 services/openshift/openshift.service \ 30 | %{buildroot}%{_unitdir}/openshift.service 31 | %{__install} -dm755 %{buildroot}%{_sysconfdir}/bash_completion.d/ 32 | %{__install} -pm644 bash_completions/* %{buildroot}%{_sysconfdir}/bash_completion.d/ 33 | %{__cp} services/openshift/openshift_option \ 34 | %{buildroot}%{_sysconfdir}/sysconfig/openshift_option 35 | %{__cp} services/openshift/scripts/* %{buildroot}/opt/adb/openshift/ 36 | %{__cp} utils/* %{buildroot}/opt/adb/ 37 | %{__cp} -r services/openshift/templates/* %{buildroot}/opt/adb/openshift/templates/ 38 | ln -s /opt/adb/sccli.py %{buildroot}%{_bindir}/sccli 39 | ln -s /opt/adb/add_insecure_registry %{buildroot}%{_bindir}/add_insecure_registry 40 | 41 | %files 42 | %{_sysconfdir}/sysconfig/openshift_option 43 | %{_unitdir}/openshift.service 44 | %{_bindir}/sccli 45 | %{_bindir}/add_insecure_registry 46 | %{_sysconfdir}/bash_completion.d/oadm 47 | %{_sysconfdir}/bash_completion.d/oc 48 | %{_sysconfdir}/bash_completion.d/openshift 49 | /opt/adb/ 50 | %doc LICENSE README.adoc 51 | 52 | %changelog 53 | * Tue Jan 24 2017 Praveen Kumar - 2.3-2 54 | - Update openshift start script to add rslave 55 | 56 | * Tue Jan 24 2017 Praveen Kumar - 2.3-1 57 | - Update to 2.3 version 58 | 59 | * Wed Nov 16 2016 Praveen Kumar - 2.2-2 60 | - Fix traceback issue due to undeclared variable 61 | 62 | * Thu Nov 10 2016 Praveen Kumar - 2.2-1 63 | - Update to 2.2 version 64 | 65 | * Wed Nov 09 2016 Praveen Kumar - 2.1-2 66 | - Fix sccli script for environment variable 67 | 68 | * Wed Nov 02 2016 Praveen Kumar - 2.1-1 69 | - Update to 2.1 version 70 | 71 | * Wed Oct 12 2016 Praveen Kumar - 2.0-2 72 | - Fix doc format from .rst to .adoc 73 | 74 | * Tue Aug 09 2016 Praveen Kumar - 2.0-1 75 | - Update to 2.0 version 76 | 77 | * Mon Jul 25 2016 Praveen Kumar - 1.9-1 78 | - Update to 1.9 version 79 | 80 | * Fri Jun 10 2016 Praveen Kumar - 1.8-1 81 | - Update to 1.8 version 82 | 83 | * Fri May 27 2016 Praveen Kumar - 1.7-1 84 | - Update to 1.7 version 85 | 86 | * Wed May 11 2016 Praveen Kumar - 1.6-1 87 | - Update to 1.6 version 88 | 89 | * Fri Apr 29 2016 Praveen Kumar 1.5-3 90 | - Add bash script auto completion for oc, oadm and openshift 91 | 92 | * Wed Apr 20 2016 Praveen Kumar 1.5-2 93 | - Ported sccli to python 94 | 95 | * Tue Apr 05 2016 Brian Exelbierd 1.5-1 96 | - Updated IP detection routine to use the last up IPv4 address 97 | 98 | * Fri Apr 01 2016 Praveen Kumar 1.4-1 99 | - Update to 1.4 with couple of bugfix 100 | 101 | * Thu Mar 17 2016 Lalatendu Mohanty 1.3-1 102 | - Adding openshift templates 103 | 104 | * Wed Mar 09 2016 Praveen Kumar 1.2-1 105 | - Update to 1.2 with couple of bugfix 106 | 107 | * Thu Mar 03 2016 Lalatendu Mohanty 1.1-1 108 | - Updating to 1.1 and couple of specfile fixes 109 | - Removing dependancy on commit0 110 | 111 | * Tue Mar 01 2016 Brian Exelbierd 1-4 112 | - Architecture change: openshift image/version info passed from the 113 | Vagrantfile to the box 114 | - docker pull is now done in sccli 115 | - Uses IMAGE_* variables so that sccli can use same for other svcs 116 | - DOCKER_REGISTRY var removed from openshift_options now in image name 117 | - `docker tag` removed from the unit file 118 | - when using openshift, enable the service for future reboots 119 | - CLI binaries now copied with `docker cp` for efficiency 120 | 121 | * Tue Feb 09 2016 Praveen Kumar 1-3 122 | - Add sccli changes 123 | 124 | * Fri Feb 05 2016 Praveen Kumar 1-2 125 | - Update to latest source 126 | 127 | * Mon Feb 01 2016 Praveen Kumar 1-1 128 | - Initial attemp to create a rpm 129 | -------------------------------------------------------------------------------- /services/openshift/openshift.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Docker Application Container for OpenShift 3 | Documentation=https://docs.openshift.org/ 4 | After=docker.service 5 | Requires=docker.service 6 | Conflicts=etcd.service kube-apiserver.service kube-controller-manager.service kube-scheduler.service kube-proxy.service 7 | 8 | [Service] 9 | TimeoutStartSec=0 10 | Restart=always 11 | EnvironmentFile=-/etc/sysconfig/openshift_option 12 | ExecStartPre=-/usr/bin/docker stop openshift 13 | ExecStartPre=-/usr/bin/docker rm openshift 14 | ExecStart=/usr/bin/sh /opt/adb/openshift/openshift 15 | ExecStartPost=/usr/bin/sh /opt/adb/openshift/openshift_provision 16 | ExecStop=/usr/bin/sh -c /opt/adb/openshift/openshift_stop 17 | KillMode=process 18 | Restart=on-failure 19 | RestartSec=30s 20 | 21 | [Install] 22 | WantedBy=multi-user.target 23 | -------------------------------------------------------------------------------- /services/openshift/openshift_option: -------------------------------------------------------------------------------- 1 | # /etc/sysconfig/openshift_options 2 | 3 | # Modify these options if you want to change openshift hostname 4 | OPENSHIFT_SUBDOMAIN="$(hostname).$(/opt/adb/openshift/get_ip_address).xip.io" 5 | IMAGE="docker.io/openshift/origin:latest" 6 | #NO_PROXY=localhost 7 | #HTTP_PROXY=http://USER:PASSWORD@IPADDR:PORT 8 | #HTTPS_PROXY=https://USER:PASSWORD@IPADDR:PORT 9 | -------------------------------------------------------------------------------- /services/openshift/scripts/get_ip_address: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function get_ip_address() 4 | { 5 | local ip=`ip -o -4 addr show up |egrep -v ': docker|: lo' |tail -1 | awk '{print $4}' |cut -f1 -d\/` 6 | 7 | echo $ip 8 | } 9 | 10 | sourcef=${BASH_SOURCE[0]} 11 | if [ $sourcef == $0 ]; then 12 | get_ip_address $@ 13 | fi 14 | -------------------------------------------------------------------------------- /services/openshift/scripts/openshift: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Export get_ip_address 4 | . /opt/adb/openshift/get_ip_address 5 | 6 | # Prepare, configure and start OpenShift 7 | 8 | set -o pipefail 9 | set -o nounset 10 | 11 | export ORIGIN_DIR="/var/lib/openshift" 12 | export OPENSHIFT_DIR=${ORIGIN_DIR}/openshift.local.config/master 13 | export KUBECONFIG=${OPENSHIFT_DIR}/admin.kubeconfig 14 | eval "OPENSHIFT_SUBDOMAIN=${OPENSHIFT_SUBDOMAIN}" 15 | 16 | # Default values for proxy 17 | HTTP_PROXY=${HTTP_PROXY:-""} 18 | HTTPS_PROXY=${HTTPS_PROXY:-""} 19 | NO_PROXY=${NO_PROXY:-""} 20 | 21 | 22 | # Get machine IP address 23 | ip=$(get_ip_address) 24 | 25 | # Proxy setup config 26 | read -r -d '' PROXY_CONFIG << EOM 27 | kubernetesMasterConfig: 28 | admissionConfig: 29 | pluginConfig: 30 | BuildDefaults: 31 | configuration: 32 | apiVersion: v1 33 | env: 34 | - name: HTTP_PROXY 35 | value: $HTTP_PROXY 36 | - name: HTTPS_PROXY 37 | value: $HTTPS_PROXY 38 | - name: NO_PROXY 39 | value: $NO_PROXY 40 | gitHTTPProxy: $HTTP_PROXY 41 | gitHTTPSProxy: $HTTPS_PROXY 42 | kind: BuildDefaultsConfig 43 | EOM 44 | 45 | 46 | ######################################################################## 47 | # Helper function to start OpenShift as container 48 | # 49 | # All passed paramters are passed through ti 50 | ######################################################################## 51 | start_openshift() { 52 | docker run $1 --name "openshift" --privileged --net=host --pid=host \ 53 | -w ${ORIGIN_DIR} \ 54 | -e "KUBECONFIG=${OPENSHIFT_DIR}/admin.kubeconfig" \ 55 | -e "NO_PROXY=${NO_PROXY}" \ 56 | -e "HTTP_PROXY=${HTTP_PROXY}" \ 57 | -e "HTTPS_PROXY=${HTTPS_PROXY}" \ 58 | -v /:/rootfs:ro \ 59 | -v /var/run:/var/run:rw \ 60 | -v /sys:/sys:ro \ 61 | -v /var/lib/docker:/var/lib/docker:rw \ 62 | -v ${ORIGIN_DIR}/openshift.local.volumes:${ORIGIN_DIR}/openshift.local.volumes:rslave,z \ 63 | -v ${ORIGIN_DIR}/openshift.local.config:${ORIGIN_DIR}/openshift.local.config:z \ 64 | -v ${ORIGIN_DIR}/openshift.local.etcd:${ORIGIN_DIR}/openshift.local.etcd:z \ 65 | $IMAGE start "${@:2}" 66 | } 67 | 68 | ######################################################################## 69 | # Helper function to remove existing openshift container 70 | ######################################################################## 71 | rm_openshift_container() { 72 | if docker inspect openshift &>/dev/null; then 73 | docker rm -f -v openshift > /dev/null 2>&1 74 | fi 75 | } 76 | 77 | ######################################################################## 78 | # Helper function to wait for OpenShift config file generation 79 | ######################################################################## 80 | wait_for_config_files() { 81 | echo "[INFO] Waiting for OpenShift config files to be created" 82 | for i in {1..6}; do 83 | if [ ! -f ${1} ] || [ ! -f ${2} ]; then 84 | echo "[INFO] ..." 85 | sleep 5 86 | else 87 | break 88 | fi 89 | done 90 | if [ ! -f ${1} ] || [ ! -f ${2} ]; then 91 | >&2 echo "[ERROR] Unable to create OpenShift config files" 92 | docker logs openshift 93 | exit 1 94 | fi 95 | } 96 | 97 | ######################################################################## 98 | # Main 99 | ######################################################################## 100 | 101 | # First start OpenShift to just write the config files 102 | master_config=${OPENSHIFT_DIR}/master-config.yaml 103 | node_config=${ORIGIN_DIR}/openshift.local.config/node-$(hostname)/node-config.yaml 104 | 105 | # In case of config changes for /etc/sysconfig/openshift_option file 106 | # this block will ensure those options should be updated to respective file 107 | # and service restart will pick latest options. 108 | if [ -f $master_config ]; then 109 | sed -i.orig -e "s/\(.*subdomain:\).*/\1 $OPENSHIFT_SUBDOMAIN/" ${master_config} 110 | fi 111 | 112 | # Configuration for openshift master config file 113 | if [ ! -f $master_config ]; then 114 | 115 | # Prepare directories for bind-mounting 116 | dirs=(openshift.local.volumes openshift.local.config openshift.local.etcd) 117 | for d in ${dirs[@]}; do 118 | mkdir -p ${ORIGIN_DIR}/${d} && chcon -Rt svirt_sandbox_file_t ${ORIGIN_DIR}/${d} 119 | done 120 | 121 | echo "[INFO] Preparing OpenShift config" 122 | start_openshift -d --write-config=${ORIGIN_DIR}/openshift.local.config --public-master=$ip > /dev/null 2>&1 123 | wait_for_config_files ${master_config} ${node_config} 124 | 125 | echo "Create openshift-dev and admin User" 126 | htpasswd -b -c ${OPENSHIFT_DIR}/user.htpasswd openshift-dev devel 127 | htpasswd -b ${OPENSHIFT_DIR}/user.htpasswd admin admin 128 | 129 | # Now we need to make some adjustments to the config 130 | DIR_EXPAND="\/var\/lib\/openshift\/openshift.local.config\/master" 131 | echo "[INFO] Configuring OpenShift via ${master_config}" 132 | sed -i.orig -e "s/\(.*subdomain:\).*/\1 $OPENSHIFT_SUBDOMAIN/" ${master_config} \ 133 | -e "s/\(.*masterPublicURL:\).*/\1 https:\/\/$ip:8443/g" \ 134 | -e "s/\(.*publicURL:\).*/\1 https:\/\/$ip:8443\/console\//g" \ 135 | -e "s/\(.*assetPublicURL:\).*/\1 https:\/\/$ip:8443\/console\//g" \ 136 | -e "s/\(.*\)anypassword/\1 htpasswd/" \ 137 | -e "s/\(.*\)kind: AllowAllPasswordIdentityProvider/\1kind: HTPasswdPasswordIdentityProvider\n\1file: ${DIR_EXPAND}\/user.htpasswd/" \ 138 | -e "/corsAllowedOrigins:/,/- localhost/c\corsAllowedOrigins:\n- .*" 139 | 140 | if [[ -n HTTP_PROXY ]]; then 141 | # Older version of awk not support inplace edit 142 | awk -v new="$PROXY_CONFIG" '/kubernetesMasterConfig/{print new} /kubernetesMasterConfig/,/pluginConfig/{next} 1' ${master_config} \ 143 | >tmp_file && mv -f tmp_file ${master_config} 144 | fi 145 | 146 | # Remove the container 147 | rm_openshift_container 148 | fi 149 | 150 | 151 | # Now we start the server pointing to the prepared config files 152 | echo "[INFO] Starting OpenShift server" 153 | start_openshift '' --master-config="${master_config}" --node-config="${node_config}" 154 | -------------------------------------------------------------------------------- /services/openshift/scripts/openshift_provision: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Prepare, configure and start OpenShift 4 | 5 | set -o pipefail 6 | set -o nounset 7 | 8 | source /etc/os-release 9 | 10 | export ORIGIN_DIR="/var/lib/openshift" 11 | export OPENSHIFT_DIR=${ORIGIN_DIR}/openshift.local.config/master 12 | export KUBECONFIG=${OPENSHIFT_DIR}/admin.kubeconfig 13 | eval "OPENSHIFT_SUBDOMAIN=${OPENSHIFT_SUBDOMAIN}" 14 | 15 | # Function to check openshift availability 16 | wait_for_openshift_api() { 17 | # Wait for container to show up 18 | ATTEMPT=0 19 | until docker inspect openshift > /dev/null 2>&1 || [ $ATTEMPT -eq 10 ]; do 20 | sleep 1 21 | ((ATTEMPT++)) 22 | done 23 | 24 | # Use health URL to check OpenShift readiness 25 | ATTEMPT=0 26 | until curl -ksSf https://127.0.0.1:8443/healthz/ready > /dev/null 2>&1 || [ $ATTEMPT -eq 60 ]; do 27 | sleep 1 28 | ((ATTEMPT++)) 29 | done 30 | } 31 | 32 | wait_for_openshift_api 33 | 34 | # Copy OpenShift CLI tools to the VM 35 | # Binaries are copied every time in case there is a version change 36 | # Note: oc and oadm are symlinks to openshift 37 | binaries=(openshift oc oadm) 38 | for n in ${binaries[@]}; do 39 | if [ ! -f /usr/bin/${n} ]; then 40 | echo "[INFO] Copying ${n} binary to VM" 41 | docker cp openshift:/usr/bin/${n} /usr/bin/${n} 42 | fi 43 | done 44 | 45 | # Create Docker Registry 46 | if [ ! -f ${ORIGIN_DIR}/configured.registry ]; then 47 | echo "[INFO] Configuring Docker Registry" 48 | # oadm and oc both can able to create registry (check oc/oadm --help) 49 | oadm registry --create --service-account=registry || exit 1 50 | oadm policy add-scc-to-group anyuid system:authenticated || exit 1 51 | touch ${ORIGIN_DIR}/configured.registry 52 | fi 53 | 54 | # For router, we have to create service account first and then use it for router creation. 55 | if [ ! -f ${ORIGIN_DIR}/configured.router ]; then 56 | echo "[INFO] Configuring HAProxy router" 57 | oadm policy add-scc-to-user privileged system:serviceaccount:default:router || exit 1 58 | oadm router --service-account=router --expose-metrics=true || exit 1 59 | touch ${ORIGIN_DIR}/configured.router 60 | 61 | # Get machine IP address 62 | registry_name="hub.openshift.${OPENSHIFT_SUBDOMAIN}" 63 | oc expose service docker-registry --hostname ${registry_name} 64 | fi 65 | 66 | 67 | # Securing the Registry 68 | # https://docs.openshift.org/latest/install_config/install/docker_registry.html#securing-the-registry 69 | if [ ! -f ${ORIGIN_DIR}/secured.registry ]; then 70 | # Public name for the registry 71 | REGISTRY_ROUTE=$(oc get route docker-registry -o template --template='{{ .spec.host }}') 72 | 73 | # Get IP and Port of the registry service 74 | REGISTRY_SERVICE_IP=$(oc get svc/docker-registry -o template --template='{{ .spec.clusterIP }}') 75 | REGISTRY_SERVICE_PORT=$(oc get svc/docker-registry -o template --template='{{ (index .spec.ports 0).port }}') 76 | 77 | # Create certificates for registry 78 | oadm ca create-server-cert --signer-cert=$OPENSHIFT_DIR/ca.crt \ 79 | --signer-key=$OPENSHIFT_DIR/ca.key --signer-serial=$OPENSHIFT_DIR/ca.serial.txt \ 80 | --hostnames="$REGISTRY_ROUTE,$REGISTRY_SERVICE_IP" \ 81 | --cert=$OPENSHIFT_DIR/registry.crt --key=$OPENSHIFT_DIR/registry.key 82 | 83 | # Create the secret for the registry certificates 84 | oc secrets new registry-secret $OPENSHIFT_DIR/registry.crt $OPENSHIFT_DIR/registry.key 85 | 86 | # Add the secret volume to the registry deployment configuration: 87 | oc volume dc/docker-registry --add --type=secret \ 88 | --secret-name=registry-secret -m /etc/secrets 89 | 90 | # Enable TLS by adding the following environment variables to the registry deployment configuration 91 | oc env dc/docker-registry \ 92 | REGISTRY_HTTP_TLS_CERTIFICATE=/etc/secrets/registry.crt \ 93 | REGISTRY_HTTP_TLS_KEY=/etc/secrets/registry.key 94 | 95 | # Update the scheme used for the registry’s liveness probe from HTTP to HTTPS: 96 | oc get dc/docker-registry -o yaml \ 97 | | sed -e 's/scheme: HTTP/scheme: HTTPS/g' \ 98 | | oc replace -f - 99 | 100 | # Copy the CA certificate to the Docker certificates directory. 101 | mkdir -p /etc/docker/certs.d/$REGISTRY_SERVICE_IP:$REGISTRY_SERVICE_PORT 102 | cp $OPENSHIFT_DIR/ca.crt /etc/docker/certs.d/$REGISTRY_SERVICE_IP:$REGISTRY_SERVICE_PORT 103 | 104 | mkdir -p /etc/docker/certs.d/$REGISTRY_ROUTE 105 | cp $OPENSHIFT_DIR/ca.crt /etc/docker/certs.d/$REGISTRY_ROUTE 106 | 107 | # Add "tls termination: passthroug" to already existing docker registry route 108 | oc get route docker-registry -o json | sed -e 's/\("spec": {\)/\1 "tls": {"termination": "passthrough"},/g' | oc replace -f - 109 | 110 | # Check if proxy enabled then add registry ip to docker proxy setting. 111 | if [ -f /etc/systemd/system/docker.service.d/http-proxy.conf ]; then 112 | sed -i.orig -r "s|^Environment=(.*)\"|Environment=\1,${REGISTRY_SERVICE_IP}\"|" /etc/systemd/system/docker.service.d/http-proxy.conf 113 | systemctl daemon-reload 114 | fi 115 | touch ${ORIGIN_DIR}/secured.registry 116 | fi 117 | 118 | 119 | # Provision persistence volumes 120 | if [ ! -f ${ORIGIN_DIR}/configured.nfs ]; then 121 | echo "[INFO] Creating and configuring NFS" 122 | mkdir -p /nfsvolumes/pv{01..03} 123 | chown -R nfsnobody:nfsnobody /nfsvolumes 124 | chmod -R 777 /nfsvolumes 125 | echo '' > /etc/exports 126 | 127 | for i in {01..03} 128 | do 129 | echo "/nfsvolumes/pv${i} *(rw,root_squash)" >> /etc/exports 130 | done 131 | # To allow pods to write to remote NFS servers 132 | setsebool -P virt_use_nfs 1 133 | 134 | # Start and enable nfs 135 | systemctl start nfs-server 136 | systemctl enable nfs-server 137 | 138 | # Enable the new exports without bouncing the NFS service 139 | exportfs -a 140 | 141 | echo "[INFO] Creating 3 NFS PV {pv01..03} using from 1Gi 3Gi in ReadWriteMany or ReadWriteOnly mode and Recycle Policy." 142 | for i in {1..3} 143 | do 144 | echo "apiVersion: v1 145 | kind: PersistentVolume 146 | metadata: 147 | name: pv0${i} 148 | spec: 149 | capacity: 150 | storage: ${i}Gi 151 | accessModes: 152 | - ReadWriteOnce 153 | - ReadWriteMany 154 | persistentVolumeReclaimPolicy: Recycle 155 | nfs: 156 | server: localhost 157 | path: /nfsvolumes/pv0${i}" | oc create -f - 158 | done 159 | 160 | touch ${ORIGIN_DIR}/configured.nfs 161 | fi 162 | 163 | # Installing templates into OpenShift 164 | if [ ! -f ${ORIGIN_DIR}/configured.templates ]; then 165 | echo "[INFO] Installing OpenShift templates" 166 | 167 | # TODO - These list must be verified and completed for a official release 168 | # Currently templates are sources from three main repositories 169 | # - openshift/origin 170 | # - openshift/nodejs-ex 171 | # - jboss-openshift/application-templates 172 | ose_tag=ose-v1.2.0 173 | template_list=$(find /opt/adb/openshift/templates/common -type f) 174 | template_list_adb=$(find /opt/adb/openshift/templates/adb -type f) 175 | template_list_cdk=$(find /opt/adb/openshift/templates/cdk -type f) 176 | case "${VARIANT_ID}" in 177 | "adb") 178 | template_list+=" ${template_list_adb}";; 179 | "cdk") 180 | template_list+=" ${template_list_cdk}";; 181 | *) 182 | (>&2 echo "[WARN] Unknown VARIANT_ID=\"${VARIANT_ID}\"!");; 183 | esac 184 | 185 | for template in ${template_list[@]}; do 186 | echo "[INFO] Importing template ${template}" 187 | oc create -f $template -n openshift >/dev/null 188 | done 189 | touch ${ORIGIN_DIR}/configured.templates 190 | fi 191 | 192 | # Configuring a openshift-dev and admin user 193 | if [ ! -f ${ORIGIN_DIR}/configured.user ]; then 194 | echo "[INFO] Adding required roles to openshift-dev and admin user ..." 195 | oadm policy add-role-to-user basic-user openshift-dev --config=${OPENSHIFT_DIR}/admin.kubeconfig 196 | oadm policy add-cluster-role-to-user cluster-admin admin --config=${OPENSHIFT_DIR}/admin.kubeconfig 197 | su vagrant -l -c "oc login https://127.0.0.1:8443 -u openshift-dev -p devel \ 198 | --certificate-authority=${OPENSHIFT_DIR}/ca.crt &>/dev/null" 199 | su vagrant -l -c "oc new-project sample-project --display-name='OpenShift sample project' \ 200 | --description='This is a sample project to demonstrate OpenShift v3' &>/dev/null" 201 | touch ${ORIGIN_DIR}/configured.user 202 | fi 203 | -------------------------------------------------------------------------------- /services/openshift/scripts/openshift_stop: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Stop OpenShift Releated Containers 4 | 5 | set -o pipefail 6 | set -o nounset 7 | 8 | docker stop openshift 9 | docker ps | awk 'index($NF,"k8s_")==1 { print $1 }' | xargs -l -r docker rm -f -v 10 | -------------------------------------------------------------------------------- /services/openshift/templates/cdk/jenkins-ephemeral-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "jenkins-ephemeral", 6 | "creationTimestamp": null, 7 | "annotations": { 8 | "openshift.io/display-name": "Jenkins (Ephemeral)", 9 | "description": "Jenkins service, without persistent storage.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.", 10 | "iconClass": "icon-jenkins", 11 | "tags": "instant-app,jenkins" 12 | } 13 | }, 14 | "message": "A Jenkins service has been created in your project. Log into Jenkins with your OpenShift account. The tutorial at https://github.com/openshift/origin/blob/master/examples/jenkins/README.md contains more information about using this template.", 15 | "objects": [ 16 | { 17 | "kind": "Route", 18 | "apiVersion": "v1", 19 | "metadata": { 20 | "name": "${JENKINS_SERVICE_NAME}", 21 | "creationTimestamp": null 22 | }, 23 | "spec": { 24 | "to": { 25 | "kind": "Service", 26 | "name": "${JENKINS_SERVICE_NAME}" 27 | }, 28 | "tls": { 29 | "termination": "edge", 30 | "insecureEdgeTerminationPolicy": "Redirect" 31 | } 32 | } 33 | }, 34 | { 35 | "kind": "DeploymentConfig", 36 | "apiVersion": "v1", 37 | "metadata": { 38 | "name": "${JENKINS_SERVICE_NAME}", 39 | "creationTimestamp": null 40 | }, 41 | "spec": { 42 | "strategy": { 43 | "type": "Recreate" 44 | }, 45 | "triggers": [ 46 | { 47 | "type": "ImageChange", 48 | "imageChangeParams": { 49 | "automatic": true, 50 | "containerNames": [ 51 | "jenkins" 52 | ], 53 | "from": { 54 | "kind": "ImageStreamTag", 55 | "name": "${JENKINS_IMAGE_STREAM_TAG}", 56 | "namespace": "${NAMESPACE}" 57 | }, 58 | "lastTriggeredImage": "" 59 | } 60 | }, 61 | { 62 | "type": "ConfigChange" 63 | } 64 | ], 65 | "replicas": 1, 66 | "selector": { 67 | "name": "${JENKINS_SERVICE_NAME}" 68 | }, 69 | "template": { 70 | "metadata": { 71 | "creationTimestamp": null, 72 | "labels": { 73 | "name": "${JENKINS_SERVICE_NAME}" 74 | } 75 | }, 76 | "spec": { 77 | "serviceAccountName": "${JENKINS_SERVICE_NAME}", 78 | "containers": [ 79 | { 80 | "name": "jenkins", 81 | "image": " ", 82 | "readinessProbe": { 83 | "timeoutSeconds": 3, 84 | "initialDelaySeconds": 3, 85 | "httpGet": { 86 | "path": "/login", 87 | "port": 8080 88 | } 89 | }, 90 | "livenessProbe": { 91 | "timeoutSeconds": 3, 92 | "initialDelaySeconds": 420, 93 | "failureThreshold" : 30, 94 | "httpGet": { 95 | "path": "/login", 96 | "port": 8080 97 | } 98 | }, 99 | "env": [ 100 | { 101 | "name": "OPENSHIFT_ENABLE_OAUTH", 102 | "value": "${ENABLE_OAUTH}" 103 | }, 104 | { 105 | "name": "OPENSHIFT_ENABLE_REDIRECT_PROMPT", 106 | "value": "true" 107 | }, 108 | { 109 | "name": "KUBERNETES_MASTER", 110 | "value": "https://kubernetes.default:443" 111 | }, 112 | { 113 | "name": "KUBERNETES_TRUST_CERTIFICATES", 114 | "value": "true" 115 | }, 116 | { 117 | "name": "JNLP_SERVICE_NAME", 118 | "value": "${JNLP_SERVICE_NAME}" 119 | } 120 | ], 121 | "resources": { 122 | "limits": { 123 | "memory": "${MEMORY_LIMIT}" 124 | } 125 | }, 126 | "volumeMounts": [ 127 | { 128 | "name": "${JENKINS_SERVICE_NAME}-data", 129 | "mountPath": "/var/lib/jenkins" 130 | } 131 | ], 132 | "terminationMessagePath": "/dev/termination-log", 133 | "imagePullPolicy": "IfNotPresent", 134 | "capabilities": {}, 135 | "securityContext": { 136 | "capabilities": {}, 137 | "privileged": false 138 | } 139 | } 140 | ], 141 | "volumes": [ 142 | { 143 | "name": "${JENKINS_SERVICE_NAME}-data", 144 | "emptyDir": { 145 | "medium": "" 146 | } 147 | } 148 | ], 149 | "restartPolicy": "Always", 150 | "dnsPolicy": "ClusterFirst" 151 | } 152 | } 153 | } 154 | }, 155 | { 156 | "kind": "ServiceAccount", 157 | "apiVersion": "v1", 158 | "metadata": { 159 | "name": "${JENKINS_SERVICE_NAME}", 160 | "annotations": { 161 | "serviceaccounts.openshift.io/oauth-redirectreference.jenkins": "{\"kind\":\"OAuthRedirectReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"Route\",\"name\":\"${JENKINS_SERVICE_NAME}\"}}" 162 | } 163 | } 164 | }, 165 | { 166 | "kind": "RoleBinding", 167 | "apiVersion": "v1", 168 | "metadata": { 169 | "name": "${JENKINS_SERVICE_NAME}_edit" 170 | }, 171 | "groupNames": null, 172 | "subjects": [ 173 | { 174 | "kind": "ServiceAccount", 175 | "name": "${JENKINS_SERVICE_NAME}" 176 | } 177 | ], 178 | "roleRef": { 179 | "name": "edit" 180 | } 181 | }, 182 | { 183 | "kind": "Service", 184 | "apiVersion": "v1", 185 | "metadata": { 186 | "name": "${JNLP_SERVICE_NAME}" 187 | }, 188 | "spec": { 189 | "ports": [ 190 | { 191 | "name": "agent", 192 | "protocol": "TCP", 193 | "port": 50000, 194 | "targetPort": 50000, 195 | "nodePort": 0 196 | } 197 | ], 198 | "selector": { 199 | "name": "${JENKINS_SERVICE_NAME}" 200 | }, 201 | "type": "ClusterIP", 202 | "sessionAffinity": "None" 203 | } 204 | }, 205 | { 206 | "kind": "Service", 207 | "apiVersion": "v1", 208 | "metadata": { 209 | "name": "${JENKINS_SERVICE_NAME}", 210 | "annotations": { 211 | "service.alpha.openshift.io/dependencies": "[{\"name\": \"${JNLP_SERVICE_NAME}\", \"namespace\": \"\", \"kind\": \"Service\"}]", 212 | "service.openshift.io/infrastructure": "true" 213 | }, 214 | "creationTimestamp": null 215 | }, 216 | "spec": { 217 | "ports": [ 218 | { 219 | "name": "web", 220 | "protocol": "TCP", 221 | "port": 80, 222 | "targetPort": 8080, 223 | "nodePort": 0 224 | } 225 | ], 226 | "selector": { 227 | "name": "${JENKINS_SERVICE_NAME}" 228 | }, 229 | "type": "ClusterIP", 230 | "sessionAffinity": "None" 231 | } 232 | } 233 | ], 234 | "parameters": [ 235 | { 236 | "name": "JENKINS_SERVICE_NAME", 237 | "displayName": "Jenkins Service Name", 238 | "description": "The name of the OpenShift Service exposed for the Jenkins container.", 239 | "value": "jenkins" 240 | }, 241 | { 242 | "name": "JNLP_SERVICE_NAME", 243 | "displayName": "Jenkins JNLP Service Name", 244 | "description": "The name of the service used for master/slave communication.", 245 | "value": "jenkins-jnlp" 246 | }, 247 | { 248 | "name": "ENABLE_OAUTH", 249 | "displayName": "Enable OAuth in Jenkins", 250 | "description": "Whether to enable OAuth OpenShift integration. If false, the static account 'admin' will be initialized with the password 'password'.", 251 | "value": "true" 252 | }, 253 | { 254 | "name": "MEMORY_LIMIT", 255 | "displayName": "Memory Limit", 256 | "description": "Maximum amount of memory the container can use.", 257 | "value": "512Mi" 258 | }, 259 | { 260 | "name": "NAMESPACE", 261 | "displayName": "Jenkins ImageStream Namespace", 262 | "description": "The OpenShift Namespace where the Jenkins ImageStream resides.", 263 | "value": "openshift" 264 | }, 265 | { 266 | "name": "JENKINS_IMAGE_STREAM_TAG", 267 | "displayName": "Jenkins ImageStreamTag", 268 | "description": "Name of the ImageStreamTag to be used for the Jenkins image.", 269 | "value": "jenkins:latest" 270 | } 271 | ], 272 | "labels": { 273 | "template": "jenkins-ephemeral-template" 274 | } 275 | } 276 | -------------------------------------------------------------------------------- /services/openshift/templates/cdk/jenkins-persistent-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "jenkins-persistent", 6 | "creationTimestamp": null, 7 | "annotations": { 8 | "openshift.io/display-name": "Jenkins (Persistent)", 9 | "description": "Jenkins service, with persistent storage.\n\nNOTE: You must have persistent volumes available in your cluster to use this template.", 10 | "iconClass": "icon-jenkins", 11 | "tags": "instant-app,jenkins" 12 | } 13 | }, 14 | "message": "A Jenkins service has been created in your project. Log into Jenkins with your OpenShift account. The tutorial at https://github.com/openshift/origin/blob/master/examples/jenkins/README.md contains more information about using this template.", 15 | "objects": [ 16 | { 17 | "kind": "Route", 18 | "apiVersion": "v1", 19 | "metadata": { 20 | "name": "${JENKINS_SERVICE_NAME}", 21 | "creationTimestamp": null 22 | }, 23 | "spec": { 24 | "to": { 25 | "kind": "Service", 26 | "name": "${JENKINS_SERVICE_NAME}" 27 | }, 28 | "tls": { 29 | "termination": "edge", 30 | "insecureEdgeTerminationPolicy": "Redirect" 31 | } 32 | } 33 | }, 34 | { 35 | "kind": "PersistentVolumeClaim", 36 | "apiVersion": "v1", 37 | "metadata": { 38 | "name": "${JENKINS_SERVICE_NAME}" 39 | }, 40 | "spec": { 41 | "accessModes": [ 42 | "ReadWriteOnce" 43 | ], 44 | "resources": { 45 | "requests": { 46 | "storage": "${VOLUME_CAPACITY}" 47 | } 48 | } 49 | } 50 | }, 51 | { 52 | "kind": "DeploymentConfig", 53 | "apiVersion": "v1", 54 | "metadata": { 55 | "name": "${JENKINS_SERVICE_NAME}", 56 | "creationTimestamp": null 57 | }, 58 | "spec": { 59 | "strategy": { 60 | "type": "Recreate" 61 | }, 62 | "triggers": [ 63 | { 64 | "type": "ImageChange", 65 | "imageChangeParams": { 66 | "automatic": true, 67 | "containerNames": [ 68 | "jenkins" 69 | ], 70 | "from": { 71 | "kind": "ImageStreamTag", 72 | "name": "${JENKINS_IMAGE_STREAM_TAG}", 73 | "namespace": "${NAMESPACE}" 74 | }, 75 | "lastTriggeredImage": "" 76 | } 77 | }, 78 | { 79 | "type": "ConfigChange" 80 | } 81 | ], 82 | "replicas": 1, 83 | "selector": { 84 | "name": "${JENKINS_SERVICE_NAME}" 85 | }, 86 | "template": { 87 | "metadata": { 88 | "creationTimestamp": null, 89 | "labels": { 90 | "name": "${JENKINS_SERVICE_NAME}" 91 | } 92 | }, 93 | "spec": { 94 | "serviceAccountName": "${JENKINS_SERVICE_NAME}", 95 | "containers": [ 96 | { 97 | "name": "jenkins", 98 | "image": " ", 99 | "readinessProbe": { 100 | "timeoutSeconds": 3, 101 | "initialDelaySeconds": 3, 102 | "httpGet": { 103 | "path": "/login", 104 | "port": 8080 105 | } 106 | }, 107 | "livenessProbe": { 108 | "timeoutSeconds": 3, 109 | "initialDelaySeconds": 420, 110 | "failureThreshold" : 30, 111 | "httpGet": { 112 | "path": "/login", 113 | "port": 8080 114 | } 115 | }, 116 | "env": [ 117 | { 118 | "name": "OPENSHIFT_ENABLE_OAUTH", 119 | "value": "${ENABLE_OAUTH}" 120 | }, 121 | { 122 | "name": "OPENSHIFT_ENABLE_REDIRECT_PROMPT", 123 | "value": "true" 124 | }, 125 | { 126 | "name": "KUBERNETES_MASTER", 127 | "value": "https://kubernetes.default:443" 128 | }, 129 | { 130 | "name": "KUBERNETES_TRUST_CERTIFICATES", 131 | "value": "true" 132 | }, 133 | { 134 | "name": "JNLP_SERVICE_NAME", 135 | "value": "${JNLP_SERVICE_NAME}" 136 | } 137 | ], 138 | "resources": { 139 | "limits": { 140 | "memory": "${MEMORY_LIMIT}" 141 | } 142 | }, 143 | "volumeMounts": [ 144 | { 145 | "name": "${JENKINS_SERVICE_NAME}-data", 146 | "mountPath": "/var/lib/jenkins" 147 | } 148 | ], 149 | "terminationMessagePath": "/dev/termination-log", 150 | "imagePullPolicy": "IfNotPresent", 151 | "capabilities": {}, 152 | "securityContext": { 153 | "capabilities": {}, 154 | "privileged": false 155 | } 156 | } 157 | ], 158 | "volumes": [ 159 | { 160 | "name": "${JENKINS_SERVICE_NAME}-data", 161 | "persistentVolumeClaim": { 162 | "claimName": "${JENKINS_SERVICE_NAME}" 163 | } 164 | } 165 | ], 166 | "restartPolicy": "Always", 167 | "dnsPolicy": "ClusterFirst" 168 | } 169 | } 170 | } 171 | }, 172 | { 173 | "kind": "ServiceAccount", 174 | "apiVersion": "v1", 175 | "metadata": { 176 | "name": "${JENKINS_SERVICE_NAME}", 177 | "annotations": { 178 | "serviceaccounts.openshift.io/oauth-redirectreference.jenkins": "{\"kind\":\"OAuthRedirectReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"Route\",\"name\":\"${JENKINS_SERVICE_NAME}\"}}" 179 | } 180 | } 181 | }, 182 | { 183 | "kind": "RoleBinding", 184 | "apiVersion": "v1", 185 | "metadata": { 186 | "name": "${JENKINS_SERVICE_NAME}_edit" 187 | }, 188 | "groupNames": null, 189 | "subjects": [ 190 | { 191 | "kind": "ServiceAccount", 192 | "name": "${JENKINS_SERVICE_NAME}" 193 | } 194 | ], 195 | "roleRef": { 196 | "name": "edit" 197 | } 198 | }, 199 | { 200 | "kind": "Service", 201 | "apiVersion": "v1", 202 | "metadata": { 203 | "name": "${JNLP_SERVICE_NAME}" 204 | }, 205 | "spec": { 206 | "ports": [ 207 | { 208 | "name": "agent", 209 | "protocol": "TCP", 210 | "port": 50000, 211 | "targetPort": 50000, 212 | "nodePort": 0 213 | } 214 | ], 215 | "selector": { 216 | "name": "${JENKINS_SERVICE_NAME}" 217 | }, 218 | "type": "ClusterIP", 219 | "sessionAffinity": "None" 220 | } 221 | }, 222 | { 223 | "kind": "Service", 224 | "apiVersion": "v1", 225 | "metadata": { 226 | "name": "${JENKINS_SERVICE_NAME}", 227 | "annotations": { 228 | "service.alpha.openshift.io/dependencies": "[{\"name\": \"${JNLP_SERVICE_NAME}\", \"namespace\": \"\", \"kind\": \"Service\"}]", 229 | "service.openshift.io/infrastructure": "true" 230 | }, 231 | "creationTimestamp": null 232 | }, 233 | "spec": { 234 | "ports": [ 235 | { 236 | "name": "web", 237 | "protocol": "TCP", 238 | "port": 80, 239 | "targetPort": 8080, 240 | "nodePort": 0 241 | } 242 | ], 243 | "selector": { 244 | "name": "${JENKINS_SERVICE_NAME}" 245 | }, 246 | "type": "ClusterIP", 247 | "sessionAffinity": "None" 248 | } 249 | } 250 | ], 251 | "parameters": [ 252 | { 253 | "name": "JENKINS_SERVICE_NAME", 254 | "displayName": "Jenkins Service Name", 255 | "description": "The name of the OpenShift Service exposed for the Jenkins container.", 256 | "value": "jenkins" 257 | }, 258 | { 259 | "name": "JNLP_SERVICE_NAME", 260 | "displayName": "Jenkins JNLP Service Name", 261 | "description": "The name of the service used for master/slave communication.", 262 | "value": "jenkins-jnlp" 263 | }, 264 | { 265 | "name": "ENABLE_OAUTH", 266 | "displayName": "Enable OAuth in Jenkins", 267 | "description": "Whether to enable OAuth OpenShift integration. If false, the static account 'admin' will be initialized with the password 'password'.", 268 | "value": "true" 269 | }, 270 | { 271 | "name": "MEMORY_LIMIT", 272 | "displayName": "Memory Limit", 273 | "description": "Maximum amount of memory the container can use.", 274 | "value": "512Mi" 275 | }, 276 | { 277 | "name": "VOLUME_CAPACITY", 278 | "displayName": "Volume Capacity", 279 | "description": "Volume space available for data, e.g. 512Mi, 2Gi.", 280 | "value": "1Gi", 281 | "required": true 282 | }, 283 | { 284 | "name": "NAMESPACE", 285 | "displayName": "Jenkins ImageStream Namespace", 286 | "description": "The OpenShift Namespace where the Jenkins ImageStream resides.", 287 | "value": "openshift" 288 | }, 289 | { 290 | "name": "JENKINS_IMAGE_STREAM_TAG", 291 | "displayName": "Jenkins ImageStreamTag", 292 | "description": "Name of the ImageStreamTag to be used for the Jenkins image.", 293 | "value": "jenkins:latest" 294 | } 295 | ], 296 | "labels": { 297 | "template": "jenkins-persistent-template" 298 | } 299 | } 300 | -------------------------------------------------------------------------------- /services/openshift/templates/common/cakephp-mysql.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "cakephp-mysql-example", 6 | "annotations": { 7 | "openshift.io/display-name": "CakePHP + MySQL (Ephemeral)", 8 | "description": "An example CakePHP application with a MySQL database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/cakephp-ex/blob/master/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.", 9 | "tags": "quickstart,php,cakephp", 10 | "iconClass": "icon-php" 11 | } 12 | }, 13 | "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/cake-ex/blob/master/README.md.", 14 | "labels": { 15 | "template": "cakephp-mysql-example" 16 | }, 17 | "objects": [ 18 | { 19 | "kind": "Secret", 20 | "apiVersion": "v1", 21 | "metadata": { 22 | "name": "${NAME}" 23 | }, 24 | "stringData" : { 25 | "database-user" : "${DATABASE_USER}", 26 | "database-password" : "${DATABASE_PASSWORD}", 27 | "cakephp-secret-token" : "${CAKEPHP_SECRET_TOKEN}", 28 | "cakephp-security-salt" : "${CAKEPHP_SECURITY_SALT}", 29 | "cakephp-security-cipher-seed" : "${CAKEPHP_SECURITY_CIPHER_SEED}" 30 | } 31 | }, 32 | { 33 | "kind": "Service", 34 | "apiVersion": "v1", 35 | "metadata": { 36 | "name": "${NAME}", 37 | "annotations": { 38 | "description": "Exposes and load balances the application pods", 39 | "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]" 40 | } 41 | }, 42 | "spec": { 43 | "ports": [ 44 | { 45 | "name": "web", 46 | "port": 8080, 47 | "targetPort": 8080 48 | } 49 | ], 50 | "selector": { 51 | "name": "${NAME}" 52 | } 53 | } 54 | }, 55 | { 56 | "kind": "Route", 57 | "apiVersion": "v1", 58 | "metadata": { 59 | "name": "${NAME}" 60 | }, 61 | "spec": { 62 | "host": "${APPLICATION_DOMAIN}", 63 | "to": { 64 | "kind": "Service", 65 | "name": "${NAME}" 66 | } 67 | } 68 | }, 69 | { 70 | "kind": "ImageStream", 71 | "apiVersion": "v1", 72 | "metadata": { 73 | "name": "${NAME}", 74 | "annotations": { 75 | "description": "Keeps track of changes in the application image" 76 | } 77 | } 78 | }, 79 | { 80 | "kind": "BuildConfig", 81 | "apiVersion": "v1", 82 | "metadata": { 83 | "name": "${NAME}", 84 | "annotations": { 85 | "description": "Defines how to build the application" 86 | } 87 | }, 88 | "spec": { 89 | "source": { 90 | "type": "Git", 91 | "git": { 92 | "uri": "${SOURCE_REPOSITORY_URL}", 93 | "ref": "${SOURCE_REPOSITORY_REF}" 94 | }, 95 | "contextDir": "${CONTEXT_DIR}" 96 | }, 97 | "strategy": { 98 | "type": "Source", 99 | "sourceStrategy": { 100 | "from": { 101 | "kind": "ImageStreamTag", 102 | "namespace": "${NAMESPACE}", 103 | "name": "php:7.0" 104 | }, 105 | "env": [ 106 | { 107 | "name": "COMPOSER_MIRROR", 108 | "value": "${COMPOSER_MIRROR}" 109 | } 110 | ] 111 | } 112 | }, 113 | "output": { 114 | "to": { 115 | "kind": "ImageStreamTag", 116 | "name": "${NAME}:latest" 117 | } 118 | }, 119 | "triggers": [ 120 | { 121 | "type": "ImageChange" 122 | }, 123 | { 124 | "type": "ConfigChange" 125 | }, 126 | { 127 | "type": "GitHub", 128 | "github": { 129 | "secret": "${GITHUB_WEBHOOK_SECRET}" 130 | } 131 | } 132 | ] 133 | } 134 | }, 135 | { 136 | "kind": "DeploymentConfig", 137 | "apiVersion": "v1", 138 | "metadata": { 139 | "name": "${NAME}", 140 | "annotations": { 141 | "description": "Defines how to deploy the application server" 142 | } 143 | }, 144 | "spec": { 145 | "strategy": { 146 | "type": "Recreate", 147 | "recreateParams": { 148 | "pre": { 149 | "failurePolicy": "Retry", 150 | "execNewPod": { 151 | "command": [ 152 | "./migrate-database.sh" 153 | ], 154 | "containerName": "cakephp-mysql-example" 155 | } 156 | } 157 | } 158 | }, 159 | "triggers": [ 160 | { 161 | "type": "ImageChange", 162 | "imageChangeParams": { 163 | "automatic": true, 164 | "containerNames": [ 165 | "cakephp-mysql-example" 166 | ], 167 | "from": { 168 | "kind": "ImageStreamTag", 169 | "name": "${NAME}:latest" 170 | } 171 | } 172 | }, 173 | { 174 | "type": "ConfigChange" 175 | } 176 | ], 177 | "replicas": 1, 178 | "selector": { 179 | "name": "${NAME}" 180 | }, 181 | "template": { 182 | "metadata": { 183 | "name": "${NAME}", 184 | "labels": { 185 | "name": "${NAME}" 186 | } 187 | }, 188 | "spec": { 189 | "containers": [ 190 | { 191 | "name": "cakephp-mysql-example", 192 | "image": " ", 193 | "ports": [ 194 | { 195 | "containerPort": 8080 196 | } 197 | ], 198 | "readinessProbe": { 199 | "timeoutSeconds": 3, 200 | "initialDelaySeconds": 3, 201 | "httpGet": { 202 | "path": "/health.php", 203 | "port": 8080 204 | } 205 | }, 206 | "livenessProbe": { 207 | "timeoutSeconds": 3, 208 | "initialDelaySeconds": 30, 209 | "httpGet": { 210 | "path": "/", 211 | "port": 8080 212 | } 213 | }, 214 | "env": [ 215 | { 216 | "name": "DATABASE_SERVICE_NAME", 217 | "value": "${DATABASE_SERVICE_NAME}" 218 | }, 219 | { 220 | "name": "DATABASE_ENGINE", 221 | "value": "${DATABASE_ENGINE}" 222 | }, 223 | { 224 | "name": "DATABASE_NAME", 225 | "value": "${DATABASE_NAME}" 226 | }, 227 | { 228 | "name": "DATABASE_USER", 229 | "valueFrom": { 230 | "secretKeyRef" : { 231 | "name" : "${NAME}", 232 | "key" : "database-user" 233 | } 234 | } 235 | }, 236 | { 237 | "name": "DATABASE_PASSWORD", 238 | "valueFrom": { 239 | "secretKeyRef" : { 240 | "name" : "${NAME}", 241 | "key" : "database-password" 242 | } 243 | } 244 | }, 245 | { 246 | "name": "CAKEPHP_SECRET_TOKEN", 247 | "valueFrom": { 248 | "secretKeyRef" : { 249 | "name" : "${NAME}", 250 | "key" : "cakephp-secret-token" 251 | } 252 | } 253 | }, 254 | { 255 | "name": "CAKEPHP_SECURITY_SALT", 256 | "valueFrom": { 257 | "secretKeyRef" : { 258 | "name" : "${NAME}", 259 | "key" : "cakephp-security-salt" 260 | } 261 | } 262 | }, 263 | { 264 | "name": "CAKEPHP_SECURITY_CIPHER_SEED", 265 | "valueFrom": { 266 | "secretKeyRef" : { 267 | "name" : "${NAME}", 268 | "key" : "cakephp-security-cipher-seed" 269 | } 270 | } 271 | }, 272 | { 273 | "name": "OPCACHE_REVALIDATE_FREQ", 274 | "value": "${OPCACHE_REVALIDATE_FREQ}" 275 | } 276 | ], 277 | "resources": { 278 | "limits": { 279 | "memory": "${MEMORY_LIMIT}" 280 | } 281 | } 282 | } 283 | ] 284 | } 285 | } 286 | } 287 | }, 288 | { 289 | "kind": "Service", 290 | "apiVersion": "v1", 291 | "metadata": { 292 | "name": "${DATABASE_SERVICE_NAME}", 293 | "annotations": { 294 | "description": "Exposes the database server" 295 | } 296 | }, 297 | "spec": { 298 | "ports": [ 299 | { 300 | "name": "mysql", 301 | "port": 3306, 302 | "targetPort": 3306 303 | } 304 | ], 305 | "selector": { 306 | "name": "${DATABASE_SERVICE_NAME}" 307 | } 308 | } 309 | }, 310 | { 311 | "kind": "DeploymentConfig", 312 | "apiVersion": "v1", 313 | "metadata": { 314 | "name": "${DATABASE_SERVICE_NAME}", 315 | "annotations": { 316 | "description": "Defines how to deploy the database" 317 | } 318 | }, 319 | "spec": { 320 | "strategy": { 321 | "type": "Recreate" 322 | }, 323 | "triggers": [ 324 | { 325 | "type": "ImageChange", 326 | "imageChangeParams": { 327 | "automatic": true, 328 | "containerNames": [ 329 | "mysql" 330 | ], 331 | "from": { 332 | "kind": "ImageStreamTag", 333 | "namespace": "${NAMESPACE}", 334 | "name": "mysql:5.7" 335 | } 336 | } 337 | }, 338 | { 339 | "type": "ConfigChange" 340 | } 341 | ], 342 | "replicas": 1, 343 | "selector": { 344 | "name": "${DATABASE_SERVICE_NAME}" 345 | }, 346 | "template": { 347 | "metadata": { 348 | "name": "${DATABASE_SERVICE_NAME}", 349 | "labels": { 350 | "name": "${DATABASE_SERVICE_NAME}" 351 | } 352 | }, 353 | "spec": { 354 | "volumes": [ 355 | { 356 | "name": "data", 357 | "emptyDir": {} 358 | } 359 | ], 360 | "containers": [ 361 | { 362 | "name": "mysql", 363 | "image": " ", 364 | "ports": [ 365 | { 366 | "containerPort": 3306 367 | } 368 | ], 369 | "volumeMounts": [ 370 | { 371 | "name": "data", 372 | "mountPath": "/var/lib/mysql/data" 373 | } 374 | ], 375 | "readinessProbe": { 376 | "timeoutSeconds": 1, 377 | "initialDelaySeconds": 5, 378 | "exec": { 379 | "command": [ "/bin/sh", "-i", "-c", "MYSQL_PWD='${DATABASE_PASSWORD}' mysql -h 127.0.0.1 -u ${DATABASE_USER} -D ${DATABASE_NAME} -e 'SELECT 1'" ] 380 | } 381 | }, 382 | "livenessProbe": { 383 | "timeoutSeconds": 1, 384 | "initialDelaySeconds": 30, 385 | "tcpSocket": { 386 | "port": 3306 387 | } 388 | }, 389 | "env": [ 390 | { 391 | "name": "MYSQL_USER", 392 | "valueFrom": { 393 | "secretKeyRef" : { 394 | "name" : "${NAME}", 395 | "key" : "database-user" 396 | } 397 | } 398 | }, 399 | { 400 | "name": "MYSQL_PASSWORD", 401 | "valueFrom": { 402 | "secretKeyRef" : { 403 | "name" : "${NAME}", 404 | "key" : "database-password" 405 | } 406 | } 407 | }, 408 | { 409 | "name": "MYSQL_DATABASE", 410 | "value": "${DATABASE_NAME}" 411 | } 412 | ], 413 | "resources": { 414 | "limits": { 415 | "memory": "${MEMORY_MYSQL_LIMIT}" 416 | } 417 | } 418 | } 419 | ] 420 | } 421 | } 422 | } 423 | } 424 | ], 425 | "parameters": [ 426 | { 427 | "name": "NAME", 428 | "displayName": "Name", 429 | "description": "The name assigned to all of the frontend objects defined in this template.", 430 | "required": true, 431 | "value": "cakephp-mysql-example" 432 | }, 433 | { 434 | "name": "NAMESPACE", 435 | "displayName": "Namespace", 436 | "description": "The OpenShift Namespace where the ImageStream resides.", 437 | "required": true, 438 | "value": "openshift" 439 | }, 440 | { 441 | "name": "MEMORY_LIMIT", 442 | "displayName": "Memory Limit", 443 | "description": "Maximum amount of memory the CakePHP container can use.", 444 | "required": true, 445 | "value": "512Mi" 446 | }, 447 | { 448 | "name": "MEMORY_MYSQL_LIMIT", 449 | "displayName": "Memory Limit (MySQL)", 450 | "description": "Maximum amount of memory the MySQL container can use.", 451 | "required": true, 452 | "value": "512Mi" 453 | }, 454 | { 455 | "name": "SOURCE_REPOSITORY_URL", 456 | "displayName": "Git Repository URL", 457 | "description": "The URL of the repository with your application source code.", 458 | "required": true, 459 | "value": "https://github.com/openshift/cakephp-ex.git" 460 | }, 461 | { 462 | "name": "SOURCE_REPOSITORY_REF", 463 | "displayName": "Git Reference", 464 | "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." 465 | }, 466 | { 467 | "name": "CONTEXT_DIR", 468 | "displayName": "Context Directory", 469 | "description": "Set this to the relative path to your project if it is not in the root of your repository." 470 | }, 471 | { 472 | "name": "APPLICATION_DOMAIN", 473 | "displayName": "Application Hostname", 474 | "description": "The exposed hostname that will route to the CakePHP service, if left blank a value will be defaulted.", 475 | "value": "" 476 | }, 477 | { 478 | "name": "GITHUB_WEBHOOK_SECRET", 479 | "displayName": "GitHub Webhook Secret", 480 | "description": "A secret string used to configure the GitHub webhook.", 481 | "generate": "expression", 482 | "from": "[a-zA-Z0-9]{40}" 483 | }, 484 | { 485 | "name": "DATABASE_SERVICE_NAME", 486 | "displayName": "Database Service Name", 487 | "required": true, 488 | "value": "mysql" 489 | }, 490 | { 491 | "name": "DATABASE_ENGINE", 492 | "displayName": "Database Engine", 493 | "description": "Database engine: postgresql, mysql or sqlite (default).", 494 | "required": true, 495 | "value": "mysql" 496 | }, 497 | { 498 | "name": "DATABASE_NAME", 499 | "displayName": "Database Name", 500 | "required": true, 501 | "value": "default" 502 | }, 503 | { 504 | "name": "DATABASE_USER", 505 | "displayName": "Database User", 506 | "required": true, 507 | "value": "cakephp" 508 | }, 509 | { 510 | "name": "DATABASE_PASSWORD", 511 | "displayName": "Database Password", 512 | "generate": "expression", 513 | "from": "[a-zA-Z0-9]{16}" 514 | }, 515 | { 516 | "name": "CAKEPHP_SECRET_TOKEN", 517 | "displayName": "CakePHP secret token", 518 | "description": "Set this to a long random string.", 519 | "generate": "expression", 520 | "from": "[\\w]{50}" 521 | }, 522 | { 523 | "name": "CAKEPHP_SECURITY_SALT", 524 | "displayName": "CakePHP Security Salt", 525 | "description": "Security salt for session hash.", 526 | "generate": "expression", 527 | "from": "[a-zA-Z0-9]{40}" 528 | }, 529 | { 530 | "name": "CAKEPHP_SECURITY_CIPHER_SEED", 531 | "displayName": "CakePHP Security Cipher Seed", 532 | "description": "Security cipher seed for session hash.", 533 | "generate": "expression", 534 | "from": "[0-9]{30}" 535 | }, 536 | { 537 | "name": "OPCACHE_REVALIDATE_FREQ", 538 | "displayName": "OPcache Revalidation Frequency", 539 | "description": "How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.", 540 | "value": "2" 541 | }, 542 | { 543 | "name": "COMPOSER_MIRROR", 544 | "displayName": "Custom Composer Mirror URL", 545 | "description": "The custom Composer mirror URL", 546 | "value": "" 547 | } 548 | ] 549 | } 550 | -------------------------------------------------------------------------------- /services/openshift/templates/common/cakephp.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "cakephp-example", 6 | "annotations": { 7 | "openshift.io/display-name": "CakePHP", 8 | "description": "An example CakePHP application with no database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/cake-ex/blob/master/README.md.", 9 | "tags": "quickstart,php,cakephp", 10 | "iconClass": "icon-php" 11 | } 12 | }, 13 | "message": "The following service(s) have been created in your project: ${NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/cake-ex/blob/master/README.md.", 14 | "labels": { 15 | "template": "cakephp-example" 16 | }, 17 | "objects": [ 18 | { 19 | "kind": "Secret", 20 | "apiVersion": "v1", 21 | "metadata": { 22 | "name": "${NAME}" 23 | }, 24 | "stringData" : { 25 | "cakephp-secret-token" : "${CAKEPHP_SECRET_TOKEN}", 26 | "cakephp-security-salt" : "${CAKEPHP_SECURITY_SALT}", 27 | "cakephp-security-cipher-seed" : "${CAKEPHP_SECURITY_CIPHER_SEED}" 28 | } 29 | }, 30 | { 31 | "kind": "Service", 32 | "apiVersion": "v1", 33 | "metadata": { 34 | "name": "${NAME}", 35 | "annotations": { 36 | "description": "Exposes and load balances the application pods" 37 | } 38 | }, 39 | "spec": { 40 | "ports": [ 41 | { 42 | "name": "web", 43 | "port": 8080, 44 | "targetPort": 8080 45 | } 46 | ], 47 | "selector": { 48 | "name": "${NAME}" 49 | } 50 | } 51 | }, 52 | { 53 | "kind": "Route", 54 | "apiVersion": "v1", 55 | "metadata": { 56 | "name": "${NAME}" 57 | }, 58 | "spec": { 59 | "host": "${APPLICATION_DOMAIN}", 60 | "to": { 61 | "kind": "Service", 62 | "name": "${NAME}" 63 | } 64 | } 65 | }, 66 | { 67 | "kind": "ImageStream", 68 | "apiVersion": "v1", 69 | "metadata": { 70 | "name": "${NAME}", 71 | "annotations": { 72 | "description": "Keeps track of changes in the application image" 73 | } 74 | } 75 | }, 76 | { 77 | "kind": "BuildConfig", 78 | "apiVersion": "v1", 79 | "metadata": { 80 | "name": "${NAME}", 81 | "annotations": { 82 | "description": "Defines how to build the application" 83 | } 84 | }, 85 | "spec": { 86 | "source": { 87 | "type": "Git", 88 | "git": { 89 | "uri": "${SOURCE_REPOSITORY_URL}", 90 | "ref": "${SOURCE_REPOSITORY_REF}" 91 | }, 92 | "contextDir": "${CONTEXT_DIR}" 93 | }, 94 | "strategy": { 95 | "type": "Source", 96 | "sourceStrategy": { 97 | "from": { 98 | "kind": "ImageStreamTag", 99 | "namespace": "${NAMESPACE}", 100 | "name": "php:7.0" 101 | }, 102 | "env": [ 103 | { 104 | "name": "COMPOSER_MIRROR", 105 | "value": "${COMPOSER_MIRROR}" 106 | } 107 | ] 108 | } 109 | }, 110 | "output": { 111 | "to": { 112 | "kind": "ImageStreamTag", 113 | "name": "${NAME}:latest" 114 | } 115 | }, 116 | "triggers": [ 117 | { 118 | "type": "ImageChange" 119 | }, 120 | { 121 | "type": "ConfigChange" 122 | }, 123 | { 124 | "type": "GitHub", 125 | "github": { 126 | "secret": "${GITHUB_WEBHOOK_SECRET}" 127 | } 128 | } 129 | ] 130 | } 131 | }, 132 | { 133 | "kind": "DeploymentConfig", 134 | "apiVersion": "v1", 135 | "metadata": { 136 | "name": "${NAME}", 137 | "annotations": { 138 | "description": "Defines how to deploy the application server" 139 | } 140 | }, 141 | "spec": { 142 | "strategy": { 143 | "type": "Rolling" 144 | }, 145 | "triggers": [ 146 | { 147 | "type": "ImageChange", 148 | "imageChangeParams": { 149 | "automatic": true, 150 | "containerNames": [ 151 | "cakephp-example" 152 | ], 153 | "from": { 154 | "kind": "ImageStreamTag", 155 | "name": "${NAME}:latest" 156 | } 157 | } 158 | }, 159 | { 160 | "type": "ConfigChange" 161 | } 162 | ], 163 | "replicas": 1, 164 | "selector": { 165 | "name": "${NAME}" 166 | }, 167 | "template": { 168 | "metadata": { 169 | "name": "${NAME}", 170 | "labels": { 171 | "name": "${NAME}" 172 | } 173 | }, 174 | "spec": { 175 | "containers": [ 176 | { 177 | "name": "cakephp-example", 178 | "image": " ", 179 | "ports": [ 180 | { 181 | "containerPort": 8080 182 | } 183 | ], 184 | "readinessProbe": { 185 | "timeoutSeconds": 3, 186 | "initialDelaySeconds": 3, 187 | "httpGet": { 188 | "path": "/", 189 | "port": 8080 190 | } 191 | }, 192 | "livenessProbe": { 193 | "timeoutSeconds": 3, 194 | "initialDelaySeconds": 30, 195 | "httpGet": { 196 | "path": "/", 197 | "port": 8080 198 | } 199 | }, 200 | "env": [ 201 | { 202 | "name": "CAKEPHP_SECRET_TOKEN", 203 | "valueFrom": { 204 | "secretKeyRef" : { 205 | "name" : "${NAME}", 206 | "key" : "cakephp-secret-token" 207 | } 208 | } 209 | }, 210 | { 211 | "name": "CAKEPHP_SECURITY_SALT", 212 | "valueFrom": { 213 | "secretKeyRef" : { 214 | "name" : "${NAME}", 215 | "key" : "cakephp-security-salt" 216 | } 217 | } 218 | }, 219 | { 220 | "name": "CAKEPHP_SECURITY_CIPHER_SEED", 221 | "valueFrom": { 222 | "secretKeyRef" : { 223 | "name" : "${NAME}", 224 | "key" : "cakephp-security-cipher-seed" 225 | } 226 | } 227 | }, 228 | { 229 | "name": "OPCACHE_REVALIDATE_FREQ", 230 | "value": "${OPCACHE_REVALIDATE_FREQ}" 231 | } 232 | ], 233 | "resources": { 234 | "limits": { 235 | "memory": "${MEMORY_LIMIT}" 236 | } 237 | } 238 | } 239 | ] 240 | } 241 | } 242 | } 243 | } 244 | ], 245 | "parameters": [ 246 | { 247 | "name": "NAME", 248 | "displayName": "Name", 249 | "description": "The name assigned to all of the frontend objects defined in this template.", 250 | "required": true, 251 | "value": "cakephp-example" 252 | }, 253 | { 254 | "name": "NAMESPACE", 255 | "displayName": "Namespace", 256 | "description": "The OpenShift Namespace where the ImageStream resides.", 257 | "required": true, 258 | "value": "openshift" 259 | }, 260 | { 261 | "name": "MEMORY_LIMIT", 262 | "displayName": "Memory Limit", 263 | "description": "Maximum amount of memory the container can use.", 264 | "required": true, 265 | "value": "512Mi" 266 | }, 267 | { 268 | "name": "SOURCE_REPOSITORY_URL", 269 | "displayName": "Git Repository URL", 270 | "description": "The URL of the repository with your application source code.", 271 | "required": true, 272 | "value": "https://github.com/openshift/cakephp-ex.git" 273 | }, 274 | { 275 | "name": "SOURCE_REPOSITORY_REF", 276 | "displayName": "Git Reference", 277 | "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." 278 | }, 279 | { 280 | "name": "CONTEXT_DIR", 281 | "displayName": "Context Directory", 282 | "description": "Set this to the relative path to your project if it is not in the root of your repository." 283 | }, 284 | { 285 | "name": "APPLICATION_DOMAIN", 286 | "displayName": "Application Hostname", 287 | "description": "The exposed hostname that will route to the CakePHP service, if left blank a value will be defaulted.", 288 | "value": "" 289 | }, 290 | { 291 | "name": "GITHUB_WEBHOOK_SECRET", 292 | "displayName": "GitHub Webhook Secret", 293 | "description": "A secret string used to configure the GitHub webhook.", 294 | "generate": "expression", 295 | "from": "[a-zA-Z0-9]{40}" 296 | }, 297 | { 298 | "name": "CAKEPHP_SECRET_TOKEN", 299 | "displayName": "CakePHP Secret Token", 300 | "description": "Set this to a long random string.", 301 | "generate": "expression", 302 | "from": "[\\w]{50}" 303 | }, 304 | { 305 | "name": "CAKEPHP_SECURITY_SALT", 306 | "displayName": "CakePHP Security Salt", 307 | "description": "Security salt for session hash.", 308 | "generate": "expression", 309 | "from": "[a-zA-Z0-9]{40}" 310 | }, 311 | { 312 | "name": "CAKEPHP_SECURITY_CIPHER_SEED", 313 | "displayName": "CakePHP Security Cipher Seed", 314 | "description": "Security cipher seed for session hash.", 315 | "generate": "expression", 316 | "from": "[0-9]{30}" 317 | }, 318 | { 319 | "name": "OPCACHE_REVALIDATE_FREQ", 320 | "displayName": "OPcache Revalidation Frequency", 321 | "description": "How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.", 322 | "value": "2" 323 | }, 324 | { 325 | "name": "COMPOSER_MIRROR", 326 | "displayName": "Custom Composer Mirror URL", 327 | "description": "The custom Composer mirror URL", 328 | "value": "" 329 | } 330 | ] 331 | } 332 | -------------------------------------------------------------------------------- /services/openshift/templates/common/eap64-basic-s2i.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "annotations": { 6 | "iconClass": "icon-jboss", 7 | "description": "Application template for EAP 6 applications built using S2I.", 8 | "tags": "eap,javaee,java,jboss,xpaas", 9 | "version": "1.3.2" 10 | }, 11 | "name": "eap64-basic-s2i" 12 | }, 13 | "labels": { 14 | "template": "eap64-basic-s2i", 15 | "xpaas": "1.3.2" 16 | }, 17 | "parameters": [ 18 | { 19 | "description": "The name for the application.", 20 | "name": "APPLICATION_NAME", 21 | "value": "eap-app", 22 | "required": true 23 | }, 24 | { 25 | "description": "Custom hostname for http service route. Leave blank for default hostname, e.g.: -.", 26 | "name": "HOSTNAME_HTTP", 27 | "value": "", 28 | "required": false 29 | }, 30 | { 31 | "description": "Git source URI for application", 32 | "name": "SOURCE_REPOSITORY_URL", 33 | "value": "https://github.com/jboss-developer/jboss-eap-quickstarts", 34 | "required": true 35 | }, 36 | { 37 | "description": "Git branch/tag reference", 38 | "name": "SOURCE_REPOSITORY_REF", 39 | "value": "6.4.x", 40 | "required": false 41 | }, 42 | { 43 | "description": "Path within Git project to build; empty for root project directory.", 44 | "name": "CONTEXT_DIR", 45 | "value": "kitchensink", 46 | "required": false 47 | }, 48 | { 49 | "description": "Queue names", 50 | "name": "HORNETQ_QUEUES", 51 | "value": "", 52 | "required": false 53 | }, 54 | { 55 | "description": "Topic names", 56 | "name": "HORNETQ_TOPICS", 57 | "value": "", 58 | "required": false 59 | }, 60 | { 61 | "description": "HornetQ cluster admin password", 62 | "name": "HORNETQ_CLUSTER_PASSWORD", 63 | "from": "[a-zA-Z0-9]{8}", 64 | "generate": "expression", 65 | "required": true 66 | }, 67 | { 68 | "description": "GitHub trigger secret", 69 | "name": "GITHUB_WEBHOOK_SECRET", 70 | "from": "[a-zA-Z0-9]{8}", 71 | "generate": "expression", 72 | "required": true 73 | }, 74 | { 75 | "description": "Generic build trigger secret", 76 | "name": "GENERIC_WEBHOOK_SECRET", 77 | "from": "[a-zA-Z0-9]{8}", 78 | "generate": "expression", 79 | "required": true 80 | }, 81 | { 82 | "description": "Namespace in which the ImageStreams for Red Hat Middleware images are installed. These ImageStreams are normally installed in the openshift namespace. You should only need to modify this if you've installed the ImageStreams in a different namespace/project.", 83 | "name": "IMAGE_STREAM_NAMESPACE", 84 | "value": "openshift", 85 | "required": true 86 | }, 87 | { 88 | "description": "JGroups cluster password", 89 | "name": "JGROUPS_CLUSTER_PASSWORD", 90 | "from": "[a-zA-Z0-9]{8}", 91 | "generate": "expression", 92 | "required": true 93 | }, 94 | { 95 | "description": "Controls whether exploded deployment content should be automatically deployed", 96 | "name": "AUTO_DEPLOY_EXPLODED", 97 | "value": "false", 98 | "required": false 99 | } 100 | ], 101 | "objects": [ 102 | { 103 | "kind": "Service", 104 | "apiVersion": "v1", 105 | "spec": { 106 | "ports": [ 107 | { 108 | "port": 8080, 109 | "targetPort": 8080 110 | } 111 | ], 112 | "selector": { 113 | "deploymentConfig": "${APPLICATION_NAME}" 114 | } 115 | }, 116 | "metadata": { 117 | "name": "${APPLICATION_NAME}", 118 | "labels": { 119 | "application": "${APPLICATION_NAME}" 120 | }, 121 | "annotations": { 122 | "description": "The web server's http port." 123 | } 124 | } 125 | }, 126 | { 127 | "kind": "Route", 128 | "apiVersion": "v1", 129 | "id": "${APPLICATION_NAME}-http", 130 | "metadata": { 131 | "name": "${APPLICATION_NAME}", 132 | "labels": { 133 | "application": "${APPLICATION_NAME}" 134 | }, 135 | "annotations": { 136 | "description": "Route for application's http service." 137 | } 138 | }, 139 | "spec": { 140 | "host": "${HOSTNAME_HTTP}", 141 | "to": { 142 | "name": "${APPLICATION_NAME}" 143 | } 144 | } 145 | }, 146 | { 147 | "kind": "ImageStream", 148 | "apiVersion": "v1", 149 | "metadata": { 150 | "name": "${APPLICATION_NAME}", 151 | "labels": { 152 | "application": "${APPLICATION_NAME}" 153 | } 154 | } 155 | }, 156 | { 157 | "kind": "BuildConfig", 158 | "apiVersion": "v1", 159 | "metadata": { 160 | "name": "${APPLICATION_NAME}", 161 | "labels": { 162 | "application": "${APPLICATION_NAME}" 163 | } 164 | }, 165 | "spec": { 166 | "source": { 167 | "type": "Git", 168 | "git": { 169 | "uri": "${SOURCE_REPOSITORY_URL}", 170 | "ref": "${SOURCE_REPOSITORY_REF}" 171 | }, 172 | "contextDir": "${CONTEXT_DIR}" 173 | }, 174 | "strategy": { 175 | "type": "Source", 176 | "sourceStrategy": { 177 | "forcePull": true, 178 | "from": { 179 | "kind": "ImageStreamTag", 180 | "namespace": "${IMAGE_STREAM_NAMESPACE}", 181 | "name": "jboss-eap64-openshift:1.4" 182 | } 183 | } 184 | }, 185 | "output": { 186 | "to": { 187 | "kind": "ImageStreamTag", 188 | "name": "${APPLICATION_NAME}:latest" 189 | } 190 | }, 191 | "triggers": [ 192 | { 193 | "type": "GitHub", 194 | "github": { 195 | "secret": "${GITHUB_WEBHOOK_SECRET}" 196 | } 197 | }, 198 | { 199 | "type": "Generic", 200 | "generic": { 201 | "secret": "${GENERIC_WEBHOOK_SECRET}" 202 | } 203 | }, 204 | { 205 | "type": "ImageChange", 206 | "imageChange": {} 207 | }, 208 | { 209 | "type": "ConfigChange" 210 | } 211 | ] 212 | } 213 | }, 214 | { 215 | "kind": "DeploymentConfig", 216 | "apiVersion": "v1", 217 | "metadata": { 218 | "name": "${APPLICATION_NAME}", 219 | "labels": { 220 | "application": "${APPLICATION_NAME}" 221 | } 222 | }, 223 | "spec": { 224 | "strategy": { 225 | "type": "Recreate" 226 | }, 227 | "triggers": [ 228 | { 229 | "type": "ImageChange", 230 | "imageChangeParams": { 231 | "automatic": true, 232 | "containerNames": [ 233 | "${APPLICATION_NAME}" 234 | ], 235 | "from": { 236 | "kind": "ImageStreamTag", 237 | "name": "${APPLICATION_NAME}:latest" 238 | } 239 | } 240 | }, 241 | { 242 | "type": "ConfigChange" 243 | } 244 | ], 245 | "replicas": 1, 246 | "selector": { 247 | "deploymentConfig": "${APPLICATION_NAME}" 248 | }, 249 | "template": { 250 | "metadata": { 251 | "name": "${APPLICATION_NAME}", 252 | "labels": { 253 | "deploymentConfig": "${APPLICATION_NAME}", 254 | "application": "${APPLICATION_NAME}" 255 | } 256 | }, 257 | "spec": { 258 | "terminationGracePeriodSeconds": 60, 259 | "containers": [ 260 | { 261 | "name": "${APPLICATION_NAME}", 262 | "image": "${APPLICATION_NAME}", 263 | "imagePullPolicy": "Always", 264 | "livenessProbe": { 265 | "exec": { 266 | "command": [ 267 | "/bin/bash", 268 | "-c", 269 | "/opt/eap/bin/livenessProbe.sh" 270 | ] 271 | } 272 | }, 273 | "readinessProbe": { 274 | "exec": { 275 | "command": [ 276 | "/bin/bash", 277 | "-c", 278 | "/opt/eap/bin/readinessProbe.sh" 279 | ] 280 | } 281 | }, 282 | "ports": [ 283 | { 284 | "name": "jolokia", 285 | "containerPort": 8778, 286 | "protocol": "TCP" 287 | }, 288 | { 289 | "name": "http", 290 | "containerPort": 8080, 291 | "protocol": "TCP" 292 | }, 293 | { 294 | "name": "ping", 295 | "containerPort": 8888, 296 | "protocol": "TCP" 297 | } 298 | ], 299 | "env": [ 300 | { 301 | "name": "OPENSHIFT_KUBE_PING_LABELS", 302 | "value": "application=${APPLICATION_NAME}" 303 | }, 304 | { 305 | "name": "OPENSHIFT_KUBE_PING_NAMESPACE", 306 | "valueFrom": { 307 | "fieldRef": { 308 | "fieldPath": "metadata.namespace" 309 | } 310 | } 311 | }, 312 | { 313 | "name": "HORNETQ_CLUSTER_PASSWORD", 314 | "value": "${HORNETQ_CLUSTER_PASSWORD}" 315 | }, 316 | { 317 | "name": "HORNETQ_QUEUES", 318 | "value": "${HORNETQ_QUEUES}" 319 | }, 320 | { 321 | "name": "HORNETQ_TOPICS", 322 | "value": "${HORNETQ_TOPICS}" 323 | }, 324 | { 325 | "name": "JGROUPS_CLUSTER_PASSWORD", 326 | "value": "${JGROUPS_CLUSTER_PASSWORD}" 327 | }, 328 | { 329 | "name": "AUTO_DEPLOY_EXPLODED", 330 | "value": "${AUTO_DEPLOY_EXPLODED}" 331 | } 332 | ] 333 | } 334 | ] 335 | } 336 | } 337 | } 338 | } 339 | ] 340 | } 341 | -------------------------------------------------------------------------------- /services/openshift/templates/common/jboss-image-streams.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "List", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "jboss-image-streams", 6 | "annotations": { 7 | "description": "ImageStream definitions for JBoss Middleware products." 8 | } 9 | }, 10 | "items": [ 11 | { 12 | "kind": "ImageStream", 13 | "apiVersion": "v1", 14 | "metadata": { 15 | "name": "jboss-webserver30-tomcat7-openshift" 16 | }, 17 | "spec": { 18 | "dockerImageRepository": "registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat7-openshift", 19 | "tags": [ 20 | { 21 | "name": "1.1", 22 | "annotations": { 23 | "description": "JBoss Web Server 3.0 Tomcat 7 S2I images.", 24 | "iconClass": "icon-jboss", 25 | "tags": "builder,tomcat,tomcat7,java,jboss,xpaas", 26 | "supports":"tomcat7:3.0,tomcat:7,java:8,xpaas:1.1", 27 | "sampleRepo": "https://github.com/jboss-openshift/openshift-quickstarts.git", 28 | "sampleContextDir": "tomcat-websocket-chat", 29 | "version": "1.1" 30 | } 31 | }, 32 | { 33 | "name": "1.2", 34 | "annotations": { 35 | "description": "JBoss Web Server 3.0 Tomcat 7 S2I images.", 36 | "iconClass": "icon-jboss", 37 | "tags": "builder,tomcat,tomcat7,java,jboss,xpaas", 38 | "supports":"tomcat7:3.0,tomcat:7,java:8,xpaas:1.2", 39 | "sampleRepo": "https://github.com/jboss-openshift/openshift-quickstarts.git", 40 | "sampleContextDir": "tomcat-websocket-chat", 41 | "version": "1.2" 42 | } 43 | } 44 | ] 45 | } 46 | }, 47 | { 48 | "kind": "ImageStream", 49 | "apiVersion": "v1", 50 | "metadata": { 51 | "name": "jboss-webserver30-tomcat8-openshift" 52 | }, 53 | "spec": { 54 | "dockerImageRepository": "registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat8-openshift", 55 | "tags": [ 56 | { 57 | "name": "1.1", 58 | "annotations": { 59 | "description": "JBoss Web Server 3.0 Tomcat 8 S2I images.", 60 | "iconClass": "icon-jboss", 61 | "tags": "builder,tomcat,tomcat8,java,jboss,xpaas", 62 | "supports":"tomcat8:3.0,tomcat:8,java:8,xpaas:1.1", 63 | "sampleRepo": "https://github.com/jboss-openshift/openshift-quickstarts.git", 64 | "sampleContextDir": "tomcat-websocket-chat", 65 | "version": "1.1" 66 | } 67 | }, 68 | { 69 | "name": "1.2", 70 | "annotations": { 71 | "description": "JBoss Web Server 3.0 Tomcat 8 S2I images.", 72 | "iconClass": "icon-jboss", 73 | "tags": "builder,tomcat,tomcat8,java,jboss,xpaas", 74 | "supports":"tomcat8:3.0,tomcat:8,java:8,xpaas:1.2", 75 | "sampleRepo": "https://github.com/jboss-openshift/openshift-quickstarts.git", 76 | "sampleContextDir": "tomcat-websocket-chat", 77 | "version": "1.2" 78 | } 79 | } 80 | ] 81 | } 82 | }, 83 | { 84 | "kind": "ImageStream", 85 | "apiVersion": "v1", 86 | "metadata": { 87 | "name": "jboss-eap64-openshift" 88 | }, 89 | "spec": { 90 | "dockerImageRepository": "registry.access.redhat.com/jboss-eap-6/eap64-openshift", 91 | "tags": [ 92 | { 93 | "name": "1.1", 94 | "annotations": { 95 | "description": "JBoss EAP 6.4 S2I images.", 96 | "iconClass": "icon-jboss", 97 | "tags": "builder,eap,javaee,java,jboss,xpaas", 98 | "supports":"eap:6.4,javaee:6,java:8,xpaas:1.1", 99 | "sampleRepo": "https://github.com/jboss-developer/jboss-eap-quickstarts.git", 100 | "sampleContextDir": "kitchensink", 101 | "sampleRef": "6.4.x", 102 | "version": "1.1" 103 | } 104 | }, 105 | { 106 | "name": "1.2", 107 | "annotations": { 108 | "description": "JBoss EAP 6.4 S2I images.", 109 | "iconClass": "icon-jboss", 110 | "tags": "builder,eap,javaee,java,jboss,xpaas", 111 | "supports":"eap:6.4,javaee:6,java:8,xpaas:1.2", 112 | "sampleRepo": "https://github.com/jboss-developer/jboss-eap-quickstarts.git", 113 | "sampleContextDir": "kitchensink", 114 | "sampleRef": "6.4.x", 115 | "version": "1.2" 116 | } 117 | }, 118 | { 119 | "name": "1.3", 120 | "annotations": { 121 | "description": "JBoss EAP 6.4 S2I images.", 122 | "iconClass": "icon-jboss", 123 | "tags": "builder,eap,javaee,java,jboss,xpaas", 124 | "supports":"eap:6.4,javaee:6,java:8,xpaas:1.3", 125 | "sampleRepo": "https://github.com/jboss-developer/jboss-eap-quickstarts.git", 126 | "sampleContextDir": "kitchensink", 127 | "sampleRef": "6.4.x", 128 | "version": "1.3" 129 | } 130 | }, 131 | { 132 | "name": "1.4", 133 | "annotations": { 134 | "description": "JBoss EAP 6.4 S2I images.", 135 | "iconClass": "icon-jboss", 136 | "tags": "builder,eap,javaee,java,jboss,xpaas", 137 | "supports":"eap:6.4,javaee:6,java:8,xpaas:1.4", 138 | "sampleRepo": "https://github.com/jboss-developer/jboss-eap-quickstarts.git", 139 | "sampleContextDir": "kitchensink", 140 | "sampleRef": "6.4.x", 141 | "version": "1.4" 142 | } 143 | } 144 | ] 145 | } 146 | }, 147 | { 148 | "kind": "ImageStream", 149 | "apiVersion": "v1", 150 | "metadata": { 151 | "name": "jboss-eap70-openshift" 152 | }, 153 | "spec": { 154 | "dockerImageRepository": "registry.access.redhat.com/jboss-eap-7/eap70-openshift", 155 | "tags": [ 156 | { 157 | "name": "1.3", 158 | "annotations": { 159 | "description": "JBoss EAP 7.0 S2I images.", 160 | "iconClass": "icon-jboss", 161 | "tags": "builder,eap,javaee,java,jboss,xpaas", 162 | "supports":"eap:7.0,javaee:7,java:8,xpaas:1.3", 163 | "sampleRepo": "https://github.com/jboss-developer/jboss-eap-quickstarts.git", 164 | "sampleContextDir": "kitchensink", 165 | "sampleRef": "7.0.0.GA", 166 | "version": "1.3" 167 | } 168 | }, 169 | { 170 | "name": "1.4", 171 | "annotations": { 172 | "description": "JBoss EAP 7.0 S2I images.", 173 | "iconClass": "icon-jboss", 174 | "tags": "builder,eap,javaee,java,jboss,xpaas", 175 | "supports":"eap:7.0,javaee:7,java:8,xpaas:1.4", 176 | "sampleRepo": "https://github.com/jboss-developer/jboss-eap-quickstarts.git", 177 | "sampleContextDir": "kitchensink", 178 | "sampleRef": "7.0.0.GA", 179 | "version": "1.4" 180 | } 181 | } 182 | ] 183 | } 184 | }, 185 | { 186 | "kind": "ImageStream", 187 | "apiVersion": "v1", 188 | "metadata": { 189 | "name": "jboss-decisionserver62-openshift" 190 | }, 191 | "spec": { 192 | "dockerImageRepository": "registry.access.redhat.com/jboss-decisionserver-6/decisionserver62-openshift", 193 | "tags": [ 194 | { 195 | "name": "1.2", 196 | "annotations": { 197 | "description": "Red Hat JBoss BRMS 6.2 decision server S2I images.", 198 | "iconClass": "icon-jboss", 199 | "tags": "builder,decisionserver,java,xpaas", 200 | "supports":"decisionserver:6.2,java:8,xpaas:1.2", 201 | "sampleRepo": "https://github.com/jboss-openshift/openshift-quickstarts.git", 202 | "sampleContextDir": "decisionserver/hellorules", 203 | "sampleRef": "1.2", 204 | "version": "1.2" 205 | } 206 | } 207 | ] 208 | } 209 | }, 210 | { 211 | "kind": "ImageStream", 212 | "apiVersion": "v1", 213 | "metadata": { 214 | "name": "jboss-decisionserver63-openshift" 215 | }, 216 | "spec": { 217 | "dockerImageRepository": "registry.access.redhat.com/jboss-decisionserver-6/decisionserver63-openshift", 218 | "tags": [ 219 | { 220 | "name": "1.3", 221 | "annotations": { 222 | "description": "Red Hat JBoss BRMS 6.3 decision server S2I images.", 223 | "iconClass": "icon-jboss", 224 | "tags": "builder,decisionserver,java,xpaas", 225 | "supports":"decisionserver:6.3,java:8,xpaas:1.3", 226 | "sampleRepo": "https://github.com/jboss-openshift/openshift-quickstarts.git", 227 | "sampleContextDir": "decisionserver/hellorules", 228 | "sampleRef": "1.3", 229 | "version": "1.3" 230 | } 231 | } 232 | ] 233 | } 234 | }, 235 | { 236 | "kind": "ImageStream", 237 | "apiVersion": "v1", 238 | "metadata": { 239 | "name": "jboss-processserver63-openshift" 240 | }, 241 | "spec": { 242 | "dockerImageRepository": "registry.access.redhat.com/jboss-processserver-6/processserver63-openshift", 243 | "tags": [ 244 | { 245 | "name": "1.3", 246 | "annotations": { 247 | "description": "Red Hat JBoss BPM Suite 6.3 intelligent process server S2I images.", 248 | "iconClass": "icon-jboss", 249 | "tags": "builder,processserver,java,xpaas", 250 | "supports":"processserver:6.3,java:8,xpaas:1.3", 251 | "sampleRepo": "https://github.com/jboss-openshift/openshift-quickstarts.git", 252 | "sampleContextDir": "processserver/library", 253 | "sampleRef": "1.3", 254 | "version": "1.3" 255 | } 256 | } 257 | ] 258 | } 259 | }, 260 | { 261 | "kind": "ImageStream", 262 | "apiVersion": "v1", 263 | "metadata": { 264 | "name": "jboss-datagrid65-openshift" 265 | }, 266 | "spec": { 267 | "dockerImageRepository": "registry.access.redhat.com/jboss-datagrid-6/datagrid65-openshift", 268 | "tags": [ 269 | { 270 | "name": "1.2", 271 | "annotations": { 272 | "description": "JBoss Data Grid 6.5 S2I images.", 273 | "iconClass": "icon-jboss", 274 | "tags": "datagrid,java,jboss,xpaas", 275 | "supports":"datagrid:6.5,java:8,xpaas:1.2", 276 | "version": "1.2" 277 | } 278 | } 279 | ] 280 | } 281 | }, 282 | { 283 | "kind": "ImageStream", 284 | "apiVersion": "v1", 285 | "metadata": { 286 | "name": "jboss-datavirt63-openshift" 287 | }, 288 | "spec": { 289 | "dockerImageRepository": "registry.access.redhat.com/jboss-datavirt-6/datavirt63-openshift", 290 | "tags": [ 291 | { 292 | "name": "1.0", 293 | "annotations": { 294 | "description": "Red Hat JBoss Data Virtualization 6.3 S2I images.", 295 | "iconClass": "icon-jboss", 296 | "tags": "datavirt,java,jboss,xpaas", 297 | "supports":"datavirt:6.3,java:8,xpaas:1.4", 298 | "version": "1.0" 299 | } 300 | } 301 | ] 302 | } 303 | }, 304 | { 305 | "kind": "ImageStream", 306 | "apiVersion": "v1", 307 | "metadata": { 308 | "name": "jboss-amq-62" 309 | }, 310 | "spec": { 311 | "dockerImageRepository": "registry.access.redhat.com/jboss-amq-6/amq62-openshift", 312 | "tags": [ 313 | { 314 | "name": "1.1", 315 | "annotations": { 316 | "description": "JBoss A-MQ 6.2 broker image.", 317 | "iconClass": "icon-jboss", 318 | "tags": "messaging,amq,jboss,xpaas", 319 | "supports":"amq:6.2,messaging,xpaas:1.1", 320 | "version": "1.1" 321 | } 322 | }, 323 | { 324 | "name": "1.2", 325 | "annotations": { 326 | "description": "JBoss A-MQ 6.2 broker image.", 327 | "iconClass": "icon-jboss", 328 | "tags": "messaging,amq,jboss,xpaas", 329 | "supports":"amq:6.2,messaging,xpaas:1.2", 330 | "version": "1.2" 331 | } 332 | }, 333 | { 334 | "name": "1.3", 335 | "annotations": { 336 | "description": "JBoss A-MQ 6.2 broker image.", 337 | "iconClass": "icon-jboss", 338 | "tags": "messaging,amq,jboss,xpaas", 339 | "supports":"amq:6.2,messaging,xpaas:1.3", 340 | "version": "1.3" 341 | } 342 | } 343 | ] 344 | } 345 | }, 346 | { 347 | "kind": "ImageStream", 348 | "apiVersion": "v1", 349 | "metadata": { 350 | "name": "redhat-sso70-openshift", 351 | "annotations": { 352 | "description": "Red Hat SSO 7.0" 353 | } 354 | }, 355 | "spec": { 356 | "dockerImageRepository": "registry.access.redhat.com/redhat-sso-7/sso70-openshift", 357 | "tags": [ 358 | { 359 | "name": "1.3", 360 | "annotations": { 361 | "description": "Red Hat SSO 7.0", 362 | "iconClass": "icon-jboss", 363 | "tags": "sso,keycloak,redhat", 364 | "supports":"sso:7.0,xpaas:1.3", 365 | "version": "1.3" 366 | } 367 | } 368 | ] 369 | } 370 | } 371 | ] 372 | } 373 | -------------------------------------------------------------------------------- /services/openshift/templates/common/jws30-tomcat7-mysql-persistent-s2i.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "annotations": { 6 | "iconClass": "icon-tomcat", 7 | "description": "Application template for JWS MySQL applications with persistent storage built using S2I.", 8 | "tags": "tomcat,tomcat7,mysql,java,database,jboss,xpaas", 9 | "version": "1.2.0" 10 | }, 11 | "name": "jws30-tomcat7-mysql-persistent-s2i" 12 | }, 13 | "labels": { 14 | "template": "jws30-tomcat7-mysql-persistent-s2i", 15 | "xpaas": "1.2.0" 16 | }, 17 | "parameters": [ 18 | { 19 | "description": "The name for the application.", 20 | "name": "APPLICATION_NAME", 21 | "value": "jws-app", 22 | "required": true 23 | }, 24 | { 25 | "description": "Custom hostname for http service route. Leave blank for default hostname, e.g.: -.", 26 | "name": "HOSTNAME_HTTP", 27 | "value": "", 28 | "required": false 29 | }, 30 | { 31 | "description": "Custom hostname for https service route. Leave blank for default hostname, e.g.: secure--.", 32 | "name": "HOSTNAME_HTTPS", 33 | "value": "", 34 | "required": false 35 | }, 36 | { 37 | "description": "Git source URI for application", 38 | "name": "SOURCE_REPOSITORY_URL", 39 | "value": "https://github.com/jboss-openshift/openshift-quickstarts", 40 | "required": true 41 | }, 42 | { 43 | "description": "Git branch/tag reference", 44 | "name": "SOURCE_REPOSITORY_REF", 45 | "value": "1.2", 46 | "required": false 47 | }, 48 | { 49 | "description": "Path within Git project to build; empty for root project directory.", 50 | "name": "CONTEXT_DIR", 51 | "value": "todolist/todolist-jdbc", 52 | "required": false 53 | }, 54 | { 55 | "description": "Database JNDI name used by application to resolve the datasource, e.g. jboss/datasources/mysqlDS", 56 | "name": "DB_JNDI", 57 | "value": "jboss/datasources/defaultDS", 58 | "required": false 59 | }, 60 | { 61 | "description": "Database name", 62 | "name": "DB_DATABASE", 63 | "value": "root", 64 | "required": true 65 | }, 66 | { 67 | "description": "Size of persistent storage for database volume.", 68 | "name": "VOLUME_CAPACITY", 69 | "value": "512Mi", 70 | "required": true 71 | }, 72 | { 73 | "description": "The name of the secret containing the certificate files", 74 | "name": "JWS_HTTPS_SECRET", 75 | "value": "jws-app-secret", 76 | "required": true 77 | }, 78 | { 79 | "description": "The name of the certificate file within the secret", 80 | "name": "JWS_HTTPS_CERTIFICATE", 81 | "value": "server.crt", 82 | "required": false 83 | }, 84 | { 85 | "description": "The name of the certificate key file within the secret", 86 | "name": "JWS_HTTPS_CERTIFICATE_KEY", 87 | "value": "server.key", 88 | "required": false 89 | }, 90 | { 91 | "description": "The certificate password", 92 | "name": "JWS_HTTPS_CERTIFICATE_PASSWORD", 93 | "value": "", 94 | "required": false 95 | }, 96 | { 97 | "description": "Sets xa-pool/min-pool-size for the configured datasource.", 98 | "name": "DB_MIN_POOL_SIZE", 99 | "required": false 100 | }, 101 | { 102 | "description": "Sets xa-pool/max-pool-size for the configured datasource.", 103 | "name": "DB_MAX_POOL_SIZE", 104 | "required": false 105 | }, 106 | { 107 | "description": "Sets transaction-isolation for the configured datasource.", 108 | "name": "DB_TX_ISOLATION", 109 | "required": false 110 | }, 111 | { 112 | "description": "Sets how the table names are stored and compared.", 113 | "name": "MYSQL_LOWER_CASE_TABLE_NAMES", 114 | "required": false 115 | }, 116 | { 117 | "description": "The maximum permitted number of simultaneous client connections.", 118 | "name": "MYSQL_MAX_CONNECTIONS", 119 | "required": false 120 | }, 121 | { 122 | "description": "The minimum length of the word to be included in a FULLTEXT index.", 123 | "name": "MYSQL_FT_MIN_WORD_LEN", 124 | "required": false 125 | }, 126 | { 127 | "description": "The maximum length of the word to be included in a FULLTEXT index.", 128 | "name": "MYSQL_FT_MAX_WORD_LEN", 129 | "required": false 130 | }, 131 | { 132 | "description": "Controls the innodb_use_native_aio setting value if the native AIO is broken.", 133 | "name": "MYSQL_AIO", 134 | "required": false 135 | }, 136 | { 137 | "description": "Database user name", 138 | "name": "DB_USERNAME", 139 | "from": "user[a-zA-Z0-9]{3}", 140 | "generate": "expression", 141 | "required": true 142 | }, 143 | { 144 | "description": "Database user password", 145 | "name": "DB_PASSWORD", 146 | "from": "[a-zA-Z0-9]{8}", 147 | "generate": "expression", 148 | "required": true 149 | }, 150 | { 151 | "description": "JWS Admin User", 152 | "name": "JWS_ADMIN_USERNAME", 153 | "from": "[a-zA-Z0-9]{8}", 154 | "generate": "expression", 155 | "required": true 156 | }, 157 | { 158 | "description": "JWS Admin Password", 159 | "name": "JWS_ADMIN_PASSWORD", 160 | "from": "[a-zA-Z0-9]{8}", 161 | "generate": "expression", 162 | "required": true 163 | }, 164 | { 165 | "description": "GitHub trigger secret", 166 | "name": "GITHUB_WEBHOOK_SECRET", 167 | "from": "[a-zA-Z0-9]{8}", 168 | "generate": "expression", 169 | "required": true 170 | }, 171 | { 172 | "description": "Generic build trigger secret", 173 | "name": "GENERIC_WEBHOOK_SECRET", 174 | "from": "[a-zA-Z0-9]{8}", 175 | "generate": "expression", 176 | "required": true 177 | }, 178 | { 179 | "description": "Namespace in which the ImageStreams for Red Hat Middleware images are installed. These ImageStreams are normally installed in the openshift namespace. You should only need to modify this if you've installed the ImageStreams in a different namespace/project.", 180 | "name": "IMAGE_STREAM_NAMESPACE", 181 | "value": "openshift", 182 | "required": true 183 | } 184 | ], 185 | "objects": [ 186 | { 187 | "kind": "Service", 188 | "apiVersion": "v1", 189 | "spec": { 190 | "ports": [ 191 | { 192 | "port": 8080, 193 | "targetPort": 8080 194 | } 195 | ], 196 | "selector": { 197 | "deploymentConfig": "${APPLICATION_NAME}" 198 | } 199 | }, 200 | "metadata": { 201 | "name": "${APPLICATION_NAME}", 202 | "labels": { 203 | "application": "${APPLICATION_NAME}" 204 | }, 205 | "annotations": { 206 | "description": "The web server's http port." 207 | } 208 | } 209 | }, 210 | { 211 | "kind": "Service", 212 | "apiVersion": "v1", 213 | "spec": { 214 | "ports": [ 215 | { 216 | "port": 8443, 217 | "targetPort": 8443 218 | } 219 | ], 220 | "selector": { 221 | "deploymentConfig": "${APPLICATION_NAME}" 222 | } 223 | }, 224 | "metadata": { 225 | "name": "secure-${APPLICATION_NAME}", 226 | "labels": { 227 | "application": "${APPLICATION_NAME}" 228 | }, 229 | "annotations": { 230 | "description": "The web server's https port." 231 | } 232 | } 233 | }, 234 | { 235 | "kind": "Service", 236 | "apiVersion": "v1", 237 | "spec": { 238 | "ports": [ 239 | { 240 | "port": 3306, 241 | "targetPort": 3306 242 | } 243 | ], 244 | "selector": { 245 | "deploymentConfig": "${APPLICATION_NAME}-mysql" 246 | } 247 | }, 248 | "metadata": { 249 | "name": "${APPLICATION_NAME}-mysql", 250 | "labels": { 251 | "application": "${APPLICATION_NAME}" 252 | }, 253 | "annotations": { 254 | "description": "The database server's port." 255 | } 256 | } 257 | }, 258 | { 259 | "kind": "Route", 260 | "apiVersion": "v1", 261 | "id": "${APPLICATION_NAME}-http", 262 | "metadata": { 263 | "name": "${APPLICATION_NAME}", 264 | "labels": { 265 | "application": "${APPLICATION_NAME}" 266 | }, 267 | "annotations": { 268 | "description": "Route for application's http service." 269 | } 270 | }, 271 | "spec": { 272 | "host": "${HOSTNAME_HTTP}", 273 | "to": { 274 | "name": "${APPLICATION_NAME}" 275 | } 276 | } 277 | }, 278 | { 279 | "kind": "Route", 280 | "apiVersion": "v1", 281 | "id": "${APPLICATION_NAME}-https", 282 | "metadata": { 283 | "name": "secure-${APPLICATION_NAME}", 284 | "labels": { 285 | "application": "${APPLICATION_NAME}" 286 | }, 287 | "annotations": { 288 | "description": "Route for application's https service." 289 | } 290 | }, 291 | "spec": { 292 | "host": "${HOSTNAME_HTTPS}", 293 | "to": { 294 | "name": "secure-${APPLICATION_NAME}" 295 | }, 296 | "tls": { 297 | "termination": "passthrough" 298 | } 299 | } 300 | }, 301 | { 302 | "kind": "ImageStream", 303 | "apiVersion": "v1", 304 | "metadata": { 305 | "name": "${APPLICATION_NAME}", 306 | "labels": { 307 | "application": "${APPLICATION_NAME}" 308 | } 309 | } 310 | }, 311 | { 312 | "kind": "BuildConfig", 313 | "apiVersion": "v1", 314 | "metadata": { 315 | "name": "${APPLICATION_NAME}", 316 | "labels": { 317 | "application": "${APPLICATION_NAME}" 318 | } 319 | }, 320 | "spec": { 321 | "source": { 322 | "type": "Git", 323 | "git": { 324 | "uri": "${SOURCE_REPOSITORY_URL}", 325 | "ref": "${SOURCE_REPOSITORY_REF}" 326 | }, 327 | "contextDir": "${CONTEXT_DIR}" 328 | }, 329 | "strategy": { 330 | "type": "Source", 331 | "sourceStrategy": { 332 | "forcePull": true, 333 | "from": { 334 | "kind": "ImageStreamTag", 335 | "namespace": "${IMAGE_STREAM_NAMESPACE}", 336 | "name": "jboss-webserver30-tomcat7-openshift:1.2" 337 | } 338 | } 339 | }, 340 | "output": { 341 | "to": { 342 | "kind": "ImageStreamTag", 343 | "name": "${APPLICATION_NAME}:latest" 344 | } 345 | }, 346 | "triggers": [ 347 | { 348 | "type": "GitHub", 349 | "github": { 350 | "secret": "${GITHUB_WEBHOOK_SECRET}" 351 | } 352 | }, 353 | { 354 | "type": "Generic", 355 | "generic": { 356 | "secret": "${GENERIC_WEBHOOK_SECRET}" 357 | } 358 | }, 359 | { 360 | "type": "ImageChange", 361 | "imageChange": {} 362 | }, 363 | { 364 | "type": "ConfigChange" 365 | } 366 | ] 367 | } 368 | }, 369 | { 370 | "kind": "DeploymentConfig", 371 | "apiVersion": "v1", 372 | "metadata": { 373 | "name": "${APPLICATION_NAME}", 374 | "labels": { 375 | "application": "${APPLICATION_NAME}" 376 | } 377 | }, 378 | "spec": { 379 | "strategy": { 380 | "type": "Recreate" 381 | }, 382 | "triggers": [ 383 | { 384 | "type": "ImageChange", 385 | "imageChangeParams": { 386 | "automatic": true, 387 | "containerNames": [ 388 | "${APPLICATION_NAME}" 389 | ], 390 | "from": { 391 | "kind": "ImageStreamTag", 392 | "name": "${APPLICATION_NAME}:latest" 393 | } 394 | } 395 | }, 396 | { 397 | "type": "ConfigChange" 398 | } 399 | ], 400 | "replicas": 1, 401 | "selector": { 402 | "deploymentConfig": "${APPLICATION_NAME}" 403 | }, 404 | "template": { 405 | "metadata": { 406 | "name": "${APPLICATION_NAME}", 407 | "labels": { 408 | "deploymentConfig": "${APPLICATION_NAME}", 409 | "application": "${APPLICATION_NAME}" 410 | } 411 | }, 412 | "spec": { 413 | "serviceAccountName": "jws-service-account", 414 | "terminationGracePeriodSeconds": 60, 415 | "containers": [ 416 | { 417 | "name": "${APPLICATION_NAME}", 418 | "image": "${APPLICATION_NAME}", 419 | "imagePullPolicy": "Always", 420 | "readinessProbe": { 421 | "exec": { 422 | "command": [ 423 | "/bin/bash", 424 | "-c", 425 | "curl -s -u ${JWS_ADMIN_USERNAME}:${JWS_ADMIN_PASSWORD} 'http://localhost:8080/manager/jmxproxy/?get=Catalina%3Atype%3DServer&att=stateName' |grep -iq 'stateName *= *STARTED'" 426 | ] 427 | } 428 | }, 429 | "volumeMounts": [ 430 | { 431 | "name": "jws-certificate-volume", 432 | "mountPath": "/etc/jws-secret-volume", 433 | "readOnly": true 434 | } 435 | ], 436 | "ports": [ 437 | { 438 | "name": "jolokia", 439 | "containerPort": 8778, 440 | "protocol": "TCP" 441 | }, 442 | { 443 | "name": "http", 444 | "containerPort": 8080, 445 | "protocol": "TCP" 446 | }, 447 | { 448 | "name": "https", 449 | "containerPort": 8443, 450 | "protocol": "TCP" 451 | } 452 | ], 453 | "env": [ 454 | { 455 | "name": "DB_SERVICE_PREFIX_MAPPING", 456 | "value": "${APPLICATION_NAME}-mysql=DB" 457 | }, 458 | { 459 | "name": "DB_JNDI", 460 | "value": "${DB_JNDI}" 461 | }, 462 | { 463 | "name": "DB_USERNAME", 464 | "value": "${DB_USERNAME}" 465 | }, 466 | { 467 | "name": "DB_PASSWORD", 468 | "value": "${DB_PASSWORD}" 469 | }, 470 | { 471 | "name": "DB_DATABASE", 472 | "value": "${DB_DATABASE}" 473 | }, 474 | { 475 | "name": "DB_MIN_POOL_SIZE", 476 | "value": "${DB_MIN_POOL_SIZE}" 477 | }, 478 | { 479 | "name": "DB_MAX_POOL_SIZE", 480 | "value": "${DB_MAX_POOL_SIZE}" 481 | }, 482 | { 483 | "name": "DB_TX_ISOLATION", 484 | "value": "${DB_TX_ISOLATION}" 485 | }, 486 | { 487 | "name": "JWS_HTTPS_CERTIFICATE_DIR", 488 | "value": "/etc/jws-secret-volume" 489 | }, 490 | { 491 | "name": "JWS_HTTPS_CERTIFICATE", 492 | "value": "${JWS_HTTPS_CERTIFICATE}" 493 | }, 494 | { 495 | "name": "JWS_HTTPS_CERTIFICATE_KEY", 496 | "value": "${JWS_HTTPS_CERTIFICATE_KEY}" 497 | }, 498 | { 499 | "name": "JWS_HTTPS_CERTIFICATE_PASSWORD", 500 | "value": "${JWS_HTTPS_CERTIFICATE_PASSWORD}" 501 | }, 502 | { 503 | "name": "JWS_ADMIN_USERNAME", 504 | "value": "${JWS_ADMIN_USERNAME}" 505 | }, 506 | { 507 | "name": "JWS_ADMIN_PASSWORD", 508 | "value": "${JWS_ADMIN_PASSWORD}" 509 | } 510 | ] 511 | } 512 | ], 513 | "volumes": [ 514 | { 515 | "name": "jws-certificate-volume", 516 | "secret": { 517 | "secretName": "${JWS_HTTPS_SECRET}" 518 | } 519 | } 520 | ] 521 | } 522 | } 523 | } 524 | }, 525 | { 526 | "kind": "DeploymentConfig", 527 | "apiVersion": "v1", 528 | "metadata": { 529 | "name": "${APPLICATION_NAME}-mysql", 530 | "labels": { 531 | "application": "${APPLICATION_NAME}" 532 | } 533 | }, 534 | "spec": { 535 | "strategy": { 536 | "type": "Recreate" 537 | }, 538 | "triggers": [ 539 | { 540 | "type": "ImageChange", 541 | "imageChangeParams": { 542 | "automatic": true, 543 | "containerNames": [ 544 | "${APPLICATION_NAME}-mysql" 545 | ], 546 | "from": { 547 | "kind": "ImageStreamTag", 548 | "namespace": "${IMAGE_STREAM_NAMESPACE}", 549 | "name": "mysql:latest" 550 | } 551 | } 552 | }, 553 | { 554 | "type": "ConfigChange" 555 | } 556 | ], 557 | "replicas": 1, 558 | "selector": { 559 | "deploymentConfig": "${APPLICATION_NAME}-mysql" 560 | }, 561 | "template": { 562 | "metadata": { 563 | "name": "${APPLICATION_NAME}-mysql", 564 | "labels": { 565 | "deploymentConfig": "${APPLICATION_NAME}-mysql", 566 | "application": "${APPLICATION_NAME}" 567 | } 568 | }, 569 | "spec": { 570 | "terminationGracePeriodSeconds": 60, 571 | "containers": [ 572 | { 573 | "name": "${APPLICATION_NAME}-mysql", 574 | "image": "mysql", 575 | "ports": [ 576 | { 577 | "containerPort": 3306, 578 | "protocol": "TCP" 579 | } 580 | ], 581 | "volumeMounts": [ 582 | { 583 | "mountPath": "/var/lib/mysql/data", 584 | "name": "${APPLICATION_NAME}-mysql-pvol" 585 | } 586 | ], 587 | "env": [ 588 | { 589 | "name": "MYSQL_USER", 590 | "value": "${DB_USERNAME}" 591 | }, 592 | { 593 | "name": "MYSQL_PASSWORD", 594 | "value": "${DB_PASSWORD}" 595 | }, 596 | { 597 | "name": "MYSQL_DATABASE", 598 | "value": "${DB_DATABASE}" 599 | }, 600 | { 601 | "name": "MYSQL_LOWER_CASE_TABLE_NAMES", 602 | "value": "${MYSQL_LOWER_CASE_TABLE_NAMES}" 603 | }, 604 | { 605 | "name": "MYSQL_MAX_CONNECTIONS", 606 | "value": "${MYSQL_MAX_CONNECTIONS}" 607 | }, 608 | { 609 | "name": "MYSQL_FT_MIN_WORD_LEN", 610 | "value": "${MYSQL_FT_MIN_WORD_LEN}" 611 | }, 612 | { 613 | "name": "MYSQL_FT_MAX_WORD_LEN", 614 | "value": "${MYSQL_FT_MAX_WORD_LEN}" 615 | }, 616 | { 617 | "name": "MYSQL_AIO", 618 | "value": "${MYSQL_AIO}" 619 | } 620 | ] 621 | } 622 | ], 623 | "volumes": [ 624 | { 625 | "name": "${APPLICATION_NAME}-mysql-pvol", 626 | "persistentVolumeClaim": { 627 | "claimName": "${APPLICATION_NAME}-mysql-claim" 628 | } 629 | } 630 | ] 631 | } 632 | } 633 | } 634 | }, 635 | { 636 | "apiVersion": "v1", 637 | "kind": "PersistentVolumeClaim", 638 | "metadata": { 639 | "name": "${APPLICATION_NAME}-mysql-claim", 640 | "labels": { 641 | "application": "${APPLICATION_NAME}" 642 | } 643 | }, 644 | "spec": { 645 | "accessModes": [ 646 | "ReadWriteOnce" 647 | ], 648 | "resources": { 649 | "requests": { 650 | "storage": "${VOLUME_CAPACITY}" 651 | } 652 | } 653 | } 654 | } 655 | ] 656 | } 657 | -------------------------------------------------------------------------------- /services/openshift/templates/common/nodejs-mongodb.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "nodejs-mongodb-example", 6 | "annotations": { 7 | "openshift.io/display-name": "Node.js + MongoDB (Ephemeral)", 8 | "description": "An example Node.js application with a MongoDB database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.", 9 | "tags": "quickstart,nodejs", 10 | "iconClass": "icon-nodejs" 11 | } 12 | }, 13 | "message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.", 14 | "labels": { 15 | "template": "nodejs-mongodb-example" 16 | }, 17 | "objects": [ 18 | { 19 | "kind": "Secret", 20 | "apiVersion": "v1", 21 | "metadata": { 22 | "name": "${NAME}" 23 | }, 24 | "stringData": { 25 | "database-user": "${DATABASE_USER}", 26 | "database-password": "${DATABASE_PASSWORD}", 27 | "database-admin-password" : "${DATABASE_ADMIN_PASSWORD}" 28 | } 29 | }, 30 | { 31 | "kind": "Service", 32 | "apiVersion": "v1", 33 | "metadata": { 34 | "name": "${NAME}", 35 | "annotations": { 36 | "description": "Exposes and load balances the application pods", 37 | "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]" 38 | } 39 | }, 40 | "spec": { 41 | "ports": [ 42 | { 43 | "name": "web", 44 | "port": 8080, 45 | "targetPort": 8080 46 | } 47 | ], 48 | "selector": { 49 | "name": "${NAME}" 50 | } 51 | } 52 | }, 53 | { 54 | "kind": "Route", 55 | "apiVersion": "v1", 56 | "metadata": { 57 | "name": "${NAME}" 58 | }, 59 | "spec": { 60 | "host": "${APPLICATION_DOMAIN}", 61 | "to": { 62 | "kind": "Service", 63 | "name": "${NAME}" 64 | } 65 | } 66 | }, 67 | { 68 | "kind": "ImageStream", 69 | "apiVersion": "v1", 70 | "metadata": { 71 | "name": "${NAME}", 72 | "annotations": { 73 | "description": "Keeps track of changes in the application image" 74 | } 75 | } 76 | }, 77 | { 78 | "kind": "BuildConfig", 79 | "apiVersion": "v1", 80 | "metadata": { 81 | "name": "${NAME}", 82 | "annotations": { 83 | "description": "Defines how to build the application" 84 | } 85 | }, 86 | "spec": { 87 | "source": { 88 | "type": "Git", 89 | "git": { 90 | "uri": "${SOURCE_REPOSITORY_URL}", 91 | "ref": "${SOURCE_REPOSITORY_REF}" 92 | }, 93 | "contextDir": "${CONTEXT_DIR}" 94 | }, 95 | "strategy": { 96 | "type": "Source", 97 | "sourceStrategy": { 98 | "from": { 99 | "kind": "ImageStreamTag", 100 | "namespace": "${NAMESPACE}", 101 | "name": "nodejs:4" 102 | }, 103 | "env": [ 104 | { 105 | "name": "NPM_MIRROR", 106 | "value": "${NPM_MIRROR}" 107 | } 108 | ] 109 | } 110 | }, 111 | "output": { 112 | "to": { 113 | "kind": "ImageStreamTag", 114 | "name": "${NAME}:latest" 115 | } 116 | }, 117 | "triggers": [ 118 | { 119 | "type": "ImageChange" 120 | }, 121 | { 122 | "type": "ConfigChange" 123 | }, 124 | { 125 | "type": "GitHub", 126 | "github": { 127 | "secret": "${GITHUB_WEBHOOK_SECRET}" 128 | } 129 | }, 130 | { 131 | "type": "Generic", 132 | "generic": { 133 | "secret": "${GENERIC_WEBHOOK_SECRET}" 134 | } 135 | } 136 | ], 137 | "postCommit": { 138 | "script": "npm test" 139 | } 140 | } 141 | }, 142 | { 143 | "kind": "DeploymentConfig", 144 | "apiVersion": "v1", 145 | "metadata": { 146 | "name": "${NAME}", 147 | "annotations": { 148 | "description": "Defines how to deploy the application server" 149 | } 150 | }, 151 | "spec": { 152 | "strategy": { 153 | "type": "Rolling" 154 | }, 155 | "triggers": [ 156 | { 157 | "type": "ImageChange", 158 | "imageChangeParams": { 159 | "automatic": true, 160 | "containerNames": [ 161 | "nodejs-mongodb-example" 162 | ], 163 | "from": { 164 | "kind": "ImageStreamTag", 165 | "name": "${NAME}:latest" 166 | } 167 | } 168 | }, 169 | { 170 | "type": "ConfigChange" 171 | } 172 | ], 173 | "replicas": 1, 174 | "selector": { 175 | "name": "${NAME}" 176 | }, 177 | "template": { 178 | "metadata": { 179 | "name": "${NAME}", 180 | "labels": { 181 | "name": "${NAME}" 182 | } 183 | }, 184 | "spec": { 185 | "containers": [ 186 | { 187 | "name": "nodejs-mongodb-example", 188 | "image": " ", 189 | "ports": [ 190 | { 191 | "containerPort": 8080 192 | } 193 | ], 194 | "env": [ 195 | { 196 | "name": "DATABASE_SERVICE_NAME", 197 | "value": "${DATABASE_SERVICE_NAME}" 198 | }, 199 | { 200 | "name": "MONGODB_USER", 201 | "valueFrom": { 202 | "secretKeyRef" : { 203 | "name" : "${NAME}", 204 | "key" : "database-user" 205 | } 206 | } 207 | }, 208 | { 209 | "name": "MONGODB_PASSWORD", 210 | "valueFrom": { 211 | "secretKeyRef" : { 212 | "name" : "${NAME}", 213 | "key" : "database-password" 214 | } 215 | } 216 | }, 217 | { 218 | "name": "MONGODB_DATABASE", 219 | "value": "${DATABASE_NAME}" 220 | }, 221 | { 222 | "name": "MONGODB_ADMIN_PASSWORD", 223 | "valueFrom": { 224 | "secretKeyRef" : { 225 | "name" : "${NAME}", 226 | "key" : "database-admin-password" 227 | } 228 | } 229 | } 230 | ], 231 | "readinessProbe": { 232 | "timeoutSeconds": 3, 233 | "initialDelaySeconds": 3, 234 | "httpGet": { 235 | "path": "/pagecount", 236 | "port": 8080 237 | } 238 | }, 239 | "livenessProbe": { 240 | "timeoutSeconds": 3, 241 | "initialDelaySeconds": 30, 242 | "httpGet": { 243 | "path": "/pagecount", 244 | "port": 8080 245 | } 246 | }, 247 | "resources": { 248 | "limits": { 249 | "memory": "${MEMORY_LIMIT}" 250 | } 251 | } 252 | } 253 | ] 254 | } 255 | } 256 | } 257 | }, 258 | { 259 | "kind": "Service", 260 | "apiVersion": "v1", 261 | "metadata": { 262 | "name": "${DATABASE_SERVICE_NAME}", 263 | "annotations": { 264 | "description": "Exposes the database server" 265 | } 266 | }, 267 | "spec": { 268 | "ports": [ 269 | { 270 | "name": "mongodb", 271 | "port": 27017, 272 | "targetPort": 27017 273 | } 274 | ], 275 | "selector": { 276 | "name": "${DATABASE_SERVICE_NAME}" 277 | } 278 | } 279 | }, 280 | { 281 | "kind": "DeploymentConfig", 282 | "apiVersion": "v1", 283 | "metadata": { 284 | "name": "${DATABASE_SERVICE_NAME}", 285 | "annotations": { 286 | "description": "Defines how to deploy the database" 287 | } 288 | }, 289 | "spec": { 290 | "strategy": { 291 | "type": "Recreate" 292 | }, 293 | "triggers": [ 294 | { 295 | "type": "ImageChange", 296 | "imageChangeParams": { 297 | "automatic": true, 298 | "containerNames": [ 299 | "mongodb" 300 | ], 301 | "from": { 302 | "kind": "ImageStreamTag", 303 | "namespace": "${NAMESPACE}", 304 | "name": "mongodb:3.2" 305 | } 306 | } 307 | }, 308 | { 309 | "type": "ConfigChange" 310 | } 311 | ], 312 | "replicas": 1, 313 | "selector": { 314 | "name": "${DATABASE_SERVICE_NAME}" 315 | }, 316 | "template": { 317 | "metadata": { 318 | "name": "${DATABASE_SERVICE_NAME}", 319 | "labels": { 320 | "name": "${DATABASE_SERVICE_NAME}" 321 | } 322 | }, 323 | "spec": { 324 | "containers": [ 325 | { 326 | "name": "mongodb", 327 | "image": " ", 328 | "ports": [ 329 | { 330 | "containerPort": 27017 331 | } 332 | ], 333 | "env": [ 334 | { 335 | "name": "MONGODB_USER", 336 | "valueFrom": { 337 | "secretKeyRef" : { 338 | "name" : "${NAME}", 339 | "key" : "database-user" 340 | } 341 | } 342 | }, 343 | { 344 | "name": "MONGODB_PASSWORD", 345 | "valueFrom": { 346 | "secretKeyRef" : { 347 | "name" : "${NAME}", 348 | "key" : "database-password" 349 | } 350 | } 351 | }, 352 | { 353 | "name": "MONGODB_DATABASE", 354 | "value": "${DATABASE_NAME}" 355 | }, 356 | { 357 | "name": "MONGODB_ADMIN_PASSWORD", 358 | "valueFrom": { 359 | "secretKeyRef" : { 360 | "name" : "${NAME}", 361 | "key" : "database-admin-password" 362 | } 363 | } 364 | } 365 | ], 366 | "readinessProbe": { 367 | "timeoutSeconds": 1, 368 | "initialDelaySeconds": 3, 369 | "exec": { 370 | "command": [ 371 | "/bin/sh", 372 | "-i", 373 | "-c", 374 | "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\"" 375 | ] 376 | } 377 | }, 378 | "livenessProbe": { 379 | "timeoutSeconds": 1, 380 | "initialDelaySeconds": 30, 381 | "tcpSocket": { 382 | "port": 27017 383 | } 384 | }, 385 | "resources": { 386 | "limits": { 387 | "memory": "${MEMORY_MONGODB_LIMIT}" 388 | } 389 | }, 390 | "volumeMounts": [ 391 | { 392 | "name": "${DATABASE_SERVICE_NAME}-data", 393 | "mountPath": "/var/lib/mongodb/data" 394 | } 395 | ] 396 | } 397 | ], 398 | "volumes": [ 399 | { 400 | "name": "${DATABASE_SERVICE_NAME}-data", 401 | "emptyDir": { 402 | "medium": "" 403 | } 404 | } 405 | ] 406 | } 407 | } 408 | } 409 | } 410 | ], 411 | "parameters": [ 412 | { 413 | "name": "NAME", 414 | "displayName": "Name", 415 | "description": "The name assigned to all of the frontend objects defined in this template.", 416 | "required": true, 417 | "value": "nodejs-mongodb-example" 418 | }, 419 | { 420 | "name": "NAMESPACE", 421 | "displayName": "Namespace", 422 | "description": "The OpenShift Namespace where the ImageStream resides.", 423 | "required": true, 424 | "value": "openshift" 425 | }, 426 | { 427 | "name": "MEMORY_LIMIT", 428 | "displayName": "Memory Limit", 429 | "description": "Maximum amount of memory the Node.js container can use.", 430 | "required": true, 431 | "value": "512Mi" 432 | }, 433 | { 434 | "name": "MEMORY_MONGODB_LIMIT", 435 | "displayName": "Memory Limit (MongoDB)", 436 | "description": "Maximum amount of memory the MongoDB container can use.", 437 | "required": true, 438 | "value": "512Mi" 439 | }, 440 | { 441 | "name": "SOURCE_REPOSITORY_URL", 442 | "displayName": "Git Repository URL", 443 | "description": "The URL of the repository with your application source code.", 444 | "required": true, 445 | "value": "https://github.com/openshift/nodejs-ex.git" 446 | }, 447 | { 448 | "name": "SOURCE_REPOSITORY_REF", 449 | "displayName": "Git Reference", 450 | "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." 451 | }, 452 | { 453 | "name": "CONTEXT_DIR", 454 | "displayName": "Context Directory", 455 | "description": "Set this to the relative path to your project if it is not in the root of your repository." 456 | }, 457 | { 458 | "name": "APPLICATION_DOMAIN", 459 | "displayName": "Application Hostname", 460 | "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.", 461 | "value": "" 462 | }, 463 | { 464 | "name": "GITHUB_WEBHOOK_SECRET", 465 | "displayName": "GitHub Webhook Secret", 466 | "description": "A secret string used to configure the GitHub webhook.", 467 | "generate": "expression", 468 | "from": "[a-zA-Z0-9]{40}" 469 | }, 470 | { 471 | "name": "GENERIC_WEBHOOK_SECRET", 472 | "displayName": "Generic Webhook Secret", 473 | "description": "A secret string used to configure the Generic webhook.", 474 | "generate": "expression", 475 | "from": "[a-zA-Z0-9]{40}" 476 | }, 477 | { 478 | "name": "DATABASE_SERVICE_NAME", 479 | "displayName": "Database Service Name", 480 | "required": true, 481 | "value": "mongodb" 482 | }, 483 | { 484 | "name": "DATABASE_USER", 485 | "displayName": "MongoDB Username", 486 | "description": "Username for MongoDB user that will be used for accessing the database.", 487 | "generate": "expression", 488 | "from": "user[A-Z0-9]{3}" 489 | }, 490 | { 491 | "name": "DATABASE_PASSWORD", 492 | "displayName": "MongoDB Password", 493 | "description": "Password for the MongoDB user.", 494 | "generate": "expression", 495 | "from": "[a-zA-Z0-9]{16}" 496 | }, 497 | { 498 | "name": "DATABASE_NAME", 499 | "displayName": "Database Name", 500 | "required": true, 501 | "value": "sampledb" 502 | }, 503 | { 504 | "name": "DATABASE_ADMIN_PASSWORD", 505 | "displayName": "Database Administrator Password", 506 | "description": "Password for the database admin user.", 507 | "generate": "expression", 508 | "from": "[a-zA-Z0-9]{16}" 509 | }, 510 | { 511 | "name": "NPM_MIRROR", 512 | "displayName": "Custom NPM Mirror URL", 513 | "description": "The custom NPM mirror URL", 514 | "value": "" 515 | } 516 | ] 517 | } 518 | -------------------------------------------------------------------------------- /services/openshift/templates/common/nodejs.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "nodejs-example", 6 | "annotations": { 7 | "openshift.io/display-name": "Node.js", 8 | "description": "An example Node.js application with no database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.", 9 | "tags": "quickstart,nodejs", 10 | "iconClass": "icon-nodejs" 11 | } 12 | }, 13 | "message": "The following service(s) have been created in your project: ${NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.", 14 | "labels": { 15 | "template": "nodejs-example" 16 | }, 17 | "objects": [ 18 | { 19 | "kind": "Service", 20 | "apiVersion": "v1", 21 | "metadata": { 22 | "name": "${NAME}", 23 | "annotations": { 24 | "description": "Exposes and load balances the application pods" 25 | } 26 | }, 27 | "spec": { 28 | "ports": [ 29 | { 30 | "name": "web", 31 | "port": 8080, 32 | "targetPort": 8080 33 | } 34 | ], 35 | "selector": { 36 | "name": "${NAME}" 37 | } 38 | } 39 | }, 40 | { 41 | "kind": "Route", 42 | "apiVersion": "v1", 43 | "metadata": { 44 | "name": "${NAME}" 45 | }, 46 | "spec": { 47 | "host": "${APPLICATION_DOMAIN}", 48 | "to": { 49 | "kind": "Service", 50 | "name": "${NAME}" 51 | } 52 | } 53 | }, 54 | { 55 | "kind": "ImageStream", 56 | "apiVersion": "v1", 57 | "metadata": { 58 | "name": "${NAME}", 59 | "annotations": { 60 | "description": "Keeps track of changes in the application image" 61 | } 62 | } 63 | }, 64 | { 65 | "kind": "BuildConfig", 66 | "apiVersion": "v1", 67 | "metadata": { 68 | "name": "${NAME}", 69 | "annotations": { 70 | "description": "Defines how to build the application" 71 | } 72 | }, 73 | "spec": { 74 | "source": { 75 | "type": "Git", 76 | "git": { 77 | "uri": "${SOURCE_REPOSITORY_URL}", 78 | "ref": "${SOURCE_REPOSITORY_REF}" 79 | }, 80 | "contextDir": "${CONTEXT_DIR}" 81 | }, 82 | "strategy": { 83 | "type": "Source", 84 | "sourceStrategy": { 85 | "from": { 86 | "kind": "ImageStreamTag", 87 | "namespace": "${NAMESPACE}", 88 | "name": "nodejs:4" 89 | }, 90 | "env": [ 91 | { 92 | "name": "NPM_MIRROR", 93 | "value": "${NPM_MIRROR}" 94 | } 95 | ] 96 | } 97 | }, 98 | "output": { 99 | "to": { 100 | "kind": "ImageStreamTag", 101 | "name": "${NAME}:latest" 102 | } 103 | }, 104 | "triggers": [ 105 | { 106 | "type": "ImageChange" 107 | }, 108 | { 109 | "type": "ConfigChange" 110 | }, 111 | { 112 | "type": "GitHub", 113 | "github": { 114 | "secret": "${GITHUB_WEBHOOK_SECRET}" 115 | } 116 | }, 117 | { 118 | "type": "Generic", 119 | "generic": { 120 | "secret": "${GENERIC_WEBHOOK_SECRET}" 121 | } 122 | } 123 | ], 124 | "postCommit": { 125 | "script": "npm test" 126 | } 127 | } 128 | }, 129 | { 130 | "kind": "DeploymentConfig", 131 | "apiVersion": "v1", 132 | "metadata": { 133 | "name": "${NAME}", 134 | "annotations": { 135 | "description": "Defines how to deploy the application server" 136 | } 137 | }, 138 | "spec": { 139 | "strategy": { 140 | "type": "Rolling" 141 | }, 142 | "triggers": [ 143 | { 144 | "type": "ImageChange", 145 | "imageChangeParams": { 146 | "automatic": true, 147 | "containerNames": [ 148 | "nodejs-example" 149 | ], 150 | "from": { 151 | "kind": "ImageStreamTag", 152 | "name": "${NAME}:latest" 153 | } 154 | } 155 | }, 156 | { 157 | "type": "ConfigChange" 158 | } 159 | ], 160 | "replicas": 1, 161 | "selector": { 162 | "name": "${NAME}" 163 | }, 164 | "template": { 165 | "metadata": { 166 | "name": "${NAME}", 167 | "labels": { 168 | "name": "${NAME}" 169 | } 170 | }, 171 | "spec": { 172 | "containers": [ 173 | { 174 | "name": "nodejs-example", 175 | "image": " ", 176 | "ports": [ 177 | { 178 | "containerPort": 8080 179 | } 180 | ], 181 | "readinessProbe": { 182 | "timeoutSeconds": 3, 183 | "initialDelaySeconds": 3, 184 | "httpGet": { 185 | "path": "/", 186 | "port": 8080 187 | } 188 | }, 189 | "livenessProbe": { 190 | "timeoutSeconds": 3, 191 | "initialDelaySeconds": 30, 192 | "httpGet": { 193 | "path": "/", 194 | "port": 8080 195 | } 196 | }, 197 | "resources": { 198 | "limits": { 199 | "memory": "${MEMORY_LIMIT}" 200 | } 201 | }, 202 | "env": [ 203 | ], 204 | "resources": { 205 | "limits": { 206 | "memory": "${MEMORY_LIMIT}" 207 | } 208 | } 209 | } 210 | ] 211 | } 212 | } 213 | } 214 | } 215 | ], 216 | "parameters": [ 217 | { 218 | "name": "NAME", 219 | "displayName": "Name", 220 | "description": "The name assigned to all of the frontend objects defined in this template.", 221 | "required": true, 222 | "value": "nodejs-example" 223 | }, 224 | { 225 | "name": "NAMESPACE", 226 | "displayName": "Namespace", 227 | "description": "The OpenShift Namespace where the ImageStream resides.", 228 | "required": true, 229 | "value": "openshift" 230 | }, 231 | { 232 | "name": "MEMORY_LIMIT", 233 | "displayName": "Memory Limit", 234 | "description": "Maximum amount of memory the container can use.", 235 | "required": true, 236 | "value": "512Mi" 237 | }, 238 | { 239 | "name": "SOURCE_REPOSITORY_URL", 240 | "displayName": "Git Repository URL", 241 | "description": "The URL of the repository with your application source code.", 242 | "required": true, 243 | "value": "https://github.com/openshift/nodejs-ex.git" 244 | }, 245 | { 246 | "name": "SOURCE_REPOSITORY_REF", 247 | "displayName": "Git Reference", 248 | "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch." 249 | }, 250 | { 251 | "name": "CONTEXT_DIR", 252 | "displayName": "Context Directory", 253 | "description": "Set this to the relative path to your project if it is not in the root of your repository." 254 | }, 255 | { 256 | "name": "APPLICATION_DOMAIN", 257 | "displayName": "Application Hostname", 258 | "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.", 259 | "value": "" 260 | }, 261 | { 262 | "name": "GITHUB_WEBHOOK_SECRET", 263 | "displayName": "GitHub Webhook Secret", 264 | "description": "A secret string used to configure the GitHub webhook.", 265 | "generate": "expression", 266 | "from": "[a-zA-Z0-9]{40}" 267 | }, 268 | { 269 | "name": "GENERIC_WEBHOOK_SECRET", 270 | "displayName": "Generic Webhook Secret", 271 | "description": "A secret string used to configure the Generic webhook.", 272 | "generate": "expression", 273 | "from": "[a-zA-Z0-9]{40}" 274 | }, 275 | { 276 | "name": "NPM_MIRROR", 277 | "displayName": "Custom NPM Mirror URL", 278 | "description": "The custom NPM mirror URL", 279 | "value": "" 280 | } 281 | ] 282 | } 283 | -------------------------------------------------------------------------------- /utils/add_insecure_registry: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o pipefail 4 | set -o nounset 5 | 6 | docker_conf_file='/etc/sysconfig/docker' 7 | is_restart_req=false 8 | registry="" 9 | 10 | 11 | function usage 12 | { 13 | echo "usage: $0 [-r | --registry] | [-h | --help]" 14 | } 15 | 16 | # Handle command line arguments 17 | while [ $# -gt 0 ]; do 18 | case $1 in 19 | -r | --registry ) shift 20 | registry=$1 21 | ;; 22 | -h | --help ) usage 23 | exit 24 | ;; 25 | esac 26 | shift 27 | done 28 | 29 | function init_insecure_reg() 30 | { 31 | if grep -q '# INSECURE_REGISTRY' ${docker_conf_file} 32 | then 33 | sed -i.orig "/# INSECURE_REGISTRY=*/c\INSECURE_REGISTRY=\"\"" ${docker_conf_file} 34 | fi 35 | } 36 | 37 | function append_insecure_reg() 38 | { 39 | local registry=$1 40 | local orig_str=`grep '^INSECURE_REGISTRY' ${docker_conf_file}` 41 | 42 | # Check if the registry is already part of insecure registry, if not add it 43 | if ! echo ${orig_str} | grep -q ${registry} 44 | then 45 | local replace_str="INSECURE_REGISTRY=\"" 46 | local add_str="INSECURE_REGISTRY=\" --insecure-registry ${registry}" 47 | local result_str="${orig_str/$replace_str/$add_str}" 48 | 49 | # Put the result string in the ${docker_conf_file} 50 | sed -i.back "s|${orig_str}|${result_str}|" ${docker_conf_file} 51 | is_restart_req=true 52 | fi 53 | } 54 | 55 | # Main 56 | init_insecure_reg 57 | if ! test -z $registry ; then 58 | append_insecure_reg ${registry} 59 | fi 60 | 61 | # Restart the docker demon if $is_restart_req is set to true 62 | if [ "$is_restart_req" = true ] ; then 63 | systemctl restart docker 64 | fi 65 | -------------------------------------------------------------------------------- /utils/cert-gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Generate certs pair for configuring TLS enabled docker daemon 3 | . /etc/sysconfig/docker 4 | 5 | if [ -e $DOCKER_CERT_PATH/ca.pem ]; then 6 | # Certificates already generated 7 | exit 8 | fi 9 | 10 | function randomString { 11 | # If a param was passed, it's the length of the string we want 12 | if [[ -n $1 ]] && [[ "$1" -lt 20 ]]; then 13 | local myStrLength=$1; 14 | else 15 | # otherwise set to default 16 | local myStrLength=8; 17 | fi 18 | 19 | dd if=/dev/urandom bs=1 2>/dev/null | tr -dc '[:alnum:]' | dd bs=1 count=$myStrLength 2>/dev/null 20 | } 21 | 22 | # Get a temporary workspace 23 | dir=`mktemp -d` 24 | cd $dir 25 | 26 | # Get a random password for the CA and save it 27 | passfile=tmp.pass 28 | password=$(randomString 10) 29 | echo $password > $passfile 30 | 31 | # Generate the CA 32 | openssl genrsa -aes256 -passout file:$passfile -out ca-key.pem 2048 33 | openssl req -new -x509 -passin file:$passfile -days 365 -key ca-key.pem -sha256 -out ca.pem -subj "/C=/ST=/L=/O=/OU=/CN=example.com" 34 | 35 | # Generate Server Key and Sign it 36 | openssl genrsa -out server-key.pem 2048 37 | openssl req -subj "/CN=example.com" -new -key server-key.pem -out server.csr 38 | # Allow from routable local IP 39 | extip=`ip -o -4 addr show up |egrep -v ': docker|: lo' |tail -1 | awk '{print $4}' |cut -f1 -d\/` 40 | extipfile=extfile.cnf 41 | echo subjectAltName = IP:$extip > $extipfile 42 | openssl x509 -req -days 365 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -passin file:$passfile -extfile $extipfile 43 | 44 | # Generate the Client Key and Sign it 45 | openssl genrsa -out key.pem 2048 46 | openssl req -subj '/CN=client' -new -key key.pem -out client.csr 47 | extfile=tmp.ext 48 | echo extendedKeyUsage = clientAuth > $extfile 49 | openssl x509 -req -days 365 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile $extfile -passin file:$passfile 50 | 51 | # Clean up 52 | 53 | # set the cert path as configured in /etc/sysconfig/docker 54 | 55 | # Move files into place 56 | mv ca.pem $DOCKER_CERT_PATH 57 | mv server-cert.pem $DOCKER_CERT_PATH 58 | mv server-key.pem $DOCKER_CERT_PATH 59 | 60 | # Since the default user is vagrant and it can run docker without sudo 61 | CLIENT_SIDE_CERT_PATH=/home/vagrant/.docker 62 | 63 | mkdir -p $CLIENT_SIDE_CERT_PATH 64 | cp $DOCKER_CERT_PATH/ca.pem $CLIENT_SIDE_CERT_PATH 65 | mv cert.pem key.pem $CLIENT_SIDE_CERT_PATH 66 | 67 | chown vagrant:vagrant $CLIENT_SIDE_CERT_PATH 68 | 69 | chmod 0444 $CLIENT_SIDE_CERT_PATH/ca.pem 70 | chmod 0444 $CLIENT_SIDE_CERT_PATH/cert.pem 71 | chmod 0444 $CLIENT_SIDE_CERT_PATH/key.pem 72 | chown vagrant:vagrant $CLIENT_SIDE_CERT_PATH/ca.pem 73 | chown vagrant:vagrant $CLIENT_SIDE_CERT_PATH/cert.pem 74 | chown vagrant:vagrant $CLIENT_SIDE_CERT_PATH/key.pem 75 | 76 | chmod -v 0400 $DOCKER_CERT_PATH/ca.pem $DOCKER_CERT_PATH/server-cert.pem $DOCKER_CERT_PATH/server-key.pem 77 | 78 | ## Remove remaining files 79 | cd 80 | rm -rf $dir 81 | 82 | # End of certs pair generation steps for TLS enabled docker daemon 83 | -------------------------------------------------------------------------------- /utils/sccli.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Copyright © 2016 Praveen Kumar 5 | # 6 | # This copyrighted material is made available to anyone wishing to use, 7 | # modify, copy, or redistribute it subject to the terms and conditions 8 | # of the GNU General Public License v.2, or (at your option) any later 9 | # version. This program is distributed in the hope that it will be 10 | # useful, but WITHOUT ANY WARRANTY expressed or implied, including the 11 | # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 | # PURPOSE. See the GNU General Public License for more details. You 13 | # should have received a copy of the GNU General Public License along 14 | # with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # sccli - Service Change CLI for kubernetes, openshift and docker 18 | 19 | """ 20 | Standard Exit Codes (bash): http://tldp.org/LDP/abs/html/exitcodes.html 21 | Return Code: 22 | 110 - Service is not running 23 | 111 - Docker image not pulled 24 | 112 - openshift_option file not found or it's syntax changed. 25 | 26 | Sample Usage: 27 | $ python sccli.py -h 28 | $ sudo python sccli.py kubernetes stop 29 | $ echo $? (if success return 0) 30 | $ sudo python sccli.py openshift start 31 | docker.io/openshift/origin:v1.1.9 Not Pulled (Message in stderr) 32 | $ echo $? 33 | 111 (Exit code for Docker images pull issue) 34 | """ 35 | 36 | import os 37 | import subprocess 38 | import sys 39 | import time 40 | import netifaces 41 | import socket 42 | from argparse import ArgumentParser 43 | from urllib import quote_plus 44 | 45 | OPERATION = ['start', 'status', 'restart', 'stop'] 46 | OPENSHIFT_OPTION = '/etc/sysconfig/openshift_option' 47 | 48 | 49 | def system(cmd): 50 | """ 51 | Runs a shell command, and returns the output, err, returncode 52 | :param cmd: The command to run. 53 | :return: Tuple with (output, err, returncode). 54 | """ 55 | ret = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, 56 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) 57 | out, err = ret.communicate() 58 | returncode = ret.returncode 59 | return out, err, returncode 60 | 61 | def get_all_interface_ip(): 62 | interface_list = '' 63 | for interface in netifaces.interfaces(): 64 | addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET) 65 | if addr: 66 | interface_list += "%s," % addr[0].get('addr') 67 | return interface_list 68 | 69 | def set_proxy(): 70 | proxy = os.getenv('PROXY', '') 71 | if proxy: 72 | interface_ip_list = get_all_interface_ip() 73 | predefine_no_proxy_list = ".xip.io,172.30.0.0/16,172.17.0.0/16,%s" % socket.gethostname() 74 | proxy_user = quote_plus(os.getenv('PROXY_USER','')) 75 | if proxy_user: 76 | proxy_password = quote_plus(os.getenv('PROXY_PASSWORD','')) 77 | http_proxy_url = "http://%s:%s@%s" % (proxy_user, proxy_password, proxy) 78 | https_proxy_url = "https://%s:%s@%s" % (proxy_user, proxy_password, proxy) 79 | else: 80 | http_proxy_url = "http://%s" % proxy 81 | https_proxy_url = "https://%s" % proxy 82 | # openshift proxy setup 83 | if system(('sed -i -e "/^#HTTP_PROXY=*/cHTTP_PROXY=%s"' 84 | ' -e "/^#HTTPS_PROXY=*/cHTTPS_PROXY=%s"' 85 | ' -e "/^#NO_PROXY=*/cNO_PROXY=%s%s"' 86 | ' %s') % (http_proxy_url, http_proxy_url, interface_ip_list, 87 | predefine_no_proxy_list, OPENSHIFT_OPTION))[2]: 88 | return ("Permisison denined: %s" % OPENSHIFT_OPTION) 89 | # docker daemon proxy setup 90 | if not os.path.isdir('/etc/systemd/system/docker.service.d'): 91 | subprocess.call("mkdir /etc/systemd/system/docker.service.d", shell=True) 92 | env_file_content = ('[Service]\n' 93 | 'Environment="HTTP_PROXY=%s" "NO_PROXY=localhost,127.0.0.1,::1,.xip.io"\n') \ 94 | % (http_proxy_url) 95 | try: 96 | with open('/etc/systemd/system/docker.service.d/http-proxy.conf', 'w') as fh: 97 | fh.write(env_file_content) 98 | subprocess.call('systemctl daemon-reload', shell=True) 99 | return subprocess.call('systemctl restart docker', shell=True) 100 | except IOError as err: 101 | return err 102 | 103 | def image_tag_exist(image): 104 | if subprocess.check_output("docker images -q %s" % image, shell=True): 105 | return True 106 | return False 107 | 108 | def get_registry_image_tag_defaults(): 109 | try: 110 | with open(OPENSHIFT_OPTION) as fh: 111 | file_content = fh.readlines() 112 | for content in file_content: 113 | if 'IMAGE' in content: 114 | content = content.strip() 115 | content = content.translate(None, '"') 116 | docker_registry = content.split('/', 1)[0].split('=')[-1] 117 | image_name, image_tag = tuple(content.split('/', 1)[1].split(':')) 118 | return (docker_registry, image_name, image_tag) 119 | except IOError as err: 120 | return 121 | 122 | def service_status(service_name): 123 | if service_name == "kubernetes": 124 | status = 0 125 | services = ['etcd', 'kube-apiserver', 'kube-controller-manager', 126 | 'kube-scheduler', 'kube-proxy', 'kubelet'] 127 | for service in services: 128 | status = status or system("systemctl is-active %s" % service)[2] 129 | if status: 130 | service_stop(service_name) 131 | break 132 | return status 133 | else: 134 | return system("systemctl is-active %s" % service_name)[2] 135 | 136 | def service_restart(service_name): 137 | if service_status(service_name): 138 | return ('Start %s first' % service_name, 110) 139 | if service_name == "kubernetes": 140 | return system("systemctl restart etcd kube-apiserver" 141 | " kube-controller-manager kube-scheduler" 142 | " kube-proxy kubelet docker")[1:] 143 | else: 144 | return system("systemctl restart %s" % service_name)[1:] 145 | 146 | 147 | def service_stop(service_name): 148 | if service_name == "kubernetes": 149 | system("systemctl disable etcd kube-apiserver " 150 | "kube-controller-manager kube-scheduler kube-proxy kubelet") 151 | if not system("systemctl is-active kube-apiserver")[2]: 152 | system("systemctl stop kube-apiserver") 153 | if not system("systemctl is-active kube-controller-manager")[2]: 154 | system("systemctl stop kube-controller-manager") 155 | if not system("systemctl is-active kube-scheduler")[2]: 156 | system("systemctl stop kube-scheduler") 157 | if not system("systemctl is-active kube-proxy")[2]: 158 | system("systemctl stop kube-proxy") 159 | if not system("systemctl is-active kubelet")[2]: 160 | system("systemctl stop kubelet") 161 | system("systemctl reset-failed kube-apiserver" 162 | " kube-controller-manager kube-scheduler kube-proxy kubelet") 163 | if not system("systemctl is-active etcd")[2]: 164 | system("systemctl stop etcd") 165 | elif service_name == "openshift": 166 | system("systemctl disable openshift") 167 | if not system("systemctl is-active openshift")[2]: 168 | system("systemctl stop openshift") 169 | system("systemctl reset-failed openshift") 170 | elif service_name == "docker": 171 | if not system("systemctl is-active docker")[2]: 172 | system("systemctl stop docker") 173 | system("systemctl reset-failed docker") 174 | 175 | def setup_kube_service_account_key(): 176 | system("mkdir -p /etc/pki/kube-apiserver/") 177 | system("openssl genrsa -out /etc/pki/kube-apiserver/serviceaccount.key 2048") 178 | system("sed -i.back '/KUBE_API_ARGS=*/c\KUBE_API_ARGS=" 179 | "\"--service_account_key_file=/etc/pki/kube-apiserver/serviceaccount.key\"'" 180 | " /etc/kubernetes/apiserver") 181 | system("sed -i.back '/KUBE_CONTROLLER_MANAGER_ARGS=*/c\KUBE_CONTROLLER_MANAGER_ARGS=" 182 | "\"--service_account_private_key_file=/etc/pki/kube-apiserver/serviceaccount.key\"'" 183 | " /etc/kubernetes/controller-manager") 184 | 185 | def pull_openshift_images(): 186 | try: 187 | DOCKER_REGISTRY, IMAGE_NAME, IMAGE_TAG = get_registry_image_tag_defaults() 188 | except ValueError: 189 | return("Not able to find: %s or syntax changed" % OPENSHIFT_OPTION, 112) 190 | if os.getenv('DOCKER_REGISTRY'): 191 | DOCKER_REGISTRY = os.getenv('DOCKER_REGISTRY', DOCKER_REGISTRY) 192 | if os.getenv('IMAGE_NAME'): 193 | IMAGE_NAME = os.getenv('IMAGE_NAME', IMAGE_NAME) 194 | if os.getenv('IMAGE_TAG'): 195 | IMAGE_TAG = os.getenv('IMAGE_TAG', IMAGE_TAG) 196 | if system(('sed -i.back "/^IMAGE=*/cIMAGE=\"%s/%s\:%s\""' 197 | ' %s') % (DOCKER_REGISTRY, IMAGE_NAME, IMAGE_TAG, OPENSHIFT_OPTION))[2]: 198 | return ("Permisison denined: %s" % OPENSHIFT_OPTION, 37) 199 | image_pull_list = ("{0}/{1}:{2} " 200 | "{0}/{1}-haproxy-router:{2} " 201 | "{0}/{1}-deployer:{2} " 202 | "{0}/{1}-docker-registry:{2} " 203 | "{0}/{1}-sti-builder:{2}").format(DOCKER_REGISTRY, IMAGE_NAME, IMAGE_TAG) 204 | for image in image_pull_list.split(): 205 | if not image_tag_exist(image): 206 | sys.stdout.write("docker pull %s\n" % image ) 207 | sys.stdout.flush() 208 | if system("docker pull %s" % image)[2]: 209 | return ("%s Not Pulled" % image, 111) 210 | return ('', 0) 211 | 212 | def service_start(service_name): 213 | if set_proxy(): 214 | return ("Proxy setup failed", 113) 215 | if service_name == "kubernetes": 216 | service_stop("openshift") 217 | # This is required because openshift does create kubeconfig for 8443 port 218 | subprocess.call("rm -fr /home/vagrant/.kube", shell=True) 219 | subprocess.call("rm -fr /root/.kube", shell=True) 220 | if subprocess.call("grep 'serviceaccount.key' /etc/kubernetes/apiserver" 221 | " > /dev/null 2>&1", shell=True) != 0: 222 | setup_kube_service_account_key() 223 | err, returncode = system("systemctl start etcd kube-apiserver " 224 | "kube-controller-manager kube-scheduler")[1:] 225 | if returncode: 226 | return err, returncode 227 | else: 228 | time.sleep(15) 229 | return system("systemctl start kube-proxy kubelet")[1:] 230 | if service_name == "openshift": 231 | service_stop("kubernetes") 232 | output, returncode = pull_openshift_images() 233 | if returncode: 234 | return (output, returncode) 235 | output, returncode = system("systemctl start openshift")[1:] 236 | # This is required because of proxy configurations. 237 | if os.getenv('PROXY', ''): 238 | output, returncode = system("systemctl restart docker")[1:] 239 | if output: 240 | return(output, returncode) 241 | else: 242 | # Since docker service restarted which make openshift service also 243 | # restarted so we need to wait until it start/fail. 244 | while 'activating' in system("systemctl is-active openshift")[0]: 245 | time.sleep(1) 246 | return system("systemctl is-active openshift")[1:] 247 | else: 248 | return(output, returncode) 249 | 250 | if service_name == "docker": 251 | return system("systemctl start docker")[1:] 252 | 253 | 254 | def service_operation(service_name, service_ops): 255 | if os.getuid(): 256 | print "Execution Permision Denied (use sudo)" 257 | sys.exit(1) 258 | if service_ops not in OPERATION: 259 | return sys.exit(1) 260 | if service_ops == 'start': 261 | err, returncode = service_start(service_name) 262 | sys.stderr.write(err) 263 | sys.exit(returncode) 264 | if args.sub_command == 'restart': 265 | err, returncode = service_restart(service_name) 266 | sys.stderr.write(err) 267 | sys.exit(returncode) 268 | if args.sub_command == 'status': 269 | sys.exit(service_status(service_name)) 270 | if args.sub_command == 'stop': 271 | sys.exit(service_stop(service_name)) 272 | 273 | 274 | def kube_ops(args): 275 | service_operation('kubernetes', args.sub_command) 276 | 277 | def openshift_ops(args): 278 | service_operation('openshift', args.sub_command) 279 | 280 | def docker_ops(args): 281 | service_operation('docker', args.sub_command) 282 | 283 | 284 | if __name__ == '__main__': 285 | parser = ArgumentParser(prog='sccli', description='CLI for managing services in ADB/CDK') 286 | subparsers = parser.add_subparsers(description = 'Manage services for openshift|docker|kubernetes') 287 | k8s_parser = subparsers.add_parser('kubernetes', help='start|restart|status|stop (default:start)') 288 | k8s_parser.add_argument('sub_command', nargs='?', 289 | help='start|restart|status|stop (default:start)', default='start') 290 | k8s_parser.set_defaults(func=kube_ops) 291 | openshift_parser = subparsers.add_parser('openshift', help='start|restart|status|stop (default:start)') 292 | openshift_parser.add_argument('sub_command', nargs='?', 293 | help='start|restart|status|stop (default:start)', default='start') 294 | openshift_parser.set_defaults(func=openshift_ops) 295 | docker_parser = subparsers.add_parser('docker', help='start|restart|status|stop (default:start)') 296 | docker_parser.add_argument('sub_command', nargs='?', 297 | help='start|restart|status|stop default:start', default='start') 298 | docker_parser.set_defaults(func=docker_ops) 299 | args = parser.parse_args() 300 | args.func(args) 301 | --------------------------------------------------------------------------------