Last active
August 12, 2020 17:57
-
-
Save miraculixx/de62909719c26adf1391f262a725e022 to your computer and use it in GitHub Desktop.
create a locally hosted helm repository to use in dependencies, serve using python http.server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def helmserver(dirname, hostname='localhost', port=8000): | |
| # runs a helmserver (http server serving index.yaml and helm packages) | |
| # returns a multiprocessing.Process, call .terminate() to stop it | |
| # Usage: | |
| # helmserver('/path/to/dependencies', hostname, port) | |
| def httpdrunner(dirname, bind, port): | |
| # this adopted from http.server module | |
| import os | |
| server_address = (bind, port) | |
| os.chdir(dirname) | |
| httpd = HTTPServer(server_address, SimpleHTTPRequestHandler) | |
| httpd.serve_forever() | |
| p = Process(target=httpdrunner, args=(dirname, hostname, port)) | |
| p.start() | |
| sleep(1) # give it some time to start | |
| return p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # put this in ./dependencies | |
| # add external dependencies that cannot be added as a repository | |
| # then add this directory as a file | |
| # for every external chart, script the download as shown in localpath example, add to build target dependencies | |
| # use $ make build to download all dependencies, build packages and local repo index | |
| localpath: | |
| mkdir -p staging | |
| curl https://codeload.github.com/rancher/local-path-provisioner/tar.gz/v0.0.15 -o staging/localpath.tgz | |
| cd staging && tar -xzf localpath.tgz | |
| cd staging/local-path-provisioner*/deploy/chart && helm package . | |
| mv staging/local-path-provisioner*/deploy/chart/*.tgz . | |
| rm -rf staging | |
| build: localpath | |
| helm repo index . | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why?
Create a local helm repository of your externally hosted packages, e.g.
Specify in your chart dependencies:
Then serve your packages using before calling helm dependency update
If you have some python program that does all the helm'ing for you, use the above to run the http.server in a process instead of separately