├── .editorconfig ├── .eslintrc.json ├── .github └── workflows │ ├── ci.yaml │ └── release-please.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── index.js ├── package-lock.json ├── package-support.json ├── package.json └── test └── kube-probe-test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 2 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false 22 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "semistandard", 3 | "rules": { 4 | "prefer-const": "error", 5 | "block-scoped-var": "error", 6 | "prefer-template": "warn", 7 | "no-unneeded-ternary": "warn", 8 | "no-use-before-define": [ 9 | "error", 10 | "nofunc" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [12.x, 14.x, 16.x] 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | - name: Use Node.js ${{ matrix.node-version }} 24 | uses: actions/setup-node@v1 25 | with: 26 | node-version: ${{ matrix.node-version }} 27 | # Install Dependencies 28 | - run: npm ci 29 | # Run the linter and tests and coverage 30 | - run: npm run ci 31 | # Run package support validation 32 | - run: npx @pkgjs/support validate 33 | -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | name: release-please 6 | jobs: 7 | release-please: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: GoogleCloudPlatform/release-please-action@v2.4.1 11 | with: 12 | token: ${{ secrets.GITHUB_TOKEN }} 13 | release-type: node 14 | package-name: kube-probe 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /tmp 2 | 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # Bower dependency directory (https://bower.io/) 29 | bower_components 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (http://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # Typescript v1 declaration files 42 | typings/ 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional eslint cache 48 | .eslintcache 49 | 50 | # Optional REPL history 51 | .node_repl_history 52 | 53 | # Output of 'npm pack' 54 | *.tgz 55 | 56 | # Yarn Integrity file 57 | .yarn-integrity 58 | 59 | # dotenv environment variables file 60 | .env 61 | 62 | # System Files 63 | .DS_Store 64 | Thumbs.db 65 | 66 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [1.0.3](https://github.com/nodeshift/kube-probe/compare/v1.0.2...v1.0.3) (2021-07-28) 6 | 7 | 8 | ### Bug Fixes 9 | 10 | * upgrade eslint from 7.15.0 to 7.16.0 ([#137](https://github.com/nodeshift/kube-probe/issues/137)) ([3d328ff](https://github.com/nodeshift/kube-probe/commit/3d328ff5e36c5a0222f2d0a576f45505d4e69761)) 11 | * upgrade eslint from 7.16.0 to 7.17.0 ([#141](https://github.com/nodeshift/kube-probe/issues/141)) ([84ff6a6](https://github.com/nodeshift/kube-probe/commit/84ff6a681b7e68709d88ef713f6c35177da8c268)) 12 | * upgrade eslint from 7.17.0 to 7.19.0 ([#144](https://github.com/nodeshift/kube-probe/issues/144)) ([f22980d](https://github.com/nodeshift/kube-probe/commit/f22980d5a8b7fc0023eaa81bb2efc99c2f478e87)) 13 | * upgrade eslint from 7.19.0 to 7.20.0 ([#145](https://github.com/nodeshift/kube-probe/issues/145)) ([4a2a83f](https://github.com/nodeshift/kube-probe/commit/4a2a83fdeb6cc661e35e3dff69ce680f07f0e965)) 14 | * upgrade eslint-plugin-promise from 4.2.1 to 4.3.1 ([#143](https://github.com/nodeshift/kube-probe/issues/143)) ([bef0d8c](https://github.com/nodeshift/kube-probe/commit/bef0d8c66db9176a5c5a38bfb23efdd0890aba7d)) 15 | * upgrade standard-version from 9.0.0 to 9.1.0 ([#140](https://github.com/nodeshift/kube-probe/issues/140)) ([985b9cd](https://github.com/nodeshift/kube-probe/commit/985b9cd40b3714983c54fd6a4064f431bfc6d778)) 16 | * upgrade standard-version from 9.1.0 to 9.1.1 ([#146](https://github.com/nodeshift/kube-probe/issues/146)) ([534efdc](https://github.com/nodeshift/kube-probe/commit/534efdc209e0a613311defcb01168841bd193656)) 17 | * upgrade tape from 5.0.1 to 5.1.0 ([#139](https://github.com/nodeshift/kube-probe/issues/139)) ([011629c](https://github.com/nodeshift/kube-probe/commit/011629c5f025a12e525563540ad3ae37c4c51513)) 18 | * upgrade tape from 5.1.0 to 5.1.1 ([#142](https://github.com/nodeshift/kube-probe/issues/142)) ([25c1a98](https://github.com/nodeshift/kube-probe/commit/25c1a98ae883599ab38fa9ff62e34876b469945a)) 19 | * upgrade tape from 5.1.1 to 5.2.0 ([#147](https://github.com/nodeshift/kube-probe/issues/147)) ([f934b39](https://github.com/nodeshift/kube-probe/commit/f934b39aad705e9af5eb103fca4ded4991c743f0)) 20 | 21 | ### [1.0.2](https://www.github.com/nodeshift/kube-probe/compare/v1.0.1...v1.0.2) (2021-01-04) 22 | 23 | 24 | ### Bug Fixes 25 | 26 | * upgrade eslint from 7.11.0 to 7.12.0 ([#129](https://www.github.com/nodeshift/kube-probe/issues/129)) ([2c99fd5](https://www.github.com/nodeshift/kube-probe/commit/2c99fd5cccd3eda2c257100c92c0413f422b834c)) 27 | * upgrade eslint from 7.12.0 to 7.12.1 ([#131](https://www.github.com/nodeshift/kube-probe/issues/131)) ([a92a8ac](https://www.github.com/nodeshift/kube-probe/commit/a92a8aca8f59965af4f87d204462af61b1ad3743)) 28 | * upgrade eslint from 7.12.1 to 7.13.0 ([#132](https://www.github.com/nodeshift/kube-probe/issues/132)) ([8b3a586](https://www.github.com/nodeshift/kube-probe/commit/8b3a5865bab2403bc635ccd3259147c25328080c)) 29 | * upgrade eslint from 7.13.0 to 7.14.0 ([#135](https://www.github.com/nodeshift/kube-probe/issues/135)) ([213f79b](https://www.github.com/nodeshift/kube-probe/commit/213f79b600d421d98a6fddb5fc5bd18c419c8269)) 30 | * upgrade eslint from 7.14.0 to 7.15.0 ([#136](https://www.github.com/nodeshift/kube-probe/issues/136)) ([7141be0](https://www.github.com/nodeshift/kube-probe/commit/7141be0e87954811e2f971055d3ba4147825cc82)) 31 | * upgrade eslint-plugin-standard from 4.0.2 to 4.1.0 ([#133](https://www.github.com/nodeshift/kube-probe/issues/133)) ([4a0b35d](https://www.github.com/nodeshift/kube-probe/commit/4a0b35d9203a5f0e019aa94a6ba5c031627b09f3)) 32 | 33 | ### [1.0.1](https://www.github.com/nodeshift/kube-probe/compare/v1.0.0...v1.0.1) (2020-10-14) 34 | 35 | 36 | ### Bug Fixes 37 | 38 | * upgrade xo from 0.33.0 to 0.33.1 ([#122](https://www.github.com/nodeshift/kube-probe/issues/122)) ([1fbd76e](https://www.github.com/nodeshift/kube-probe/commit/1fbd76ebcf806b34c1c90ad4fb622ce8c9e9a03c)) 39 | 40 | ## [1.0.0](https://github.com/nodeshift/kube-probe/compare/v0.5.0...v1.0.0) (2020-09-10) 41 | 42 | 43 | ### Bug Fixes 44 | 45 | * [Snyk] Upgrade xo from 0.28.1 to 0.28.2 ([#96](https://github.com/nodeshift/kube-probe/issues/96)) ([58b97a0](https://github.com/nodeshift/kube-probe/commit/58b97a0370fc02ca61faa785d40eeb203488c757)) 46 | * upgrade standard-version from 8.0.1 to 8.0.2 ([#117](https://github.com/nodeshift/kube-probe/issues/117)) ([39a1d98](https://github.com/nodeshift/kube-probe/commit/39a1d989bfa5138347dfa01b5ab59e79ad82d1b7)) 47 | * upgrade xo from 0.32.1 to 0.33.0 ([#119](https://github.com/nodeshift/kube-probe/issues/119)) ([2d6352b](https://github.com/nodeshift/kube-probe/commit/2d6352b70b140818694bc77dac9f7fa42891f139)) 48 | 49 | ## [0.5.0](https://github.com/nodeshift/kube-probe/compare/v0.4.0...v0.5.0) (2020-04-23) 50 | 51 | 52 | ### Features 53 | 54 | * Option to bypass overload protection when needed ([#93](https://github.com/nodeshift/kube-probe/issues/93)) ([93ee8e5](https://github.com/nodeshift/kube-probe/commit/93ee8e55724d1987f873fcf93022d5eabc520369)), closes [#89](https://github.com/nodeshift/kube-probe/issues/89) 55 | 56 | 57 | ### Bug Fixes 58 | 59 | * upgrade xo from 0.28.0 to 0.28.1 ([#92](https://github.com/nodeshift/kube-probe/issues/92)) ([c5f663d](https://github.com/nodeshift/kube-probe/commit/c5f663d115feff636d8a275fa33dba5400d1b317)) 60 | 61 | ## [0.4.0](https://github.com/nodeshift/kube-probe/compare/v0.3.3...v0.4.0) (2020-02-07) 62 | 63 | 64 | ### chore 65 | 66 | * **package:** Engine parameter targets node 10+ ([#83](https://github.com/nodeshift/kube-probe/issues/83)) ([04175c2](https://github.com/nodeshift/kube-probe/commit/04175c2)) 67 | 68 | 69 | ### BREAKING CHANGES 70 | 71 | * **package:** removal of Node 8 support 72 | 73 | 74 | 75 | ### [0.3.3](https://github.com/nodeshift/kube-probe/compare/v0.3.2...v0.3.3) (2020-01-23) 76 | 77 | 78 | ### Bug Fixes 79 | 80 | * **package:** update overload-protection to version 1.2.0 ([c99b658](https://github.com/nodeshift/kube-probe/commit/c99b658)) 81 | 82 | 83 | ### Build System 84 | 85 | * using LTS and 10x also cleaning up the config ([58026c1](https://github.com/nodeshift/kube-probe/commit/58026c1)) 86 | 87 | 88 | 89 | ## [0.3.2](https://github.com/nodeshift/kube-probe/compare/v0.3.1...v0.3.2) (2019-02-25) 90 | 91 | 92 | 93 | 94 | ## [0.3.1](https://github.com/nodeshift/kube-probe/compare/v0.3.0...v0.3.1) (2018-02-12) 95 | 96 | 97 | ### Bug Fixes 98 | 99 | * response should include content type header ([#31](https://github.com/nodeshift/kube-probe/issues/31)) ([d0dce9d](https://github.com/nodeshift/kube-probe/commit/d0dce9d)) 100 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at nodeshift@redhat.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | This module is deprecated. 3 | 4 | [![Build Status](https://travis-ci.org/nodeshift/kube-probe.svg?branch=main)](https://travis-ci.org/nodeshift/kube-probe) [![Coverage Status](https://coveralls.io/repos/github/nodeshift/kube-probe/badge.svg?branch=main)](https://coveralls.io/github/nodeshift/kube-probe?branch=main) 5 | [![Greenkeeper badge](https://badges.greenkeeper.io/nodeshift/kube-probe.svg)](https://greenkeeper.io/) 6 | Connect middleware that sets up generic liveness and readiness probes for OpenShift/Kubernetes 7 | 8 | Example Usage: 9 | 10 | const express = require('express'); 11 | const app = express(); 12 | 13 | const probe = require('kube-probe'); 14 | 15 | probe(app); 16 | 17 | 18 | This will add 2 `GET` endpoints `/api/health/liveness` and `/api/health/readiness` 19 | that will return a `200 OK` response. This module uses `overload-protection` to identify 20 | when a process may be overloaded, and will return `HTTP 503 Service Unavailable` 21 | if the service becomes too heavily loaded. Configuration of the `protection-config` module 22 | may be passed as `options.protectionConfig`. 23 | 24 | See: https://github.com/davidmarkclements/overload-protection/ 25 | 26 | #### Parameters 27 | 28 | * app - an instance of a connect-based framework (e.g. express.js) - required 29 | 30 | * options - optional 31 | * options.readinessURL - string - url where the readiness probe is located 32 | * options.livenessURL - string - url where the livenessURL probe is located 33 | * options.readinessCallback - function - function to call when the readiness probe is triggered 34 | * options.livenessCallback - function - function to call when the liveness probe is triggered 35 | * options.bypassProtection - boolean - kube-probe will bypass protection (defaults to false) 36 | * options.protectionConfig - object - options passed direction to `overload-protection` 37 | 38 | #### Environment Variables 39 | 40 | * KUBE_PROBE_BYPASS_PROTECTION - boolean - kube-probe will bypass protection 41 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const protection = require('overload-protection'); 4 | 5 | const READINESS_URL = '/api/health/readiness'; 6 | const LIVENESS_URL = '/api/health/liveness'; 7 | 8 | function defaultResponse (request, response) { 9 | response.setHeader('Content-Type', 'text/html'); 10 | return response.end('OK'); 11 | } 12 | 13 | /* 14 | @param {object} app - an instance of a connect.js web framework 15 | @param {object} [options] 16 | @param {string} [options.readinessURL] - url where the readiness probe is located 17 | @param {string} [options.livenessURL] - url where the liveness probe is located 18 | @param {function} [options.readinessCallback] - function to call when the readiness probe is triggered 19 | @param {function} [options.livenessCallback] - function to call when the liveness probe is triggered 20 | @param {object} [options.protectionConfig] - options passed directly to 'overload-protection' module 21 | */ 22 | module.exports = function (app, options = {}) { 23 | const protectCfg = { 24 | production: process.env.NODE_ENV === 'production', 25 | maxHeapUsedBytes: 0, // Maximum heap used threshold (0 to disable) [default 0] 26 | maxRssBytes: 0, // Maximum rss size threshold (0 to disable) [default 0] 27 | ...options.protectionConfig 28 | }; 29 | const readiness = options.readinessURL || READINESS_URL; 30 | const liveness = options.livenessURL || LIVENESS_URL; 31 | 32 | // Check if kube-probe's protection option is disabled 33 | const bypassProtection = options.bypassProtection || process.env.KUBE_PROBE_BYPASS_PROTECTION === 'true'; 34 | 35 | if (!bypassProtection) { 36 | const protect = protection('http', protectCfg); 37 | app.use(readiness, protect); 38 | app.use(liveness, protect); 39 | } 40 | 41 | app.use(readiness, options.readinessCallback || defaultResponse); 42 | app.use(liveness, options.livenessCallback || defaultResponse); 43 | }; 44 | -------------------------------------------------------------------------------- /package-support.json: -------------------------------------------------------------------------------- 1 | { 2 | "versions": [ 3 | { 4 | "version": "*", 5 | "target": { 6 | "node": "lts" 7 | }, 8 | "response": { 9 | "type": "regular-7" 10 | }, 11 | "backing": { 12 | "company": "true" 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kube-probe", 3 | "version": "1.0.3", 4 | "description": "connect.js middleware that sets up generic liveness and readiness probes for Openshift/Kubernetes", 5 | "author": "Red Hat, Inc.", 6 | "license": "Apache-2.0", 7 | "scripts": { 8 | "test": "tape test/*.js | tap-spec", 9 | "lint": "eslint test/*-test.js index.js", 10 | "coverage": "nyc npm test", 11 | "coverage:html": "nyc npm test && nyc report --reporter=html", 12 | "coveralls": "nyc npm test && nyc report && if [ $COVERALLS_REPO_TOKEN'' != '' ] ; then nyc report --reporter=text-lcov | coveralls; fi", 13 | "ci": "npm run lint && npm run coveralls", 14 | "release": "standard-version" 15 | }, 16 | "files": [ 17 | "index.js" 18 | ], 19 | "engines": { 20 | "node": "^16 || ^14 || ^12" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git://github.com/nodeshift/kube-probe.git" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/nodeshift/kube-probe/issues" 28 | }, 29 | "keywords": [ 30 | "connect", 31 | "connect.js", 32 | "express", 33 | "express.js", 34 | "middleware", 35 | "kubernetes", 36 | "openshift", 37 | "liveness", 38 | "readiness" 39 | ], 40 | "homepage": "https://github.com/nodeshift/kube-probe", 41 | "devDependencies": { 42 | "connect": "~3.7.0", 43 | "coveralls": "^3.1.0", 44 | "eslint": "~7.20.0", 45 | "eslint-config-semistandard": "~15.0.1", 46 | "eslint-config-standard": "~14.1.1", 47 | "eslint-plugin-import": "~2.22.1", 48 | "eslint-plugin-node": "~11.1.0", 49 | "eslint-plugin-promise": "~4.3.1", 50 | "eslint-plugin-standard": "~4.1.0", 51 | "nyc": "~15.1.0", 52 | "standard-version": "^9.1.1", 53 | "supertest": "^4.0.0", 54 | "tap-spec": "~5.0.0", 55 | "tape": "~5.2.0" 56 | }, 57 | "dependencies": { 58 | "overload-protection": "~1.2.0" 59 | }, 60 | "support": true 61 | } 62 | -------------------------------------------------------------------------------- /test/kube-probe-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const test = require('tape'); 4 | const supertest = require('supertest'); 5 | 6 | const connect = require('connect'); 7 | const probe = require('..'); 8 | 9 | test('test defaults for readiness', async t => { 10 | const app = connect(); 11 | probe(app); 12 | 13 | const response = await supertest(app).get('/api/health/readiness').expect(200); 14 | 15 | t.equal(response.text, 'OK', 'should just return OK for the text'); 16 | t.end(); 17 | }); 18 | 19 | test('test defaults for liveness', async t => { 20 | const app = connect(); 21 | probe(app); 22 | 23 | const response = await supertest(app).get('/api/health/liveness').expect(200); 24 | 25 | t.equal(response.text, 'OK', 'should just return OK for the text'); 26 | t.end(); 27 | }); 28 | 29 | test('test different url and callback for readiness', async t => { 30 | const app = connect(); 31 | const options = { 32 | readinessURL: '/different/api/ready', 33 | readinessCallback: (request, response) => { 34 | return response.end('Different Callback'); 35 | } 36 | }; 37 | 38 | probe(app, options); 39 | 40 | const response = await supertest(app).get('/different/api/ready').expect(200); 41 | 42 | t.equal(response.text, 'Different Callback', 'Different Callback shold be the new text'); 43 | t.end(); 44 | }); 45 | 46 | test('test different url and callback for liveness', async t => { 47 | const app = connect(); 48 | const options = { 49 | livenessURL: '/different/api/ready', 50 | livenessCallback: (request, response) => { 51 | return response.end('Different Callback'); 52 | } 53 | }; 54 | 55 | probe(app, options); 56 | 57 | const response = await supertest(app).get('/different/api/ready').expect(200); 58 | 59 | t.equal(response.text, 'Different Callback', 'Different Callback should be the new text'); 60 | t.end(); 61 | }); 62 | 63 | test('default content type for readiness endpoint', async t => { 64 | t.plan(1); 65 | const app = connect(); 66 | probe(app); 67 | 68 | const response = await supertest(app) 69 | .get('/api/health/readiness') 70 | .expect(200) 71 | .expect('Content-Type', /text\/html/); 72 | 73 | t.strictEqual(response.text, 'OK', 'expected response'); 74 | t.end(); 75 | }); 76 | 77 | test('default content type for liveness endpoint', async t => { 78 | t.plan(1); 79 | const app = connect(); 80 | probe(app); 81 | 82 | const response = await supertest(app) 83 | .get('/api/health/liveness') 84 | .expect(200) 85 | .expect('Content-Type', /text\/html/); 86 | 87 | t.strictEqual(response.text, 'OK', 'expected response'); 88 | t.end(); 89 | }); 90 | 91 | test('custom content type for liveness endpoint', async t => { 92 | t.plan(1); 93 | const app = connect(); 94 | probe(app, { 95 | livenessCallback: (request, response) => { 96 | response.setHeader('Content-Type', 'application/json'); 97 | response.end(JSON.stringify({ status: 'OK' })); 98 | } 99 | }); 100 | 101 | const response = await supertest(app) 102 | .get('/api/health/liveness') 103 | .expect(200) 104 | .expect('Content-Type', /json/); 105 | 106 | t.strictEqual(response.body.status, 'OK', 'expected response'); 107 | t.end(); 108 | }); 109 | 110 | test('bypass kube-probe protection', async t => { 111 | t.plan(2); 112 | const app = connect(); 113 | 114 | probe(app, { 115 | bypassProtection: true 116 | }); 117 | 118 | const readinessResponse = await supertest(app) 119 | .get('/api/health/readiness') 120 | .expect(200) 121 | .expect('Content-Type', /text\/html/); 122 | 123 | const livenessResponse = await supertest(app) 124 | .get('/api/health/liveness') 125 | .expect(200) 126 | .expect('Content-Type', /text\/html/); 127 | 128 | t.strictEqual(readinessResponse.text, 'OK', 'Expected readiness response'); 129 | t.strictEqual(livenessResponse.text, 'OK', 'Expected liveness response'); 130 | t.end(); 131 | }); 132 | --------------------------------------------------------------------------------