From e4c7b319e26c5094fc0ca60bc94f526e9f35a432 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Tue, 4 Mar 2025 07:05:50 +0100 Subject: [PATCH] first commit --- .gitea/workflows/build-chart.yml | 44 ++ LICENSE | 674 ++++++++++++++++++ README.md | 392 ++++++++++ artemis-broker/.gitignore | 3 + artemis-broker/Chart.yaml | 14 + artemis-broker/conf/artemis-roles.properties | 49 ++ artemis-broker/conf/artemis-users.properties | 28 + artemis-broker/conf/bootstrap.xml | 43 ++ artemis-broker/conf/broker.xml | 258 +++++++ artemis-broker/conf/jgroups-ping.xml | 34 + artemis-broker/conf/login.config | 23 + .../configure_custom_config.sh | 37 + artemis-broker/scripts-override/drain.sh | 75 ++ artemis-broker/scripts-override/launch.sh | 444 ++++++++++++ artemis-broker/templates/_drain.tpl | 132 ++++ artemis-broker/templates/_pod.tpl | 179 +++++ artemis-broker/templates/configmap.yaml | 14 + artemis-broker/templates/deployment.yaml | 35 + artemis-broker/templates/ingress.yaml | 64 ++ artemis-broker/templates/nodeport.yaml | 26 + .../templates/persistentvolume.yaml | 13 + artemis-broker/templates/rbac.yaml | 56 ++ artemis-broker/templates/route.yaml | 65 ++ artemis-broker/templates/secrets.yaml | 42 ++ artemis-broker/templates/servicemonitor.yaml | 16 + artemis-broker/templates/services.yaml | 57 ++ artemis-broker/templates/statefulset.yaml | 50 ++ artemis-broker/tls/ingress_console.crt | 1 + artemis-broker/tls/ingress_console.key | 1 + artemis-broker/tls/keystore.ks | 1 + artemis-broker/tls/keystore.ts | 1 + artemis-broker/values.yaml | 227 ++++++ values_helmChart.yaml | 16 + values_helmChart__passive.yaml | 19 + 34 files changed, 3133 insertions(+) create mode 100644 .gitea/workflows/build-chart.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 artemis-broker/.gitignore create mode 100644 artemis-broker/Chart.yaml create mode 100644 artemis-broker/conf/artemis-roles.properties create mode 100644 artemis-broker/conf/artemis-users.properties create mode 100644 artemis-broker/conf/bootstrap.xml create mode 100644 artemis-broker/conf/broker.xml create mode 100644 artemis-broker/conf/jgroups-ping.xml create mode 100644 artemis-broker/conf/login.config create mode 100755 artemis-broker/scripts-override/configure_custom_config.sh create mode 100755 artemis-broker/scripts-override/drain.sh create mode 100755 artemis-broker/scripts-override/launch.sh create mode 100644 artemis-broker/templates/_drain.tpl create mode 100644 artemis-broker/templates/_pod.tpl create mode 100644 artemis-broker/templates/configmap.yaml create mode 100644 artemis-broker/templates/deployment.yaml create mode 100644 artemis-broker/templates/ingress.yaml create mode 100644 artemis-broker/templates/nodeport.yaml create mode 100644 artemis-broker/templates/persistentvolume.yaml create mode 100644 artemis-broker/templates/rbac.yaml create mode 100644 artemis-broker/templates/route.yaml create mode 100644 artemis-broker/templates/secrets.yaml create mode 100644 artemis-broker/templates/servicemonitor.yaml create mode 100644 artemis-broker/templates/services.yaml create mode 100644 artemis-broker/templates/statefulset.yaml create mode 100644 artemis-broker/tls/ingress_console.crt create mode 100644 artemis-broker/tls/ingress_console.key create mode 100644 artemis-broker/tls/keystore.ks create mode 100644 artemis-broker/tls/keystore.ts create mode 100644 artemis-broker/values.yaml create mode 100644 values_helmChart.yaml create mode 100644 values_helmChart__passive.yaml diff --git a/.gitea/workflows/build-chart.yml b/.gitea/workflows/build-chart.yml new file mode 100644 index 0000000..fae48d5 --- /dev/null +++ b/.gitea/workflows/build-chart.yml @@ -0,0 +1,44 @@ +name: "Build Helm Chart" +on: + push: + branches: + - main + - dev + paths: + - "artemis-broker/Chart.yaml" + +jobs: + helm-package: + runs-on: ubuntu-latest + env: + APP: artemis-broker + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set Helm Chart App Name and Version + id: get_version + run: | + APP_NAME=$(grep -oP '(?<=^name: ).*' ${{ env.APP }}/Chart.yaml) + echo "Helm Chart App Name: $APP_NAME" + echo "::set-output name=app::$APP_NAME" + + CHART_VERSION=$(grep -oP '(?<=^version: ).*' ${{ env.APP }}/Chart.yaml) + echo "Helm Chart version: $CHART_VERSION" + echo "::set-output name=tag::$CHART_VERSION" + + - name: Setup Helm + run: | + curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash + helm version + + - name: Package Helm Chart + run: | + helm dependency update ${{ env.APP }} + helm lint ${{ env.APP }} + helm package ${{ env.APP }} + + - name: Upload Helm Package to repo + run: | + curl --user ${{ secrets.USER }}:${{ secrets.TOKEN }} -X POST --upload-file ./${{ steps.get_version.outputs.app }}-${{ steps.get_version.outputs.tag }}.tgz ${{ vars.HELMREGISTRY }}/api/packages/${{ vars.OWNER }}/helm/api/charts + echo "--user ${{ secrets.USER }}:${{ secrets.TOKEN }} -X POST --upload-file ./${{ steps.get_version.outputs.app }}-${{ steps.get_version.outputs.tag }}.tgz ${{ vars.HELMREGISTRY }}/api/packages/${{ vars.OWNER }}/helm/api/charts" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1420b67 --- /dev/null +++ b/README.md @@ -0,0 +1,392 @@ +# RED HAT AMQ BROKER HELM CHART + +This chart handles the deployment of RedHat AMQ broker instances on both OCP and generic k8s distributions. These deployment flavors are supported: + +1. Standalone AMQ Broker +2. Choice between `Deployment` and `StatefulSet` +3. TLS optional +4. Persistence is optional. (Needs a supported StorageClass) +5. NodePorts and Passthrough Routes +6. Optional Prometheus monitoring +7. Optional Clustering (WIP) +8. Deployment compatibility with both Openshift and base Kubernetes + +|NAME | DESCRIPTION | DEFAULT VALUE | +|----------------------------------|----------------------------------------------------------|----------------| +| kind | Deploy broker as Deployment or StatefulSet | `Deployment` | +| clustered | Deploy a clustered broker | `False` | +| platform | Choose platform type (openshift or kubernetes) | `openshift` | +| application.name | The name for the application. | `amq-broker-persistence` | +| application.amq_broker_version | Broker Image tag | `7.7` | +| application.amq_broker_image | Broker Image name | `registry.redhat.io/amq7/amq-broker` | +| application.pullPolicy | Pull policy | `IfNotPresent` | +| application.replicas | Number of replicas for a clustered broker | `2` | +| application.volume_capacity | Size of persistent volume | `1G` | +| service.console | Jolokia console port and configuration | See values.yaml | +| service.acceptors | Array of acceptors. Only the multiplex is exposed by default | See values.yaml | +| ingress | Ingress configuration (only applies to kubernetes platform | See values.yaml | +| ingress.passthrough | Passthrough ingress rule options (k8s only) | See values.yaml | +| ingress.console | Artemis console ingress rule options (k8s only) | See values.yaml | +| tls.keystore | Name of the keystore file | See values.yaml | +| tls.truststore | Name of the truststoreile | See values.yaml | +| tls.keystore_password | Password to unlock the keystore on container boot | See values.yaml | +| tls.truststore_password | Password to unlock the truststore on container boot | See values.yaml | +| nodeport.enabled | Create node port to expose AMQ to clients outside of the cluster | `30002` | +| nodeport.port | Node port number used when enabled | `30002` | +| passthrough_route.enabled | Create a passthrough route to allow inbound TCP/SNI connections to a TLS-enabled broker | `False` | +| passthrough_route.hostname | Host name to use when building the route. the openshift_appdomain parameter gets appended to this value. | None | +| parameters.append_ns | Append the namespace string to hostnames before building route manifests. This is useful to keep the URL unique. | `False` | +| parameters.tls_enabled | Enable or disable TLS support for acceptors | `false` | +| parameters.jolokia_passthrough | Configure TLS for the jolokia console as a passthrough route or an edge terminated route if tls_enabled is set to true | `false` | +| parameters.amq_protocols | Protocols to configure, separated by commas. Allowed values are: `openwire`, `amqp`, `stomp`, `mqtt` and `hornetq`. | `openwire,amqp,stomp,mqtt,hornetq` | +| parameters.amq_broker_name | Broker name (TODO is this used? Same as application.name ) | `broker` | +| parameters.amq_global_max_size | Maximum amount of memory which message data may consume ( TODO: 100 gb as default is a bit high for most systems) | `"100 gb"` | +| parameters.amq_require_login | Determines whether or not the broker will allow anonymous access, or require login | `False` | +| parameters.amq_extra_args | Extra arguments for broker creation | `` | +| parameters.amq_anycast_prefix | Anycast prefix applied to the multiplexed protocol port 61616 | `jmx.queue.` | +| parameters.amq_multicast_prefix | Multicast prefix applied to the multiplexed protocol port 61616 | `jmx.topic.` | +| parameters.amq_enable_metrics_plugin | Whether to enable artemis metrics plugin | `False` | +| parameters.amq_journal_type | Journal type to use; aio or nio supported | `nio` | +| parameters.amq_data_dir | Directory for storing data | `/opt/amq/data` | +| templates.service | Template for service name | See values.yaml | +| templates.deployment | Template for deployment name | See values.yaml | +| templates.route | Template for route name | See values.yaml | +| templates.broker_image | Template for image name | See values.yaml | +| templates.override_cm | Template for ConfigMap name containing overrides | See values.yaml | +| templates.config_cm | Template for ConfigMap nggame | See values.yaml | +| templates.app_secret | Template for name of a secret containing credential data such as users and passwords | See values.yaml | +| templates.pvc_name | Template for persistent volume name | See values.yaml | +| security.enabled | Enabled security | `true` | +| security.secrets | Array of names of additional secrets to mount into /opt/amq/conf | [] | +| security.createSecret | Create secret with users and passwords. Disable when secrets is created outside of this chart. For example by ExternalSecret | `true` | +| security.jaasUsers.key | Specify the key (filename) of the user/password file in the secret | `artemis-users.properties` | +| admin.user | Admin user. Mandatory even if security.createSecret is `false`) | `admin` | +| admin.password | Admin password. Optional. Only used if security.createSecret is `true` | `password` | +| admin.role | Admin role name | `admin` | +| users | Array of additional users. Only used if security.createSecret is `true` else users are expected to be defined in secret. | [] | +| queue.defaults | Default values for queues parameters | [] | +| queue.addresses | Array of queues to create. | [] | +| metrics.enabled | Enable metrics in AMQ and let Prometheus collect metrics using ServiceMonitor | `false` | +| metrics.jvm_memory | Enable JVM memory metrics | `true` | +| metrics.jvm_gc | Enable JVM garbage collection statistics in metrics | `false` | +| metrics.jvm_threads | Enable JVM Thread statistics | `false` | +| metrics.servicemonitor.port | Collect metrics from this port. Default is the management port. | `8161` | +| metrics.servicemonitor.interval | Metrics are collected with fixed interval. | `20s` | +| resources | Kubernetes limits and resources to attach to pod templates | See values.yaml | + +## INSTALLATION + +The most basic deployment can be performed by following these steps: + +### Disk Persistence: + +Every deployment flavor (TLS and Non-TLS) can be made persistent by setting the `persitent` flag to `true`: + +``` +application: + [...] + volume_capacity: "1G" + persistent: true +``` + +### Non-TLS AMQ Brokers + +- Customize the application name in `values.yaml`: + +``` +application: + name: amq-broker-persistence-ssl + [...] + volume_capacity: "1G" +``` + +``` +parameters: + [...] + amq_data_dir: "/opt/amq/data" + tls_enabled: false + [...] +``` + +If needed, the broker can be consumed by clients running outside OCP by deploying a NodePort resource: + +``` +nodeport: + [...] + enabled: true +``` + +Since no TLS passthrough is possible without proper tls support, the passthrough_route should be disabled: + +``` +passthrough_route: + enabled: false + [...] +``` + +### TLS-enabled AMQ Brokers + +- Create (or import) a keystore/truststore pair for this broker. Put the files under `tls/` and update the tls section in `values.yaml`: + +``` +tls: + keystore: keystore.ks + truststore: keystore.ts + keystore_password: kspwd + truststore_password: tspwd +``` + +- Customize the application name in `values.yaml`: + +``` +application: + name: amq-broker-artemis + [...] + volume_capacity: "1G" +``` + +``` +parameters: + [...] + tls_enabled: true + jolokia_passthrough: false # set this to true if you want to use the same keystore for the jolokia console too. in this case the route will be created as passthrough + amq_data_dir: "/opt/amq/data" + [...] +``` + +For TLS-enabled brokers, both the NodePort and the Passthrough route options are working. Both can be enabled at the same time. + +### Common Setup + +The application name will be used as a prefix for most of the objects deployed by the Chart itself. + +- Update the Admin user name and password in `values.yaml` + +``` +admin: + user: admin + password: password + role: admin +``` + +- If needed, enable and choose a node port TCP value and corresponding service for the external service in `values.yaml`: + +``` +nodeport: + port: 30003 + service: multiplex + enabled: true +``` +this port needs to be in the allowed NodePort range set up in the kubelet (typically in the range 30000-32768) + +- Install the Chart under your preferred project + +``` +$ oc new-project amq-demo-artemis +$ helm install amq-broker-artemis . +``` + +After a while and depending on what options are enabled in the values file, the broker should be up and running: + +``` +$ oc get all +NAME READY STATUS RESTARTS AGE +pod/amq-broker-artemis-dc-6f7658dbc7-xgxll 1/1 Running 0 86s + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +service/amq-broker-artemis-nodeport-svc NodePort 172.30.208.78 61616:30003/TCP 87s +service/amq-broker-artemis-svc ClusterIP 172.30.194.187 61616/TCP,8161/TCP 87s + +NAME READY UP-TO-DATE AVAILABLE AGE +deployment.apps/amq-broker-artemis-dc 1/1 1 1 87s + +NAME DESIRED CURRENT READY AGE +replicaset.apps/amq-broker-artemis-dc-6f7658dbc7 1 1 1 87s + +NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD +route.route.openshift.io/amq-broker-artemis-route-console amq-broker-artemis-route-console-amq-helm-test.apps.lab01.gpslab.club amq-broker-artemis-svc 8161 edge/Redirect None +``` + +## ADDING QUEUES, USERS AND ROLES + +To add multiple users to the broker edit the `users` section in `values.yaml`. For example, this setup here: + +``` +users: + - name: demouser + password: "demo" + role: user + - name: anotheruser + password: "demo1" + role: user +``` + +would be rendered by the Helm Chart into these two files: + +- `artemis-users.properties` + +``` + ## CUSTOMCONFIG + + # ADMIN USER + admin = password + + # ADDITIONAL USERS + demouser = demo + anotheruser = demo1 +``` + +- `artemis-roles.properties` + +``` + ## CUSTOMCONFIG + # ADMIN ROLE MAPPING + admin = admin + + # ADDITIONAL ROLE MAPPING + user = demouser + user = anotheruser +``` + +Users and passwords may be stored in an existing secret instead of as clear text in the values.yaml: disable the creation of the built-in user secret and specify the name of an existing secret. + +Set the `jaasUsers.key` to the filename used in the secret. Note that the filename have to be something different from `artemis-users.properties` as the default file will be mounted in the same directory in the container. + +For example: +``` +security: + secrets: + - broker-external-secret + createSecret: false + jaasUsers: + key: my-secured-artemis-users.properties + +``` + +*Note*, that the AMQ_USER and AMQ_PASSWORD *must* be set, as the broker still uses these environment parameters: + +``` +stringData: + AMQ_USER: broker-admin + AMQ_PASSWORD: mySecretPassword + my-secured-artimis-users.properties: | + # ADMIN USER + broker-admin = mySecretPassword + # ADDITIONAL USERS + consumer-user = otherSecretPassword +type: Opaque +``` + +The `queues` section in `values.yaml` allows to add custom queues to the broker at install time. For example, this setup: + +``` +queues: + defaults: + [...] + addresses: + - name: demoQueue + permissions: + - grant: consume + roles: + - admin + - user + - grant: browse + roles: + - admin + - user + - grant: send + roles: + - admin + - user + - grant: manage + roles: + - admin +``` + +would result in this rendered section inside `broker.xml`: + +``` + + + + + + +``` + +the defaults section under the queues stanza contains the values set for every queue if not overridden on a per queue basis. + +## Metering + +An optional prometheus ServiceMonitor is shipped with the chart. See values.yaml (metering stanza) for configuration. + +## Clustering + +Optional clustering is somewhat supported, but it is still considered WIP. + +## Kubernetes support + +AMQ Broker can be deployed also on standard Kubernetes clusters: + +1. Ingress Rules are deployed instead of Openshift Routes for both the console and the passthrough route +2. A valid RedHat pull secret needs to be explicitly created in order to pull the AMQ broker images from registry.redhat.io: + +``` +$ kubectl create secret docker-registry \ + --docker-server=registry.redhat.io \ + --docker-username= \ + --docker-password= \ + --docker-email= +``` + +The secret created with the command shown above needs to be set up in the _values.yaml_ file: + +``` +[...] +application: +[...] + pullSecretName: +[...] +``` + +## KEYSTORE CREATION MINI-HOWTO + +In order to deploy SSL-enabled templates, a secret with valid Java Truststore and Keystore files must be created. +To create a keystore: + +1. Generate a self-signed certificate for the broker keystore: +``` +$ keytool -genkey -alias broker -keyalg RSA -keystore broker.ks +``` + +2. Export the certificate so that it can be shared with clients: +``` +$ keytool -export -alias broker -keystore broker.ks -file broker_cert +``` + +3. Generate a self-signed certificate for the client keystore: +``` +$ keytool -genkey -alias client -keyalg RSA -keystore client.ks +``` + +4. Create a client truststore that imports the broker certificate: +``` +$ keytool -import -alias broker -keystore client.ts -file broker_cert +``` + +5. Export the client’s certificate from the keystore: +``` +$ keytool -export -alias client -keystore client.ks -file client_cert +``` + +6. Import the client’s exported certificate into a broker SERVER truststore: +``` +$ keytool -import -alias client -keystore broker.ts -file client_cert +``` + +## DISCLAIMER + +This chart is distributed as-is under the GPLv3 license and it's currently being developed as a private project to experiment alternative installation methods to the default AMQ Operator supported by RedHat. +This repo and the code it contains is not by any means endorsed or supported by RedHat or by any of the software subscriptions RedHat offers. + + diff --git a/artemis-broker/.gitignore b/artemis-broker/.gitignore new file mode 100644 index 0000000..ac09cfc --- /dev/null +++ b/artemis-broker/.gitignore @@ -0,0 +1,3 @@ +values.test +tls/broker* +tls/client* diff --git a/artemis-broker/Chart.yaml b/artemis-broker/Chart.yaml new file mode 100644 index 0000000..d4819a9 --- /dev/null +++ b/artemis-broker/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: artemis-broker +version: 7.12.3-test1 +description: An unified Helm Chart that deploys an Artemis MQ Broker with optional SSL support and Optional Disk Persistence. Clustered setups are also supported. +type: application +keywords: + - activemq + - artemismq + - amq-broker + - ssl-endpoint + - amq-cluster +home: https://access.redhat.com/products/red-hat-amq/ +sources: + - https://git.cooltux.net/marko/amq-broker-helm diff --git a/artemis-broker/conf/artemis-roles.properties b/artemis-broker/conf/artemis-roles.properties new file mode 100644 index 0000000..145d37c --- /dev/null +++ b/artemis-broker/conf/artemis-roles.properties @@ -0,0 +1,49 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +## CUSTOMCONFIG + +# syntax is role = list of users + +# ADMIN ROLE MAPPING +{{- $admins := list -}} +{{- $admins = printf "%s" $.Values.admin.user | append $admins -}} +{{- range $currentUser := $.Values.users }} +{{- if has ($.Values.admin.role) $currentUser.roles }} +{{- $admins = printf "%s" (toString $currentUser.name) | append $admins -}} +{{- end }} +{{- end }} +{{ $.Values.admin.role }} = {{ $admins | join "," }} + +{{- $declared_roles := list }} +{{- range .Values.users }} +{{- range .roles }} + {{- if and (not (has (toString .) $declared_roles)) (not (eq (toString .) ($.Values.admin.role))) }} + {{- $declared_roles = printf "%s" (toString .) | append $declared_roles }} + {{- end }} +{{- end }} +{{- end }} + +# ADDITIONAL ROLE MAPPING +{{- range $current_role := $declared_roles }} + {{- $users_in_role := list -}} + {{- range $currentUser := $.Values.users }} + {{- if has $current_role $currentUser.roles }} + {{- $users_in_role = printf "%s" (toString $currentUser.name) | append $users_in_role -}} + {{- end }} + {{- end }} +{{ $current_role }} = {{ $users_in_role | join "," }} +{{- end }} diff --git a/artemis-broker/conf/artemis-users.properties b/artemis-broker/conf/artemis-users.properties new file mode 100644 index 0000000..c719f76 --- /dev/null +++ b/artemis-broker/conf/artemis-users.properties @@ -0,0 +1,28 @@ +{{- if .Values.security.createSecret }} +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +## CUSTOMCONFIG + +# ADMIN USER +{{ .Values.admin.user }} = {{ .Values.admin.password }} + +# ADDITIONAL USERS +{{- range .Values.users }} +{{ .name }} = {{ .password }} +{{- end }} + +{{- end }} diff --git a/artemis-broker/conf/bootstrap.xml b/artemis-broker/conf/bootstrap.xml new file mode 100644 index 0000000..9ab76fa --- /dev/null +++ b/artemis-broker/conf/bootstrap.xml @@ -0,0 +1,43 @@ +{{- $jolokia_ssl := and (.Values.parameters.tls_enabled) (.Values.parameters.jolokia_passthrough) }} + + + + + + + + + + + + +{{- if $jolokia_ssl }} + +{{- else }} + +{{- end }} + + + + + + + + + diff --git a/artemis-broker/conf/broker.xml b/artemis-broker/conf/broker.xml new file mode 100644 index 0000000..b6c9af6 --- /dev/null +++ b/artemis-broker/conf/broker.xml @@ -0,0 +1,258 @@ + + + + + ${AMQ_NAME} + {{- if and .Values.application.persistent (or .Values.clustered .Values.ha_ap) }} + true + + {{ .Values.application.journal_type }} + ${AMQ_DATA_DIR}/paging + ${AMQ_DATA_DIR}/bindings + ${AMQ_DATA_DIR}/journal + ${AMQ_DATA_DIR}/large-messages + {{- else }} + false + + NIO + ./data/paging + ./data/bindings + ./data/journal + ./data/large-messages + {{- end }} + true + 2 + 10 + 10M + + 9524000 + + 4096 + + + + + + + + + + + + 5000 + + 90 + + true + 120000 + 60000 + HALT + + + + + + + {{- if .Values.parameters.tls_enabled }} + {{- range .Values.service.acceptors }} + {{- $extra_args := list -}} + {{- range .acceptor_params }} + {{- $extra_args = printf "%s=%s" (toString .key) (toString .value) | append $extra_args }} + {{- end }} + {{- if or (.use_tls) (eq (.use_tls | toString) "") }} + tcp://${BROKER_IP}:{{ .port }}?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols={{ default $.Values.parameters.amq_protocols .amq_protocols }};useEpoll=true;amqpCredits=1000;amqpLowCredits=300;anycastPrefix=${AMQ_ANYCAST_PREFIX};multicastPrefix=${AMQ_MULTICAST_PREFIX};connectionsAllowed={{ .max_connections }};sslEnabled=true;keyStorePath=${AMQ_KEYSTORE_TRUSTSTORE_DIR}/{{ $.Values.tls.keystore }};keyStorePassword=${AMQ_KEYSTORE_PASSWORD};trustStorePath=${AMQ_KEYSTORE_TRUSTSTORE_DIR}/{{ $.Values.tls.truststore }};trustStorePassword=${AMQ_TRUSTSTORE_PASSWORD};sslProvider={{ $.Values.parameters.ssl_provider }};{{ $extra_args | join ";" }} + {{- else }} + tcp://${BROKER_IP}:{{ .port }}?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols={{ default $.Values.parameters.amq_protocols .amq_protocols }};useEpoll=true;amqpCredits=1000;amqpLowCredits=300;anycastPrefix=${AMQ_ANYCAST_PREFIX};multicastPrefix=${AMQ_MULTICAST_PREFIX};{{ $extra_args | join ";" }} + {{- end }} + {{- end }} + {{- else }} + {{- range .Values.service.acceptors }} + {{- $extra_args := list -}} + {{- range .acceptor_params }} + {{- $extra_args = printf "%s=%s" (toString .key) (toString .value) | append $extra_args }} + {{- end }} + tcp://${BROKER_IP}:{{ .port }}?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols={{ default $.Values.parameters.amq_protocols .amq_protocols }};useEpoll=true;amqpCredits=1000;amqpLowCredits=300;anycastPrefix=${AMQ_ANYCAST_PREFIX};multicastPrefix=${AMQ_MULTICAST_PREFIX};{{ $extra_args | join ";" }} + {{- end }} + {{- end }} + + {{ .Values.security.enabled }} + + {{- range .Values.queues.addresses }} + + {{- range .permissions }} + + {{- end }} + + {{- end }} + + + + + + + + + + + + + + + + + + DLQ + ExpiryQueue + 0 + + -1 + 10 + PAGE + + + + DLQ + ExpiryQueue + {{ .Values.queues.defaults.maxDeliveryAttempts }} + {{ .Values.queues.defaults.redeliveryDelay }} + {{ .Values.queues.defaults.redeliveryDelayMultiplier }} + {{ .Values.queues.defaults.maxRedeliveryDelay }} + + {{ .Values.queues.defaults.maxSizeBytes }} + {{ .Values.queues.defaults.messageCounterHistoryDayLimit }} + {{ .Values.queues.defaults.addressFullPolicy }} + {{- if .Values.parameters.amq_force_addresses_cleanup }} + FORCE + FORCE + {{- end }} + + {{- range .Values.queues.addresses }} + + {{- if .dlq_address }} + {{ .dlq_address }} + {{- end }} + {{- if .expiry_address }} + {{ .expiry_address }} + {{- end }} + {{ default $.Values.queues.defaults.maxDeliveryAttempts .maxDeliveryAttempts }} + {{ default $.Values.queues.defaults.redeliveryDelay .redeliveryDelay }} + {{ default $.Values.queues.defaults.redeliveryDelayMultiplier .redeliveryDelayMultiplier }} + {{ default $.Values.queues.defaults.maxRedeliveryDelay .maxRedeliveryDelay }} + {{ default $.Values.queues.defaults.maxSizeBytes .maxSizeBytes }} + {{ default $.Values.queues.defaults.messageCounterHistoryDayLimit .messageCounterHistoryDayLimit }} + {{ default $.Values.queues.defaults.addressFullPolicy .addressFullPolicy }} + + {{- end }} + + +
+ + + +
+
+ + + +
+ {{- range .Values.queues.addresses }} +
+ {{- $isMulticast := "" }} + {{- if ( .type ) }}{{- if eq .type "multicast" }} + {{- $isMulticast = print "true" }} + {{- end }}{{- end }} + {{- if $isMulticast }} + + {{- else }} + + + + {{- end }} +
+ {{- if .dlq_address }} +
+ + + +
+ {{- end }} + {{- if .expiry_address }} +
+ + + +
+ {{- end }} + {{- end }} +
+ {{- if .Values.metrics.enabled }} + + {{ .Values.metrics.jvm_memory }} + {{ .Values.metrics.jvm_gc }} + {{ .Values.metrics.jvm_threads }} + + + {{- end }} + {{- if .Values.clustered }} + {{- if .Values.cluster.ha_ap_mode }} + + tcp://${BROKER_IP}:{{ .Values.ha_ap.connector.port }} + tcp://{{ .Values.ha_ap.connector.static.ref }}-svc:{{ .Values.ha_ap.connector.static.port }} + + + + {{ .Values.ha_ap.connector.ref }} + + {{ .Values.ha_ap.connector.static.ref }} + + + + + + {{- if eq .Values.ha_ap.mode "primary" }} + + true + + {{- else }} + + true + + {{- end }} + + + {{- else }} + + tcp://${BROKER_IP}:{{ .Values.cluster.connector.port }} + + + + {{ .Values.cluster.jgroupsCfg }} + activemq_broadcast_channel + {{ .Values.cluster.refreshTimeout }} + + + + + {{ .Values.cluster.jgroupsCfg }} + activemq_broadcast_channel + {{ .Values.cluster.connector.ref }} + + + + + {{ .Values.cluster.connector.ref }} + 1000 + 2 + 32000 + 20 + 10 + true + ON_DEMAND + 1 + + + + {{- end }} + {{- end }} +
+
\ No newline at end of file diff --git a/artemis-broker/conf/jgroups-ping.xml b/artemis-broker/conf/jgroups-ping.xml new file mode 100644 index 0000000..569b39d --- /dev/null +++ b/artemis-broker/conf/jgroups-ping.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + diff --git a/artemis-broker/conf/login.config b/artemis-broker/conf/login.config new file mode 100644 index 0000000..830252e --- /dev/null +++ b/artemis-broker/conf/login.config @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +activemq { + org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule requisite + reload=true + org.apache.activemq.jaas.properties.user="{{ .Values.security.jaasUsers.key }}" + org.apache.activemq.jaas.properties.role="artemis-roles.properties"; +}; diff --git a/artemis-broker/scripts-override/configure_custom_config.sh b/artemis-broker/scripts-override/configure_custom_config.sh new file mode 100755 index 0000000..0c181a2 --- /dev/null +++ b/artemis-broker/scripts-override/configure_custom_config.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +INSTANCE_DIR=$1 + +declare -a CONFIG_FILES=("bootstrap.xml" "broker.xml" "logging.properties") + +function swapVars() { + # Requires bash v4+ + declare -A SUBSTITUTIONS + + while read -r SUBVAR + do + SUBSTITUTIONS[$SUBVAR]=1 + done < <( awk '{ + while( match($0, /\$\{[a-zA-Z_0-9][a-zA-Z_0-9]*\}/) ) { + print substr($0, RSTART, RLENGTH) + sub(/\$\{[a-zA-Z_0-9][a-zA-Z_0-9]*\}/, "matched", $0) + } + }' $1 ) + + echo "Found placeholder variables: \"${!SUBSTITUTIONS[@]}\". Customizing configuration.." + + for var in "${!SUBSTITUTIONS[@]}"; do + sed -i "s#$var#$(eval echo \"$var\")#g" $1 + done +} + +for config_file in ${CONFIG_FILES[@]}; +do + # Swap env vars into configuration file + if [[ -e $INSTANCE_DIR/etc/$config_file ]]; then + echo "Patching Custom Configuration file '$config_file'" + swapVars $INSTANCE_DIR/etc/$config_file + fi +done + diff --git a/artemis-broker/scripts-override/drain.sh b/artemis-broker/scripts-override/drain.sh new file mode 100755 index 0000000..b969c69 --- /dev/null +++ b/artemis-broker/scripts-override/drain.sh @@ -0,0 +1,75 @@ +#!/bin/sh + +export BROKER_IP=`hostname -f` + +instanceDir="${HOME}/${AMQ_NAME}" + +ENDPOINT_NAME="${HEADLESS_ENDPOINT}" +if [ "$HEADLESS_SVC_NAME" ]; then + ENDPOINT_NAME=$HEADLESS_SVC_NAME +fi + +endpointsUrl="https://${KUBERNETES_SERVICE_HOST:-kubernetes.default.svc}:${KUBERNETES_SERVICE_PORT:-443}/api/v1/namespaces/${POD_NAMESPACE}/" +endpointsAuth="Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" + +function waitForJolokia() { + while : ; + do + sleep 5 + curl -s -o /dev/null -G -k http://${AMQ_USER}:${AMQ_PASSWORD}@${BROKER_IP}:8161/console/jolokia + if [ $? -eq 0 ]; then + break + fi + done +} + + +endpointsCode=$(curl -s -o /dev/null -w "%{http_code}" -G -k -H "${endpointsAuth}" ${endpointsUrl}) +if [ $endpointsCode -ne 200 ]; then + echo "Can't find endpoints with ips status <${endpointsCode}>" + exit 1 +fi + +ENDPOINTS=$(curl -s -X GET -G -k -H "${endpointsAuth}" ${endpointsUrl}"endpoints/${ENDPOINT_NAME}") +echo $ENDPOINTS +count=0 +while [ 1 ]; do + ip=$(echo $ENDPOINTS | python -c "import sys, json; print json.load(sys.stdin)['subsets'][0]['addresses'][${count}]['ip']") + if [ $? -ne 0 ]; then + echo "Can't find ip to scale down to tried ${count} ips" + exit + fi + + echo "got ip ${ip} broker ip is ${BROKER_IP}" + if [ "$ip" != "$BROKER_IP" ]; then + break + fi + + count=$(( count + 1 )) +done + +source /opt/amq/bin/launch.sh nostart + +SCALE_TO_BROKER_IP=$ip + +# Add connector to the pod to scale down to +connector="tcp:\/\/${SCALE_TO_BROKER_IP}:61616<\/connector>" +sed -i "/<\/connectors>/ s/.*/${connector}\n&/" ${instanceDir}/etc/broker.xml + +# Remove the acceptors +#sed -i -ne "// {p; " -e ":a; n; /<\/acceptors>/ {p; b}; ba}; p" ${instanceDir}/etc/broker.xml +acceptor="tcp:\/\/${BROKER_IP}:61616?protocols=CORE<\/acceptor>" +sed -i -ne "// {p; i $acceptor" -e ":a; n; /<\/acceptors>/ {p; b}; ba}; p" ${instanceDir}/etc/broker.xml + +#start the broker and issue the scaledown command to drain the messages. +${instanceDir}/bin/artemis-service start + +if [ "$AMQ_DATA_DIR_LOGGING" = "true" ]; then + tail -n 100 -f ${AMQ_DATA_DIR}/log/artemis.log & +else + tail -n 100 -f ${AMQ_NAME}/log/artemis.log & +fi + +waitForJolokia +curl -s -o /dev/null -G -k http://${AMQ_USER}:${AMQ_PASSWORD}@${BROKER_IP}:8161/console/jolokia/exec/org.apache.activemq.artemis:broker=%22${AMQ_NAME}%22/scaleDown/scaledownconnector + diff --git a/artemis-broker/scripts-override/launch.sh b/artemis-broker/scripts-override/launch.sh new file mode 100755 index 0000000..91f1db8 --- /dev/null +++ b/artemis-broker/scripts-override/launch.sh @@ -0,0 +1,444 @@ +#!/bin/bash + +if [ "${SCRIPT_DEBUG}" = "true" ] ; then + set -x + echo "Script debugging is enabled, allowing bash commands and their arguments to be printed as they are executed" +fi + + +export BROKER_IP=`hostname -I` +CONFIG_TEMPLATES=/config_templates + +#GC Option conflicts with the one already configured. +echo "Removing provided -XX:+UseParallelOldGC in favour of artemis.profile provided option" +JAVA_OPTS=$(echo $JAVA_OPTS | sed -e "s/-XX:+UseParallelOldGC/ /") +PLATFORM=`uname -m` +echo "Platform is ${PLATFORM}" +if [ "${PLATFORM}" = "s390x" ] ; then + #GC Option found to be a problem on s390x + echo "Removing -XX:+UseG1GC as per recommendation to use default GC" + JAVA_OPTS=$(echo $JAVA_OPTS | sed -e "s/-XX:+UseG1GC/ /") + #JDK11 related warnings removal + echo "Adding -Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true as per ENTMQBR-1932" + JAVA_OPTS="-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true ${JAVA_OPTS}" +fi +JAVA_OPTS="-Djava.net.preferIPv4Stack=true ${JAVA_OPTS}" + +if [ "$AMQ_ENABLE_JOLOKIA_AGENT" = "true" ]; then + echo "Define jolokia jvm agent options" + + if [ -z ${AMQ_JOLOKIA_AGENT_OPTS} ]; then + if [ -f "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt" ]; then + AMQ_JOLOKIA_AGENT_OPTS='realm=activemq,caCert=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt,clientPrincipal.1=cn=system:master-proxy,clientPrincipal.2=cn=hawtio-online.hawtio.svc,clientPrincipal.3=cn=fuse-console.fuse.svc' + else + AMQ_JOLOKIA_AGENT_OPTS='realm=activemq,clientPrincipal.1=cn=system:master-proxy,clientPrincipal.2=cn=hawtio-online.hawtio.svc,clientPrincipal.3=cn=fuse-console.fuse.svc' + fi + fi + + export AB_JOLOKIA_USER=$AMQ_JOLOKIA_AGENT_USER + export AB_JOLOKIA_PASSWORD_RANDOM=false + export AB_JOLOKIA_PASSWORD=$AMQ_JOLOKIA_AGENT_PASSWORD + export AB_JOLOKIA_OPTS="${AMQ_JOLOKIA_AGENT_OPTS}" + JOLOKIA_OPTS="$(/opt/jolokia/jolokia-opts)" + echo "JOLOKIA_OPTS: $JOLOKIA_OPTS" +fi + +function sslPartial() { + [ -n "$AMQ_KEYSTORE_TRUSTSTORE_DIR" -o -n "$AMQ_KEYSTORE" -o -n "$AMQ_TRUSTSTORE" -o -n "$AMQ_KEYSTORE_PASSWORD" -o -n "$AMQ_TRUSTSTORE_PASSWORD" ] +} + +function sslEnabled() { + [ -n "$AMQ_KEYSTORE_TRUSTSTORE_DIR" -a -n "$AMQ_KEYSTORE" -a -n "$AMQ_TRUSTSTORE" -a -n "$AMQ_KEYSTORE_PASSWORD" -a -n "$AMQ_TRUSTSTORE_PASSWORD" ] +} + +# Finds the environment variable and returns its value if found. +# Otherwise returns the default value if provided. +# +# Arguments: +# $1 env variable name to check +# $2 default value if environemnt variable was not set +function find_env() { + var=${!1} + echo "${var:-$2}" +} + +function configureUserAuthentication() { + if [ -n "${AMQ_USER}" -a -n "${AMQ_PASSWORD}" ] ; then + AMQ_ARGS="$AMQ_ARGS --user $AMQ_USER --password $AMQ_PASSWORD " + else + echo "Required variable missing: both AMQ_USER and AMQ_PASSWORD are required." + exit 1 + fi + if [ "$AMQ_REQUIRE_LOGIN" = "true" ]; then + AMQ_ARGS="$AMQ_ARGS --require-login" + else + AMQ_ARGS="$AMQ_ARGS --allow-anonymous" + fi +} + +function configureLogging() { + instanceDir=$1 + if [ "$AMQ_DATA_DIR_LOGGING" = "true" ]; then + echo "Configuring logging directory to be ${AMQ_DATA_DIR}/log" + sed -i 's@${artemis.instance}@'"$AMQ_DATA_DIR"'@' ${instanceDir}/etc/logging.properties + fi +} + +function configureNetworking() { + if [ "$AMQ_CLUSTERED" = "true" ]; then + echo "Broker will be clustered" + AMQ_ARGS="$AMQ_ARGS --clustered --cluster-user $AMQ_CLUSTER_USER --cluster-password $AMQ_CLUSTER_PASSWORD --host $BROKER_IP" + ACCEPTOR_IP=$BROKER_IP + else + AMQ_ARGS="$AMQ_ARGS --host 0.0.0.0" + ACCEPTOR_IP="0.0.0.0" + fi +} + +function configureRedistributionDelay() { + instanceDir=$1 + echo "Setting redistribution-delay to zero." + sed -i "s//&\n 0<\/redistribution-delay>/g" ${instanceDir}/etc/broker.xml +} + +function configureSSL() { + sslDir=$(find_env "AMQ_KEYSTORE_TRUSTSTORE_DIR" "") + keyStoreFile=$(find_env "AMQ_KEYSTORE" "") + trustStoreFile=$(find_env "AMQ_TRUSTSTORE" "") + + if sslEnabled ; then + keyStorePassword=$(find_env "AMQ_KEYSTORE_PASSWORD" "") + trustStorePassword=$(find_env "AMQ_TRUSTSTORE_PASSWORD" "") + + keyStorePath="$sslDir/$keyStoreFile" + trustStorePath="$sslDir/$trustStoreFile" + + AMQ_ARGS="$AMQ_ARGS --ssl-key $keyStorePath" + AMQ_ARGS="$AMQ_ARGS --ssl-key-password $keyStorePassword" + + AMQ_ARGS="$AMQ_ARGS --ssl-trust $trustStorePath" + AMQ_ARGS="$AMQ_ARGS --ssl-trust-password $trustStorePassword" + elif sslPartial ; then + log_warning "Partial ssl configuration, the ssl context WILL NOT be configured." + fi +} + +function updateAcceptorsForSSL() { + instanceDir=$1 + + if sslEnabled ; then + + echo "keystore filepath: $keyStorePath" + + IFS=',' read -a protocols <<< $(find_env "AMQ_TRANSPORTS" "openwire,amqp,stomp,mqtt,hornetq") + connectionsAllowed=$(find_env "AMQ_MAX_CONNECTIONS" "1000") + + sslProvider=$(find_env "AMQ_SSL_PROVIDER" "") + + if [ -z "${sslProvider}" ] ; then + SSL_OPS="sslEnabled=true;keyStorePath=${keyStorePath};keyStorePassword=${keyStorePassword}" + else + SSL_OPS="sslEnabled=true;keyStorePath=${keyStorePath};keyStorePassword=${keyStorePassword};sslProvider=${sslProvider}" + fi + + if [ "${#protocols[@]}" -ne "0" ]; then + acceptors="" + for protocol in ${protocols[@]}; do + case "${protocol}" in + "openwire") + acceptors="${acceptors} tcp://${ACCEPTOR_IP}:61617?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;connectionsAllowed=${connectionsAllowed};${SSL_OPS}\n" + ;; + "mqtt") + acceptors="${acceptors} tcp://${ACCEPTOR_IP}:8883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true;connectionsAllowed=${connectionsAllowed};${SSL_OPS}\n" + ;; + "amqp") + acceptors="${acceptors} tcp://${ACCEPTOR_IP}:5671?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpMinCredits=300;connectionsAllowed=${connectionsAllowed};${SSL_OPS}\n" + ;; + "stomp") + acceptors="${acceptors} tcp://${ACCEPTOR_IP}:61612?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true;connectionsAllowed=${connectionsAllowed};${SSL_OPS}\n" + ;; +esac + done + fi + safeAcceptors=$(echo "${acceptors}" | sed 's/\//\\\//g') + sed -i "/<\/acceptors>/ s/.*/${safeAcceptors}\n&/" ${instanceDir}/etc/broker.xml + fi +} + +function updateAcceptorsForPrefixing() { + instanceDir=$1 + + if [ -n "$AMQ_MULTICAST_PREFIX" ]; then + echo "Setting multicastPrefix to ${AMQ_MULTICAST_PREFIX}" + sed -i "s/:61616?/&multicastPrefix=${AMQ_MULTICAST_PREFIX};/g" ${instanceDir}/etc/broker.xml + sed -i "s/:61617?/&multicastPrefix=${AMQ_MULTICAST_PREFIX};/g" ${instanceDir}/etc/broker.xml + fi + + if [ -n "$AMQ_ANYCAST_PREFIX" ]; then + echo "Setting anycastPrefix to ${AMQ_ANYCAST_PREFIX}" + sed -i "s/:61616?/&anycastPrefix=${AMQ_ANYCAST_PREFIX};/g" ${instanceDir}/etc/broker.xml + sed -i "s/:61617?/&anycastPrefix=${AMQ_ANYCAST_PREFIX};/g" ${instanceDir}/etc/broker.xml + fi +} + +function appendAcceptorsFromEnv() { + instanceDir=$1 + + if [ -n "$AMQ_ACCEPTORS" ]; then + echo "Using acceptors from environment and removing existing entries" + sed -i "/acceptor name=/d" ${instanceDir}/etc/broker.xml + acceptorsFromEnv=$(find_env "AMQ_ACCEPTORS" "") + # As AMQ_ACCEPTORS was introduced from the operator, the operator makes a safe string for here + safeAcceptorsFromEnv=$(echo "${acceptorsFromEnv}") + sed -i "/<\/acceptors>/ s/.*/${safeAcceptorsFromEnv}\n&/g" ${instanceDir}/etc/broker.xml + sed -i "s/ACCEPTOR_IP/${ACCEPTOR_IP}/g" ${instanceDir}/etc/broker.xml + fi +} + +function appendConnectorsFromEnv() { + instanceDir=$1 + + if [ -n "$AMQ_CONNECTORS" ]; then + echo "Appending connectors from environment" + connectorsFromEnv=$(find_env "AMQ_CONNECTORS" "") + # As AMQ_CONNECTORS was introduced from the operator, the operator makes a safe string for here + safeConnectorsFromEnv=$(echo "${connectorsFromEnv}") + endConnectorsCount=`grep -c '' ${instanceDir}/etc/broker.xml` + if [ ${endConnectorsCount} -ne 0 ]; then + sed -i "/<\/connectors>/ s/.*/\t\t${safeConnectorsFromEnv}\n&/" ${instanceDir}/etc/broker.xml + else + sed -i "/<\/acceptors>/ s/.*/&\n\t\n\t\t${safeConnectorsFromEnv}\n\t<\/connectors>\n/" ${instanceDir}/etc/broker.xml + fi + fi +} + +function appendJournalType() { + instanceDir=$1 + + if [ -n "$AMQ_JOURNAL_TYPE" ]; then + echo "Setting journal type to ${AMQ_JOURNAL_TYPE}" + if [[ $(removeWhiteSpace ${AMQ_JOURNAL_TYPE}) != *"nio"* ]]; then + AMQ_ARGS="$AMQ_ARGS --aio" + fi + if [[ $(removeWhiteSpace ${AMQ_JOURNAL_TYPE}) != *"aio"* ]]; then + AMQ_ARGS="$AMQ_ARGS --nio" + fi + fi +} + +function modifyDiscovery() { + discoverygroup="" + discoverygroup="${discoverygroup} " + discoverygroup="${discoverygroup} jgroups-ping.xml" + discoverygroup="${discoverygroup} activemq_broadcast_channel" + discoverygroup="${discoverygroup} 10000" + discoverygroup="${discoverygroup} " + sed -i -ne "// {p; i $discoverygroup" -e ":a; n; /<\/discovery-groups>/ {p; b}; ba}; p" ${instanceDir}/etc/broker.xml + + #generate jgroups-ping.xml + echo "Generating jgroups-ping.xml, current dir is: $PWD, AMQHOME: $AMQ_HOME" + + if [ -z "${PING_SVC_NAME+x}" ]; then + echo "PING_SERVICE is not set" + PING_SVC_NAME=ping + fi + + if [ -z "${APPLICATION_NAME+x}" ]; then + echo "APPLICATION_NAME is not set" + sed -i -e "s/\${APPLICATION_NAME}-\${PING_SVC_NAME}/${PING_SVC_NAME}/" $AMQ_HOME/conf/jgroups-ping.xml + else + echo "APPLICATION_NAME is set" + sed -i -e "s/\${APPLICATION_NAME}-\${PING_SVC_NAME}/${APPLICATION_NAME}-${PING_SVC_NAME}/" $AMQ_HOME/conf/jgroups-ping.xml + fi + + broadcastgroup="" + broadcastgroup="${broadcastgroup} " + broadcastgroup="${broadcastgroup} jgroups-ping.xml" + broadcastgroup="${broadcastgroup} activemq_broadcast_channel" + broadcastgroup="${broadcastgroup} artemis" + broadcastgroup="${broadcastgroup} " + sed -i -ne "// {p; i $broadcastgroup" -e ":a; n; /<\/broadcast-groups>/ {p; b}; ba}; p" ${instanceDir}/etc/broker.xml + + clusterconnections="" + clusterconnections="${clusterconnections} " + clusterconnections="${clusterconnections} artemis" + clusterconnections="${clusterconnections} 1000" + clusterconnections="${clusterconnections} 2" + clusterconnections="${clusterconnections} 32000" + clusterconnections="${clusterconnections} 20" + clusterconnections="${clusterconnections} 10" + clusterconnections="${clusterconnections} true" + clusterconnections="${clusterconnections} ON_DEMAND" + clusterconnections="${clusterconnections} 1" + clusterconnections="${clusterconnections} " + clusterconnections="${clusterconnections} " + sed -i -ne "// {p; i $clusterconnections" -e ":a; n; /<\/cluster-connections>/ {p; b}; ba}; p" ${instanceDir}/etc/broker.xml +} + +function configureJAVA_ARGSMemory() { + instanceDir=$1 + echo "Removing hardcoded -Xms -Xmx from artemis.profile in favour of JAVA_OPTS in log above" + sed -i "s/\-Xms[0-9]*[mMgG] \-Xmx[0-9]*[mMgG] \-Dhawtio/\ -Dhawtio/g" ${instanceDir}/etc/artemis.profile +} + +function configureJolokiaJVMAgent() { + instanceDir=$1 + if [ "$AMQ_ENABLE_JOLOKIA_AGENT" = "true" ]; then + echo "Configure jolokia jvm agent" + echo "JOLOKIA_OPTS: $JOLOKIA_OPTS" + echo '' >> ${instanceDir}/etc/artemis.profile + echo "if [ \"\$1\" = \"run\" ]; then JAVA_ARGS=\"\$JAVA_ARGS $JOLOKIA_OPTS\"; fi" >> ${instanceDir}/etc/artemis.profile + echo '' >> ${instanceDir}/etc/artemis.profile + fi +} + +function injectMetricsPlugin() { + instanceDir=$1 + echo "Adding artemis metrics plugin" + sed -i "s/^\([[:blank:]]*\)<\\/core>/\1\1\\n\1<\\/core>/" $instanceDir/etc/broker.xml + + if ! grep -q 'metrics' $instanceDir/etc/bootstrap.xml; then + sed -i 's~~~' $instanceDir/etc/bootstrap.xml + fi + +} + +function checkBeforeRun() { + instanceDir=$1 + if [ "$AMQ_ENABLE_METRICS_PLUGIN" = "true" ]; then + pluginStr="com.redhat.amq.broker.core.server.metrics.plugins.ArtemisPrometheusMetricsPlugin" + grep -q "$pluginStr" ${instanceDir}/etc/broker.xml + result=$? + if [[ $result == 0 ]]; then + echo "The Prometheus plugin already configured." + else + echo "Need to inject Prometheus plugin" + injectMetricsPlugin ${instanceDir} + fi + fi + + if [[ "${JAVA_ARGS_APPEND}" == *"-Dlog4j2.configurationFile"* ]]; then + echo "There is a custom logger configuration defined in JAVA_ARGS_APPEND: ${JAVA_ARGS_APPEND}" + else + echo "Using default logging configuration(console only)" + defaultLoggingConfigFile=${instanceDir}/etc/log4j2.properties + sed -i "s/rootLogger = INFO, console, log_file/rootLogger = INFO, console/g" $defaultLoggingConfigFile + fi +} + +function configure() { + instanceDir=$1 + + export CONTAINER_ID=$HOSTNAME + if [ ! -d ${instanceDir} -o "$AMQ_RESET_CONFIG" = "true" -o ! -f ${instanceDir}/bin/artemis ]; then + AMQ_ARGS="--silent --role $AMQ_ROLE --name $AMQ_NAME --http-host $BROKER_IP --java-options=-Djava.net.preferIPv4Stack=true " + configureUserAuthentication + if [ -n "$AMQ_DATA_DIR" ]; then + AMQ_ARGS="$AMQ_ARGS --data ${AMQ_DATA_DIR}" + fi + if [ -n "$AMQ_QUEUES" ]; then + AMQ_ARGS="$AMQ_ARGS --queues $(removeWhiteSpace $AMQ_QUEUES)" + fi + if [ -n "$AMQ_ADDRESSES" ]; then + AMQ_ARGS="$AMQ_ARGS --addresses $(removeWhiteSpace $AMQ_ADDRESSES)" + fi + if [ -n "$AMQ_ACCEPTORS" ]; then + AMQ_ARGS="$AMQ_ARGS --no-amqp-acceptor --no-hornetq-acceptor --no-mqtt-acceptor --no-stomp-acceptor" + else + if [ -n "$AMQ_TRANSPORTS" ]; then + if [[ $(removeWhiteSpace ${AMQ_TRANSPORTS}) != *"hornetq"* ]]; then + AMQ_ARGS="$AMQ_ARGS --no-hornetq-acceptor" + fi + if [[ $(removeWhiteSpace ${AMQ_TRANSPORTS}) != *"amqp"* ]]; then + AMQ_ARGS="$AMQ_ARGS --no-amqp-acceptor" + fi + if [[ $(removeWhiteSpace ${AMQ_TRANSPORTS}) != *"mqtt"* ]]; then + AMQ_ARGS="$AMQ_ARGS --no-mqtt-acceptor" + fi + if [[ $(removeWhiteSpace ${AMQ_TRANSPORTS}) != *"stomp"* ]]; then + AMQ_ARGS="$AMQ_ARGS --no-stomp-acceptor" + fi + fi + fi + if [ -n "$GLOBAL_MAX_SIZE" ]; then + AMQ_ARGS="$AMQ_ARGS --global-max-size $(removeWhiteSpace $GLOBAL_MAX_SIZE)" + fi + if [ "$AMQ_RESET_CONFIG" = "true" ]; then + AMQ_ARGS="$AMQ_ARGS --force" + fi + if [ "$AMQ_EXTRA_ARGS" ]; then + AMQ_ARGS="$AMQ_ARGS $AMQ_EXTRA_ARGS" + fi + configureNetworking + configureSSL + appendJournalType ${instanceDir} + + # mask sensitive values + PRINT_ARGS="${AMQ_ARGS/--password $AMQ_PASSWORD/--password XXXXX}" + PRINT_ARGS="${PRINT_ARGS/--user $AMQ_USER/--user XXXXX}" + PRINT_ARGS="${PRINT_ARGS/--cluster-user $AMQ_CLUSTER_USER/--cluster-user XXXXX}" + PRINT_ARGS="${PRINT_ARGS/--cluster-password $AMQ_CLUSTER_PASSWORD/--cluster-password XXXXX}" + PRINT_ARGS="${PRINT_ARGS/--ssl-key-password $AMQ_KEYSTORE_PASSWORD/--ssl-key-password XXXXX}" + PRINT_ARGS="${PRINT_ARGS/--ssl-trust-password $AMQ_TRUSTSTORE_PASSWORD/--ssl-trust-password XXXXX}" + + if [ "$AMQ_CONSOLE_ARGS" ]; then + AMQ_ARGS="$AMQ_ARGS $AMQ_CONSOLE_ARGS" + keypat='(.*)(--ssl-key-password).([[:alnum:]]*)(.*)' + [[ "$AMQ_CONSOLE_ARGS" =~ $keypat ]] + CONSOLE_ARGS_NO_KEYPASS="${BASH_REMATCH[1]} ${BASH_REMATCH[2]} XXXXX ${BASH_REMATCH[4]}" + trustpat='(.*)(--ssl-trust-password).([[:alnum:]]*)(.*)' + [[ "$CONSOLE_ARGS_NO_KEYPASS" =~ $trustpat ]] + CONSOLE_ARGS_NO_TRUSTPASS="${BASH_REMATCH[1]} ${BASH_REMATCH[2]} XXXXX ${BASH_REMATCH[4]}" + PRINT_ARGS="${PRINT_ARGS} ${CONSOLE_ARGS_NO_TRUSTPASS}" + fi + + + echo "Creating Broker with args $PRINT_ARGS" + $AMQ_HOME/bin/artemis create ${instanceDir} $AMQ_ARGS --java-options "$JAVA_OPTS" + + if [ "$AMQ_CLUSTERED" = "true" ]; then + modifyDiscovery + configureRedistributionDelay ${instanceDir} + fi + $AMQ_HOME/bin/configure_jolokia_access.sh ${instanceDir}/etc/jolokia-access.xml + if [ "$AMQ_KEYSTORE_TRUSTSTORE_DIR" ]; then + echo "Updating acceptors for SSL" + updateAcceptorsForSSL ${instanceDir} + fi + updateAcceptorsForPrefixing ${instanceDir} + appendAcceptorsFromEnv ${instanceDir} + appendConnectorsFromEnv ${instanceDir} + configureLogging ${instanceDir} + configureJAVA_ARGSMemory ${instanceDir} + configureJolokiaJVMAgent ${instanceDir} + + if [ "$AMQ_ENABLE_METRICS_PLUGIN" = "true" ]; then + echo "Enable artemis metrics plugin" + injectMetricsPlugin ${instanceDir} + fi + + $AMQ_HOME/bin/configure_s2i_files.sh ${instanceDir} + $AMQ_HOME/bin/configure_custom_config.sh ${instanceDir} + fi +} + +function removeWhiteSpace() { + echo $*|tr -s ''| tr -d [[:space:]] +} + +function runServer() { + + echo "Configuring Broker" + instanceDir="${HOME}/${AMQ_NAME}" + + configure $instanceDir + + if [ "$1" != "nostart" ]; then + echo "Running Broker in ${instanceDir}" + checkBeforeRun ${instanceDir} + exec ${instanceDir}/bin/artemis run + fi +} + +runServer $1 + diff --git a/artemis-broker/templates/_drain.tpl b/artemis-broker/templates/_drain.tpl new file mode 100644 index 0000000..fed9650 --- /dev/null +++ b/artemis-broker/templates/_drain.tpl @@ -0,0 +1,132 @@ +{{- define "drainer.pod" -}} +alpha.image.policy.openshift.io/resolve-names: "*" +statefulsets.kubernetes.io/drainer-pod-template: | + { + "metadata": { + "labels": { + "app": "{{ .Values.application.name }}-amq-drainer" + } + }, + "spec": { + "serviceAccount": "{{ tpl .Values.templates.service_account .}}", + "serviceAccountName": "{{ tpl .Values.templates.service_account .}}", + "terminationGracePeriodSeconds": 5, + "containers": [ + { + "env": [ + { + "name": "APPLICATION_NAME", + "value": "{{ .Values.application.name }}" + }, + { + "name": "HEADLESS_ENDPOINT", + "value": "{{ tpl .Values.templates.service . }}" + }, + { + "name": "PING_SVC_NAME", + "value": "{{ tpl .Values.ping_service.name . }}" + }, + { + "name": "AMQ_EXTRA_ARGS", + "value": "--no-autotune" + }, + { + "name": "AMQ_USER", + "valueFrom": { + "secretKeyRef": { + "name": "{{ tpl .Values.templates.app_secret . }}", + "key": "AMQ_USER" + } + } + }, + { + "name": "AMQ_PASSWORD", + "valueFrom": { + "secretKeyRef": { + "name": "{{ tpl .Values.templates.app_secret . }}", + "key": "AMQ_PASSWORD" + } + } + }, + { + "name": "AMQ_ROLE", + "value": "{{ .Values.admin.role }}" + }, + { + "name": "AMQ_NAME", + "value": "{{ .Values.parameters.amq_broker_name }}" + }, + { + "name": "AMQ_TRANSPORTS", + "value": "{{ .Values.parameters.amq_protocols }}" + }, + { + "name": "AMQ_GLOBAL_MAX_SIZE", + "value": "{{ .Values.parameters.amq_global_max_size }}" + }, + { + "name": "AMQ_ALLOW_ANONYMOUS", + "value": "{{ .Values.parameters.allow_anonymous }}" + }, + { + "name": "AMQ_DATA_DIR", + "value": "{{ .Values.parameters.amq_data_dir }}" + }, + { + "name": "AMQ_DATA_DIR_LOGGING", + "value": "{{ .Values.parameters.amq_data_dir_logging }}" + }, + { + "name": "AMQ_CLUSTERED", + "value": "{{ .Values.parameters.amq_clustered }}" + }, + { + "name": "AMQ_REPLICAS", + "value": "{{ .Values.application.replicas }}" + }, + { + "name": "AMQ_CLUSTER_USER", + "valueFrom": { + "secretKeyRef": { + "name": "{{ tpl .Values.templates.app_secret .}}", + "key": "AMQ_CLUSTER_USER" + } + } + }, + { + "name": "AMQ_CLUSTER_PASSWORD", + "valueFrom": { + "secretKeyRef": { + "name": "{{ tpl .Values.templates.app_secret .}}", + "key": "AMQ_CLUSTER_PASSWORD" + } + } + }, + { + "name": "POD_NAMESPACE", + "valueFrom": { + "fieldRef": { + "fieldPath": "metadata.namespace" + } + } + }, + { + "name": "OPENSHIFT_DNS_PING_SERVICE_PORT", + "value": "{{ .Values.ping_service.jgroups.bind_port }}" + } + ], + "image": "{{ tpl .Values.templates.broker_image .}}", + "name": "{{ .Values.application.name }}-amq-drainer-pod", + + "command": ["/bin/sh", "-c", "echo \"Starting the drainer\" ; /opt/amq/bin/drain.sh; echo \"Drain completed! Exit code $?\""], + "volumeMounts": [ + { + "name": "{{ tpl .Values.templates.pvc_name . }}", + "mountPath": "{{ .Values.parameters.amq_data_dir }}" + } + ] + } + ] + } + } +{{- end -}} diff --git a/artemis-broker/templates/_pod.tpl b/artemis-broker/templates/_pod.tpl new file mode 100644 index 0000000..de5a826 --- /dev/null +++ b/artemis-broker/templates/_pod.tpl @@ -0,0 +1,179 @@ +{{- define "amq.pod" -}} +{{- if eq .Values.platform "kubernetes" -}} +imagePullSecrets: + - name: {{ .Values.application.pullSecretName }} +{{- end }} +containers: +- env: +{{- if .Values.clustered }} + - name: APPLICATION_NAME + value: "{{ .Values.application.name }}" + - name: PING_SVC_NAME + value: "{{ tpl .Values.ping_service.name . }}" + - name: AMQ_CLUSTERED + value: "{{ .Values.clustered }}" + - name: AMQ_REPLICAS + value: "{{ .Values.application.replicas }}" + - name: AMQ_CLUSTER_USER + valueFrom: + secretKeyRef: + name: {{ tpl .Values.templates.app_secret . }} + key: AMQ_CLUSTER_USER + - name: AMQ_CLUSTER_PASSWORD + valueFrom: + secretKeyRef: + name: {{ tpl .Values.templates.app_secret . }} + key: AMQ_CLUSTER_PASSWORD + - name: OPENSHIFT_DNS_PING_SERVICE_PORT + value: "{{ .Values.ping_service.jgroups.bind_port }}" + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace +{{- end }} + - name: AMQ_USER + valueFrom: + secretKeyRef: + name: {{ tpl .Values.templates.app_secret . }} + key: AMQ_USER + - name: AMQ_PASSWORD + valueFrom: + secretKeyRef: + name: {{ tpl .Values.templates.app_secret . }} + key: AMQ_PASSWORD + - name: AMQ_ROLE + value: "{{ .Values.admin.role }}" + - name: AMQ_NAME + value: "{{ .Values.parameters.amq_broker_name }}" + - name: AMQ_TRANSPORTS + value: "{{ .Values.parameters.amq_protocols }}" + {{- if .Values.parameters.tls_enabled }} + - name: AB_JOLOKIA_HTTPS + value: "{{ .Values.parameters.jolokia_passthrough }}" + - name: AMQ_KEYSTORE_TRUSTSTORE_DIR + value: {{ .Values.tls.secret_mount_path }} + - name: AMQ_TRUSTSTORE + value: {{ .Values.tls.truststore }} + - name: AMQ_TRUSTSTORE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ tpl .Values.templates.app_certificates . }} + key: AMQ_TRUSTSTORE_PASSWORD + - name: AMQ_KEYSTORE + value: {{ .Values.tls.keystore }} + - name: AMQ_KEYSTORE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ tpl .Values.templates.app_certificates . }} + key: AMQ_KEYSTORE_PASSWORD + - name: AMQ_SSL_PROVIDER + value: {{ tpl .Values.parameters.ssl_provider . }} + {{- end }} + - name: AMQ_GLOBAL_MAX_SIZE + value: "{{ .Values.parameters.amq_global_max_size }}" + - name: AMQ_REQUIRE_LOGIN + value: "{{ .Values.parameters.amq_require_login }}" + {{- if .Values.application.persistent }} + - name: AMQ_DATA_DIR + value: "{{ .Values.parameters.amq_data_dir }}" + {{- end }} + - name: AMQ_EXTRA_ARGS + value: {{ if .Values.parameters.amq_extra_args }} "{{ .Values.parameters.amq_extra_args }}" {{ else }} "" {{ end }} + - name: AMQ_ANYCAST_PREFIX + value: {{ if .Values.parameters.amq_anycast_prefix }} "{{ .Values.parameters.amq_anycast_prefix }}" {{ else }} "jms.queue." {{ end }} + - name: AMQ_MULTICAST_PREFIX + value: {{ if .Values.parameters.amq_multicast_prefix }} "{{ .Values.parameters.amq_multicast_prefix }}" {{ else }} "jms.topic." {{ end }} + - name: AMQ_ENABLE_METRICS_PLUGIN + value: {{ .Values.metrics.enabled | quote }} + - name: AMQ_JOURNAL_TYPE + value: "{{ .Values.parameters.amq_journal_type }}" + image: {{ tpl .Values.templates.broker_image . }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 4 -}} + {{- end }} + imagePullPolicy: {{ .Values.application.pullPolicy }} + readinessProbe: + exec: + command: + - "/bin/bash" + - "-c" + - "/opt/amq/bin/readinessProbe.sh" + name: {{ tpl .Values.templates.deployment . }} + ports: + {{- range .Values.service.acceptors }} + - containerPort: {{ .port }} + name: {{ .name }} + protocol: {{ .protocol }} + {{- end }} + {{- range .Values.service.console }} + - containerPort: {{ .port }} + name: {{ .name }} + protocol: {{ .protocol }} + {{- end }} + volumeMounts: + {{- if .Values.application.persistent }} + - name: {{ tpl .Values.templates.pvc_name . }} + mountPath: {{ .Values.parameters.amq_data_dir }} + {{- end }} + - name: broker-config-script-custom + mountPath: /opt/amq/bin/configure_custom_config.sh + subPath: configure_custom_config.sh + readOnly: true + - name: broker-config-script-custom + mountPath: /opt/amq/bin/launch.sh + subPath: launch.sh + readOnly: true + {{- if .Values.clustered }} + - name: broker-config-script-custom + mountPath: /opt/amq/bin/drain.sh + subPath: drain.sh + readOnly: true + {{- end }} + - name: broker-config-volume + mountPath: "/opt/amq/conf" + readOnly: true + {{- if .Values.parameters.tls_enabled }} + - mountPath: {{ .Values.tls.secret_mount_path }} + name: broker-secret-volume + readOnly: true + {{- end }} +terminationGracePeriodSeconds: 60 +volumes: + {{- if .Values.parameters.tls_enabled }} + - name: broker-secret-volume + secret: + secretName: {{ tpl .Values.templates.app_certificates . }} + {{- end }} + - name: broker-config-script-custom + configMap: + name: {{ tpl .Values.templates.override_cm . }} + items: + - key: configure_custom_config.sh + path: configure_custom_config.sh + - key: launch.sh + path: launch.sh + {{- if .Values.clustered }} + - key: drain.sh + path: drain.sh + {{- end }} + defaultMode: 0550 + - name: broker-config-volume + projected: + sources: + - configMap: + name: {{ tpl .Values.templates.config_cm . }} + {{- range .Values.security.secrets }} + - secret: + name: {{ . }} + {{- end }} + {{- if and (eq .Values.kind "Deployment") (.Values.application.persistent) }} + - name: {{ tpl .Values.templates.pvc_name . }} + persistentVolumeClaim: + {{- if eq .Values.ha_ap.mode "primary" }} + claimName: {{ tpl .Values.templates.pvc_name . }} + {{- else }} + claimName: {{ .Values.ha_ap.connector.static.ref }}-persistent-volume + {{- end }} + {{- end }} +{{- end }} diff --git a/artemis-broker/templates/configmap.yaml b/artemis-broker/templates/configmap.yaml new file mode 100644 index 0000000..d557c55 --- /dev/null +++ b/artemis-broker/templates/configmap.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ tpl .Values.templates.override_cm . }} +data: + {{- (.Files.Glob "scripts-override/**.sh").AsConfig | nindent 2 }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ tpl .Values.templates.config_cm . }} +data: + {{ tpl (.Files.Glob "conf/**").AsConfig . | nindent 2 }} \ No newline at end of file diff --git a/artemis-broker/templates/deployment.yaml b/artemis-broker/templates/deployment.yaml new file mode 100644 index 0000000..6652739 --- /dev/null +++ b/artemis-broker/templates/deployment.yaml @@ -0,0 +1,35 @@ +{{- if eq .Values.kind "Deployment" }} +{{- if and .Values.clustered (not .Values.cluster.ha_ap_mode) }} + {{- fail ".Values.kind is set to Deployment but this is unsupported in a clustered environment. Use a StatefulSet" }} +{{- else }} +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + application: {{ .Values.application.name }} + name: {{ tpl .Values.templates.deployment . }} +{{- if .Values.clustered }} + annotations: + {{- include "drainer.pod" . | nindent 6 }} +{{- end }} +spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: + application: {{ .Values.application.name }} + strategy: + type: Recreate + template: + metadata: + # trigger deployments on config map changes + annotations: + configmap/checksum: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + labels: + application: {{ .Values.application.name }} + deployment: {{ tpl .Values.templates.deployment . }} + name: {{ tpl .Values.templates.deployment . }} + spec: + {{- include "amq.pod" . | nindent 6 }} +{{- end }} +{{- end }} diff --git a/artemis-broker/templates/ingress.yaml b/artemis-broker/templates/ingress.yaml new file mode 100644 index 0000000..dde847b --- /dev/null +++ b/artemis-broker/templates/ingress.yaml @@ -0,0 +1,64 @@ +{{- if eq .Values.platform "kubernetes" }} +{{- $route_name := tpl .Values.templates.route . }} +{{- $svc_name := tpl .Values.templates.service . }} +{{- if .Values.parameters.tls_enabled }} +{{- if not .Values.clustered }} +{{- if .Values.ingress.passthrough.enabled }} +{{- range .Values.service.acceptors }} +{{- $nm := toString .name }} +{{- if eq $nm $.Values.ingress.passthrough.service }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: "{{ $route_name }}-passthrough" + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/ssl-passthrough: "true" + nginx.ingress.kubernetes.io/ssl-redirect: "true" +spec: + ingressClassName: {{ $.Values.ingress.className }} + rules: + - host: "{{ $route_name }}-passthrough.{{ $.Values.ingress.domain }}" + http: + paths: + - path: "{{ $.Values.ingress.passthrough.path }}" + pathType: Prefix + backend: + service: + name: {{ $svc_name }} + port: + number: {{ .port }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} +{{- if .Values.ingress.console.enabled }} +{{- range .Values.service.console }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: "{{ $route_name }}-console" +spec: + {{- if $.Values.ingress.console.tls }} + tls: + - hosts: + - "{{ $route_name }}-console.{{ $.Values.ingress.domain }}" + secretName: {{ $.Values.ingress.console.tlsSecretName }} + {{- end }} + rules: + - host: "{{ $route_name }}-console.{{ $.Values.ingress.domain }}" + http: + paths: + - path: "{{ $.Values.ingress.console.path }}" + pathType: Prefix + backend: + service: + name: {{ $svc_name }} + port: + number: {{ .port }} +{{- end }} +{{- end }} +{{- end }} diff --git a/artemis-broker/templates/nodeport.yaml b/artemis-broker/templates/nodeport.yaml new file mode 100644 index 0000000..993a15e --- /dev/null +++ b/artemis-broker/templates/nodeport.yaml @@ -0,0 +1,26 @@ +{{- if .Values.nodeport.enabled }} +{{- $np_svc := .Values.nodeport }} +{{- range .Values.service.acceptors }} +{{- if eq .name $np_svc.service }} +--- +apiVersion: v1 +kind: Service +metadata: + labels: + application: {{ $.Values.application.name }} + name: {{ $.Values.application.name }}-nodeport-svc +spec: + ports: + - name: {{ quote .name }} + port: {{ .port }} + protocol: {{ quote .protocol }} + targetPort: {{ .port }} + nodePort: {{ $np_svc.port }} + publishNotReadyAddresses: true + selector: + application: {{ $.Values.application.name }} + sessionAffinity: None + type: NodePort +{{- end }} +{{- end }} +{{- end }} diff --git a/artemis-broker/templates/persistentvolume.yaml b/artemis-broker/templates/persistentvolume.yaml new file mode 100644 index 0000000..a90b74c --- /dev/null +++ b/artemis-broker/templates/persistentvolume.yaml @@ -0,0 +1,13 @@ +{{- if and (eq .Values.kind "Deployment") (eq .Values.ha_ap.mode "primary") (.Values.application.persistent) }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ tpl .Values.templates.pvc_name . }} +spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: {{ .Values.application.volume_capacity }} + storageClassName: "{{ .Values.application.storageclass }}" +{{- end }} diff --git a/artemis-broker/templates/rbac.yaml b/artemis-broker/templates/rbac.yaml new file mode 100644 index 0000000..5378722 --- /dev/null +++ b/artemis-broker/templates/rbac.yaml @@ -0,0 +1,56 @@ +{{- if .Values.clustered }} +{{- $service_account := tpl .Values.templates.service_account . }} +{{- $role := tpl .Values.templates.k8s_role . }} +{{- $rolebinding := tpl .Values.templates.k8s_rolebinding . }} +{{- with $app := .Values.application.name }} +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ $service_account }} + labels: + app: {{ $app }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ $role }} + labels: + app: {{ $app }} +rules: +- apiGroups: + - "" + resources: + - endpoints + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch +- apiGroups: + - "" + resources: + - namespaces + verbs: + - get + - list +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ $rolebinding }} + labels: + app: {{ $app }} +subjects: + - kind: ServiceAccount + name: {{ $service_account }} +roleRef: + kind: Role + name: {{ $role }} + apiGroup: rbac.authorization.k8s.io +{{- end }} +{{- end }} diff --git a/artemis-broker/templates/route.yaml b/artemis-broker/templates/route.yaml new file mode 100644 index 0000000..c2dcdb8 --- /dev/null +++ b/artemis-broker/templates/route.yaml @@ -0,0 +1,65 @@ +{{- if eq .Values.platform "openshift" }} +{{- $svc_name := tpl .Values.templates.service . }} +{{- $app_name := tpl .Values.application.name . }} +{{- $route_name := tpl .Values.templates.route . }} +{{- $jolokia_ssl := and (.Values.parameters.tls_enabled) (.Values.parameters.jolokia_passthrough) }} +{{- range .Values.service.console }} +--- +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + labels: + application: {{ $app_name }} + name: {{ $route_name }}-console +spec: + {{- if $.Values.parameters.append_ns }} + host: {{ $route_name }}.{{ $.Release.Namespace }}.{{ $.Values.parameters.openshift_appdomain }} + {{- else }} + host: {{ $route_name }}.{{ $.Values.parameters.openshift_appdomain }} + {{- end }} + to: + kind: Service + name: {{ $svc_name }} + port: + targetPort: {{ .port }} + tls: +{{- if $jolokia_ssl }} + termination: passthrough +{{- else }} + termination: edge +{{- end }} + insecureEdgeTerminationPolicy: Redirect + wildcardPolicy: None +{{- end }} +{{- if not .Values.clustered }} +{{- if .Values.passthrough_route.enabled }} +{{- range .Values.service.acceptors }} +{{- $nm := toString .name }} +{{- if eq $nm $.Values.passthrough_route.service }} +--- +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + labels: + application: {{ $app_name }} + name: {{ $route_name }}-passthrough +spec: + {{- if $.Values.parameters.append_ns }} + host: {{ $.Values.passthrough_route.hostname }}.{{ $.Release.Namespace }}.{{ $.Values.parameters.openshift_appdomain }} + {{- else }} + host: {{ $.Values.passthrough_route.hostname }}.{{ $.Values.parameters.openshift_appdomain }} + {{- end }} + to: + kind: Service + name: {{ $svc_name }} + port: + targetPort: {{ .port }} + tls: + termination: passthrough + insecureEdgeTerminationPolicy: Redirect + wildcardPolicy: None +{{- end }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/artemis-broker/templates/secrets.yaml b/artemis-broker/templates/secrets.yaml new file mode 100644 index 0000000..22ed405 --- /dev/null +++ b/artemis-broker/templates/secrets.yaml @@ -0,0 +1,42 @@ +{{- if .Values.security.createSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ tpl .Values.templates.app_secret .}} +type: Opaque +data: + AMQ_USER: {{ b64enc .Values.admin.user }} + AMQ_PASSWORD: {{ b64enc .Values.admin.password }} + {{- if .Values.clustered }} + AMQ_CLUSTER_USER: {{ b64enc .Values.admin.cluster_user }} + AMQ_CLUSTER_PASSWORD: {{ b64enc .Values.admin.cluster_password }} + {{- end }} +{{- end }} +{{- if .Values.parameters.tls_enabled }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ tpl .Values.templates.app_certificates . }} +type: Opaque +data: + AMQ_KEYSTORE_PASSWORD: {{ b64enc .Values.tls.keystore_password }} + AMQ_TRUSTSTORE_PASSWORD: {{ b64enc .Values.tls.truststore_password }} + {{- range tuple .Values.tls.keystore .Values.tls.truststore }} + {{ . }}: |- + {{ ( printf "%s%s" "tls/" . | $.Files.Get ) | b64enc }} + {{- end }} +{{- end }} +{{- if and (eq .Values.platform "kubernetes") (.Values.ingress.console.tls) }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.ingress.console.tlsSecretName }} +data: + tls.crt: |- + {{ ( printf "%s%s" "tls/" .Values.ingress.console.cert | $.Files.Get) | b64enc }} + tls.key: |- + {{ ( printf "%s%s" "tls/" .Values.ingress.console.key | $.Files.Get) | b64enc }} +type: kubernetes.io/tls +{{- end }} diff --git a/artemis-broker/templates/servicemonitor.yaml b/artemis-broker/templates/servicemonitor.yaml new file mode 100644 index 0000000..f8e90c3 --- /dev/null +++ b/artemis-broker/templates/servicemonitor.yaml @@ -0,0 +1,16 @@ +{{- if .Values.metrics.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ .Values.application.name }}-monitor + labels: + prometheus: prometheus-app +spec: + selector: + matchLabels: + application: {{ .Values.application.name }} + endpoints: + - targetPort: {{ .Values.metrics.servicemonitor.port }} + path: /metrics/ + interval: {{ .Values.metrics.servicemonitor.interval }} +{{- end }} \ No newline at end of file diff --git a/artemis-broker/templates/services.yaml b/artemis-broker/templates/services.yaml new file mode 100644 index 0000000..eb9ae10 --- /dev/null +++ b/artemis-broker/templates/services.yaml @@ -0,0 +1,57 @@ +{{- $application_name := .Values.application.name }} +{{- $svc_name := tpl .Values.templates.service . }} +{{- $dc_name := tpl .Values.templates.deployment . }} +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + {{- if eq .Values.kind "StatefulSet" }} + description: The broker's headless, non load balanced service + {{- else }} + description: AMQ Broker Service + {{- end }} + labels: + application: {{ $application_name }} + app: {{ $application_name }} + name: {{ $svc_name }} +spec: + {{- if eq .Values.kind "StatefulSet" }} + clusterIP: None + {{- end }} + type: ClusterIP + publishNotReadyAddresses: true + ports: + {{- range .Values.service.acceptors }} + - port: {{ .port }} + name: {{ .name }} + protocol: {{ .protocol }} + targetPort: {{ .port }} + {{- end }} + {{- range .Values.service.console }} + - port: {{ .port }} + name: {{ .name }} + protocol: {{ .protocol }} + targetPort: {{ .port }} + {{- end }} + selector: + deployment: {{ $dc_name }} +{{- if .Values.clustered }} +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + description: The JGroups ping port for clustering. + service.alpha.kubernetes.io/tolerate-unready-endpoints: 'true' + labels: + application: {{ $application_name }} + name: {{ tpl .Values.ping_service.name . }} +spec: + clusterIP: None + ports: + - targetPort: {{ .Values.ping_service.port }} + port: {{ .Values.ping_service.port }} + selector: + deployment: {{ $dc_name }} +{{- end }} diff --git a/artemis-broker/templates/statefulset.yaml b/artemis-broker/templates/statefulset.yaml new file mode 100644 index 0000000..b3e08f4 --- /dev/null +++ b/artemis-broker/templates/statefulset.yaml @@ -0,0 +1,50 @@ +{{- if eq .Values.kind "StatefulSet" }} +{{- $svc_name := tpl .Values.templates.service . }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + application: {{ .Values.application.name }} + name: {{ tpl .Values.templates.deployment . }} +{{- if .Values.clustered }} + annotations: + {{- include "drainer.pod" . | nindent 6 }} +{{- end }} +spec: + revisionHistoryLimit: 2 + selector: + matchLabels: + application: {{ .Values.application.name }} + {{- if .Values.clustered }} + podManagementPolicy: OrderedReady + replicas: {{ .Values.application.replicas }} + {{- else }} + replicas: 1 + {{- end }} + serviceName: {{ $svc_name }} + template: + metadata: + # trigger deployments on config map changes + annotations: + configmap/checksum: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + labels: + application: {{ .Values.application.name }} + deployment: {{ tpl .Values.templates.deployment . }} + app: {{ .Values.application.name }} + name: {{ tpl .Values.templates.deployment . }} + spec: + {{- include "amq.pod" . | nindent 6 }} + {{- if .Values.application.persistent }} + volumeClaimTemplates: + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: {{ tpl .Values.templates.pvc_name . }} + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: {{ .Values.application.volume_capacity }} + storageClassName: "{{ .Values.application.storageclass }}" + {{- end }} +{{- end }} diff --git a/artemis-broker/tls/ingress_console.crt b/artemis-broker/tls/ingress_console.crt new file mode 100644 index 0000000..4f2e970 --- /dev/null +++ b/artemis-broker/tls/ingress_console.crt @@ -0,0 +1 @@ +PLACEHOLDER diff --git a/artemis-broker/tls/ingress_console.key b/artemis-broker/tls/ingress_console.key new file mode 100644 index 0000000..4f2e970 --- /dev/null +++ b/artemis-broker/tls/ingress_console.key @@ -0,0 +1 @@ +PLACEHOLDER diff --git a/artemis-broker/tls/keystore.ks b/artemis-broker/tls/keystore.ks new file mode 100644 index 0000000..4f2e970 --- /dev/null +++ b/artemis-broker/tls/keystore.ks @@ -0,0 +1 @@ +PLACEHOLDER diff --git a/artemis-broker/tls/keystore.ts b/artemis-broker/tls/keystore.ts new file mode 100644 index 0000000..4f2e970 --- /dev/null +++ b/artemis-broker/tls/keystore.ts @@ -0,0 +1 @@ +PLACEHOLDER diff --git a/artemis-broker/values.yaml b/artemis-broker/values.yaml new file mode 100644 index 0000000..b7fe305 --- /dev/null +++ b/artemis-broker/values.yaml @@ -0,0 +1,227 @@ +# Deploy broker as Deployment or StatefulSet +# if clustered is True, then only StatefulSet is supported +kind: Deployment +clustered: false # only with StatefulSet + +# Platform type. +platform: kubernetes + +application: + name: broker1 # set broker1 is this for primary deployment else set to broker2 + amq_broker_version: 55ae4e28b100534d63c34ab86f69230d274c999d46d1493f26fe3e75ba7a0cec # 7.12.3 + amq_broker_image: registry.redhat.io/amq7/amq-broker-rhel8 + pullPolicy: IfNotPresent + persistent: true + journal_type: ASYNCIO # more information see broker.xml + volume_capacity: "1G" + replicas: 1 + storageclass: default + # this is used if platform type is set as "kubernetes" + pullSecretName: redhat-pullsecret + +service: + console: + - name: jolokia + description: "The Jolokia Management Console Service" + protocol: TCP + port: 8161 + acceptors: + - name: multiplex + description: "Multiplexed protocol endpoint (CORE+All the others)" + protocol: TCP + # when tls is enabled, all acceptors are tls-protected. + # this behaviour can be overridden by marking the acceptor as non-tls + #use_tls: false + port: 61616 + # if needed, override the protocols here. + # default values are specified in the "parameters" section below + #amq_protocols: "CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE" + # also, additional properties for a single acceptor can be set here + #acceptor_params: + # - key: supportAdvisory + # value: false + # - key: suppressInternalManagementObjects + # value: false + +ping_service: + name: "{{ .Values.application.name }}-ping-svc" + port: 8888 + jgroups: + bind_port: 7800 + +nodeport: + port: 30003 + service: multiplex + enabled: true + +passthrough_route: + hostname: multiplex-amq + enabled: false + service: multiplex + +# only relevant for deployment on kubernetes +ingress: + # the ingress rule domain + domain: kubernetes.local + # passthrough ingress rule: only relevant for TLS enabled brokers + passthrough: + path: "/" + service: multiplex + enabled: true + # jolokia console ingress rule. optional tls certificates can be configured here + console: + path: "/" + service: jolokia + enabled: true + tls: false + tlsSecretName: "amq-console-ingress-certs" + cert: ingress_console.crt + key: ingress_console.key + +tls: + secret_mount_path: "/etc/amq-secret-volume" + keystore: keystore.ks + truststore: keystore.ts + keystore_password: kspwd + truststore_password: tspwd + +parameters: + tls_enabled: false + jolokia_passthrough: false + append_ns: false + openshift_appdomain: apps.cluster.local + amq_protocols: "openwire,amq,stomp,mqtt,hornetq,core" + amq_broker_name: "broker" + amq_global_max_size: "200 mb" + amq_require_login: False + amq_extra_args: "" + amq_anycast_prefix: "jmx.queue." + amq_multicast_prefix: "jmx.topic." + amq_journal_type: "nio" + ssl_provider: "jdk" # alternative is openssl + amq_data_dir: "/opt/amq/data" + amq_force_addresses_cleanup: True # if true remove all queues that are not declared here upon chart update + +cluster: + ha_ap_mode: false # Primary-Backup Mode / only with 2 Deployments + jgroupsCfg: "jgroups-ping.xml" + refreshTimeout: 10000 + connector: + ref: multiplex + port: 61616 + +ha_ap: + mode: primary + refreshTimeout: 10000 + connector: + ref: artemis + port: 61616 + static: + ref: broker2 # set broker2 is this for primary deployment else set to broker1 + port: 61616 + +templates: + service: "{{ .Values.application.name }}-svc" + service_account: "{{ .Values.application.name }}-sa" + k8s_role: "{{ .Values.application.name }}-role" + k8s_rolebinding: "{{ .Values.application.name }}-rolebinding" + deployment: "{{ .Values.application.name }}-dc" + route: "{{ .Values.application.name }}-route" + broker_image: "{{ .Values.application.amq_broker_image }}:{{ .Values.application.amq_broker_version }}" + override_cm: "{{ .Values.application.name }}-override-cm" + config_cm: "{{ .Values.application.name }}-config-cm" + app_secret: "{{ .Values.application.name }}-secret" + app_certificates: "{{ .Values.application.name }}-certificates" + pvc_name: "{{ .Values.application.name }}-persistent-volume" + +admin: + user: admin + password: password + cluster_user: cadmin + cluster_password: cpassword + role: "admin" + +security: + enabled: true + # Names of additional secrets to mount into configuration folder. + secrets: [] + createSecret: true + jaasUsers: + # Secret key entry name for Username password properties file. Override when files is provided by existing Secret. + key: artemis-users.properties + +# Add more users to this configuration +# Any users that gets assigned the .admin.role +# role name becomes an additional administrator +users: [] +# - name: demouser +# password: "demo" +# roles: +# - user +# - name: anotheruser +# password: "demo1" +# roles: +# - user +# +queues: + defaults: + maxDeliveryAttempts: 3 + redeliveryDelayMultiplier: 1 + redeliveryDelay: 5000 + maxRedeliveryDelay: 50000 + maxSizeBytes: "100 mb" + addressFullPolicy: "PAGE" + messageCounterHistoryDayLimit: 10 + addresses: [] +# - name: QUEUE_1 +# type: anycast # for queues, choose 'multicast' for topics +# dlq_address: QUEUE_1_DLQ +# expiry_address: +# maxDeliveryAttempts: +# redeliveryDelayMultiplier: +# redeliveryDelay: +# maxRedeliveryDelay: +# maxSizeBytes: +# messageCounterHistoryDayLimit: +# addressFullPolicy: +# permissions: +# - grant: consume +# roles: +# - admin +# - user +# - grant: browse +# roles: +# - admin +# - user +# - grant: send +# roles: +# - admin +# - user +# - grant: manage +# roles: +# - admin +# #- grant: createNonDurableQueue # uncomment this when declaring topics (with type: multicast) +# # roles: +# # - admin +# # - user + +# Add Metrics and Prometheus ServiceMonitor for collecting metrics +metrics: + enabled: false + jvm_memory: true + jvm_gc: false + jvm_threads: false + servicemonitor: + port: 8161 + interval: 20s + +# k8s resources +resources: {} +# limits: +# cpu: 1000m +# memory: 2000Mi +# requests: +# cpu: 200m +# memory: 1000Mi +# + diff --git a/values_helmChart.yaml b/values_helmChart.yaml new file mode 100644 index 0000000..df5fc4b --- /dev/null +++ b/values_helmChart.yaml @@ -0,0 +1,16 @@ +kind: Deployment +clustered: true +cluster: + ha_ap_mode: true +ha_ap: + connector: + ref: broker1 + static: + ref: broker2 +application: + name: broker1 + amq_broker_image: registry.tuxnet.lan/amq7/amq-broker-rhel8 + storageclass: nfs-delete + +ingress: + domain: tuxnet.lan diff --git a/values_helmChart__passive.yaml b/values_helmChart__passive.yaml new file mode 100644 index 0000000..a6c0fc6 --- /dev/null +++ b/values_helmChart__passive.yaml @@ -0,0 +1,19 @@ +kind: Deployment +clustered: true +cluster: + ha_ap_mode: true +ha_ap: + mode: backup + connector: + ref: broker2 + static: + ref: broker1 +application: + name: broker2 + amq_broker_image: registry.tuxnet.lan/amq7/amq-broker-rhel8 + +nodeport: + port: 30004 + +ingress: + domain: tuxnet.lan