Coder Social home page Coder Social logo

microsoft / helm-web-api Goto Github PK

View Code? Open in Web Editor NEW
102.0 15.0 39.0 55 KB

Enabling applications in your Kubernetes cluster to programmatically install helm charts and expose them through a single public facing IP

License: MIT License

Dockerfile 4.03% JavaScript 92.40% Smarty 3.57%
kubernetes deployment http helm helm-charts tiller

helm-web-api's Introduction

On-demand micro-services deployment for Kubernetes via HTTP endpoints

Enabling applications in your Kubernetes cluster to programmatically install helm charts and expose them through a single public facing IP

The solution exposes web endpoint which provides the Helm functionalities of Install, Delete and Upgrade charts, as well as automatically configure the ingress controller to expose them to the internet all within a single public IP. The solution we propose consists of two parts, both as web servers:

Helm charts deployer: let developers install, delete and upgrade helm charts from inside the cluster, using a simple REST API.

Ingress rule setter: expose installed helm charts to the internet, via a single IP.

When to use this solution

  • Automating deployments in the cluster.
  • Programmatically managing the cluster from the code.

Requirements

  • Kubernetes 1.9+ with RBAC enabled.
  • Helm

Installation

  1. Install Helm with RBAC

    Make sure to grant tiller sufficient permissions to run helm inside the cluster, and install the app Chart. The example below will configure helm and tiller to work with the chart's default values. Execute the following lines if using the default chart values:

    kubectl apply -f https://raw.githubusercontent.com/Microsoft/k8s-On-demand-micro-services-deployment/master/rbac-example/tiller.yaml
    
    helm init --service-account tiller
  2. Clone the repository

    docker build -t registryname/on-demand-micro-services-deployment-k8s .
    docker push registryname/on-demand-micro-services-deployment-k8s
    • Edit the values.yaml file to point to the newly published image and registry
  3. Install the app chart

    helm install chart/on-demand-micro-services-deployment --name on-demand-micro-services-deployment --set rbac.create=true
  4. Call on-demand-micro-services-deployment-k8s and install nginx-ingress-controller, to expose other helm charts via a single public IP:

    curl -d '{"chartName":"stable/nginx-ingress", "releaseName":"myingress"}' -H "Content-Type: application/json" -X POST http://<on-demand-micro-services-deployment-k8s-ip>:4000/install
  5. Label each ingress controller. This is required, since this is our way of telling the system, which IPs to use:

    kubectl label service myingress-nginx-ingress-controller appingress=ingress

Now you have a working API awaiting HTTP requests.

Using the API

If you used the default settings, the API will be accessible internally at: http://on-demand-micro-services-deployment-k8s.default.svc.cluster.local:4000

Here is a quick node.js snippet that makes use of the API to install RabbitMQ with default settings.

Note: any chart will be suitable, RabbitMQ is just a specific example:

let chart = { name: "stable/rabbitmq", servicePort: 5672 };

// perform helm install
var installResponse = await requestPostAsync(Paths.HelmInstall, { form: { chartName: "" } });

// create a rule to expose the new service expternally
var ingressResponse = await requestGetAsync(Paths.SetIngressRule, { serviceName: installResponse.serviceName, servicePort: chart.servicePort });

return `Your new service: ${ingressResponse.releaseName}, is publicly accessible on ${ingressResponse.ip}:${ingressResponse.port}`;

For example, installig a chart from a private repository is done by sending the following json to the exposed endpoint:

{
  "chartName":"sampleApp",
  "releaseName":"sampleApp1",
  "privateChartsRepo": "https://raw.githubusercontent.com/username/helm_repo/master/index.yaml"
}

In most cases the deployed chart will be a private one, which makes sense to be deployed on demand, for example a service which adds support for a new format of requests. However, public charts are fully supported (remove the 'privateChartsRepo' key-value).

API Documentation

Check out the API documentation here

How it works

Feel free to read the extended summary here

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

helm-web-api's People

Contributors

dattachandan avatar eladiw avatar microsoftopensource avatar msftgits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

helm-web-api's Issues

Helm 3 Support

Does this work with helm 3? I noticed in the instructions it lists tiller, which is no longer used with helm 3.

Custom values not working

Custom values provided are ignored, because the check on whether values are set is inverted.


I think the this keyword should be omitted, because it is in a static method and I am not sure what it refers to here.

A follow up issue is that the sample code uses a url-encoded form to send the POST data, and the body parser does not seem to work well as it is. Using JSON encoding in the POST solves the issue.

"Error: Not Found" | when trying to post

Getting the below error when trying to post any releases or when trying to access the endpoint through the browser (helm 2.14.3 & kubectl 1.16.0):

Error: Not Found
at /usr/src/index.js:140:15
at Layer.handle [as handle_request] (/usr/src/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/src/node_modules/express/lib/router/index.js:317:13)
at /usr/src/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/usr/src/node_modules/express/lib/router/index.js:335:12)
at next (/usr/src/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/usr/src/node_modules/body-parser/lib/types/urlencoded.js:91:7)
at Layer.handle [as handle_request] (/usr/src/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/src/node_modules/express/lib/router/index.js:317:13)
at /usr/src/node_modules/express/lib/router/index.js:284:7

privateChartsRepo functionality if not working

Steps to Replicate:

curl -d '{"chartName":"chart-name", "releaseName":"chart-name-1", "privateChartsRepo":"https://<gs-bucket-name-helm-repo>.storage.googleapis.com/index.yaml"}' -H "Content-Type: application/json" -X POST http://<service-endpoint>:4000/install

Expected behavior:

should return success

Actual result:

{"status":"failed","reason":"Installation failed."}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.