Behind the scene Pipeline is using Helm to deployt applications to Kubernetes. In order to interact with Helm (basically Tiller) you have to use the CLI or write gRPC code and talk directly with Tiller. For the Pipeline PaaS, and our end users we needed to build a REST based API to speak with the Tiller server. This implementation resides inside the helm package and it's exposed using a Gin server by Pipeline itself.
To flow of deploying a Helm chart to Kubernetes will look like this:
Now lets see how can you access and deploy a Kubernetes application using the REST endpoints with curl
. The first thing you might need is a kubeconfig
if you'd like to validate the deployment using the Helm CLI as well. Beside provisioning Kubernetes clusters in the cloud, Pipeline can connect to existing clusters, disregarding whether it's cloud or on-prem based.
In order to get the kubeconfig
you can do the following REST call:
curl --request GET \
--url 'http://{{url}}/api/v1/clusters/{{cluster_id}}/config' \
--header 'Authorization: Basic YWRtaW46eWFyZDIy' \
--header 'Content-Type: application/json'
Now you can add a deployment with the following REST call:
curl --request POST \
--url 'http://{{url}}/api/v1/clusters/{{cluster_id}}/deployments' \
--header 'Authorization: Basic YWRtaW46eWFyZDIy' \
--header 'Content-Type: application/json' \
--data '{"name": "spark-shuffle"}'
Once the deployment is posted you can check the status with this HEAD call:
curl --request HEAD \
--url 'http://{{url}}/api/v1/clusters/{{cluster_id}}/deployments/{{deployment_name}}' \
--header 'Authorization: Basic YWRtaW46eWFyZDIy' \
--header 'Content-Type: application/json'
Deployments can be upgraded with the following PUT call:
curl --request PUT \
--url 'http://{{url}}/api/v1/clusters/{{cluster_id}}/deployments/{{deployment_name}}' \
--header 'Authorization: Basic YWRtaW46eWFyZDIy' \
--header 'Content-Type: application/x-www-form-urlencoded'
Finally a deployment can be deleted as well:
curl --request DELETE \
--url 'http://{{url}}/api/v1/clusters/{{cluster_id}}/deployments/{{deployment_name}}' \
--header 'Authorization: Basic YWRtaW46eWFyZDIy' \
--header 'Content-Type: application/x-www-form-urlencoded'
We use these REST API calls as well and have collected them in a Postman collection:
Alternatively you can access the same collection online as well following this link.
We have also created a Docker image that can be used to run the collection in a containerized manner. Build the image from our GitHub repository or pull it from the Docker Hub.