Table of Contents | ||
---|---|---|
|
Definitions API
...
K8splugin artifacts start in the form of Definitions. These are nothing but Helm Charts wrapped with some metadata about the chart itself.
...
Code Block | ||
---|---|---|
| ||
> cd vagrant/tests/vnfs/testrb/helm > find vault-consul-dev vault-consul-dev vault-consul-dev/Chart.yaml vault-consul-dev/values.yaml vault-consul-dev/templates vault-consul-dev/templates/service.yaml vault-consul-dev/templates/deployment.yaml vault-consul-dev/charts vault-consul-dev/charts/common/values.yaml vault-consul-dev/charts/common/templates/_service.tpl vault-consul-dev/charts/common/templates/_repository.tpl vault-consul-dev/charts/common/templates/_name.tpl vault-consul-dev/charts/common/templates/_namespace.tpl vault-consul-dev/charts/common/templates vault-consul-dev/charts/common/Chart.yaml vault-consul-dev/charts/common #Create a tar.gz for upload > tar -cf vault-consul-dev.tar vault-consul-dev > gzip vault-consul-dev.tar |
Managing Definitions
The following curl commands can be used to upload a definition and the helm chart for that definition.
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "rb-name": "test-rbdef", "rb-version": "v1", "chart-name": "vault-consul-dev", //optional field. chart-name will be detected if this is not provided. "description": "testing resource bundle definition api", "labels": { } } |
Command to create (POST) Definition:
Code Block | ||
---|---|---|
| ||
curl -i -d @create_rbdefinition.json -X POST http://localhost:9015/v1/rb/definition |
Command to UPLOAD artifact for Definition Created:
Code Block | ||
---|---|---|
| ||
curl -i --data-binary @vault-consul-dev.tar.gz -X POST http://localhost:9015/v1/rb/definition/test-rbdef/v1/content |
Command to GET Definitions:
Code Block | ||
---|---|---|
| ||
# Get all Definitions curl -i http://localhost:9015/v1/rb/definition/ # Get one Definition curl -i http://localhost:9015/v1/rb/definition/test-rbdef/v1 |
Command to DELETE Definitions:
Code Block | ||
---|---|---|
| ||
#Delete all versions of definition curl -i -X DELETE http://localhost:9015/v1/rb/definition/test-rbdef #Delete a particular version of definition curl -i -X DELETE http://localhost:9015/v1/rb/definition/test-rbdef/v1 |
Profiles API
...
Once the Definitions are created, we are ready to create some profiles so that we can customize that definition and instantiate it in Kubernetes.
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "rb-name": "test-rbdef", "rb-version": "v1", "profile-name": "p1", "release-name": "r1", //If release-name is not provided, profile-name will be used "namespace": "testnamespace1", "kubernetes-version": "1.12.3" } |
Command to create (POST) Profile
Code Block | ||
---|---|---|
| ||
curl -i -d @create_rbprofile.json -X POST http://localhost:9015/v1/rb/definition/test-rbdef/v1/profile |
Command to UPLOAD artifact for Profile
Code Block | ||
---|---|---|
| ||
curl -i --data-binary @profile.tar.gz -X POST http://localhost:9015/v1/rb/definition/test-rbdef/v1/profile/p1/content |
Command to GET Profiles
Code Block | ||
---|---|---|
| ||
# Get all Profiles curl -i http://localhost:9015/v1/rb/definition/test-rbdef/v1/profile # Get one Profile curl -i http://localhost:9015/v1/rb/definition/test-rbdef/v1/profile/p1 |
Command to DELETE Profile
Code Block | ||
---|---|---|
| ||
curl -i -X DELETE http://localhost:9015/v1/rb/definition/test-rbdef/v1/profile/p1 |
Instantiation API
...
Instantiate the created Profile via the following REST api
...
Code Block | ||
---|---|---|
| ||
{ "id": "ZKMTSaxv", "rb-name": "mongo", "rb-version": "v1", "profile-name": "profile1", "cloud-region": "kud", "namespace": "testns", "resources": [ { "GVK": { "Group": "", "Version": "v1", "Kind": "Service" }, "Name": "mongo" }, { "GVK": { "Group": "", "Version": "v1", "Kind": "Service" }, "Name": "mongo-read" }, { "GVK": { "Group": "apps", "Version": "v1beta1", "Kind": "StatefulSet" }, "Name": "profile1-mongo" } ] } |
Delete Instantiated Kubernetes resources
The id field from the returned JSON can be used to DELETE the resources created in the previous step
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl -X DELETE http://localhost:9015/v1/instance/ZKMTSaxv |
GET Instantiated Kubernetes resources
The id field from the returned JSON can be used to GET the resources created in the previous step
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl -X GET http://localhost:9015/v1/instance/ZKMTSaxv |
Configuration API
...
Day 2 Configurations for applications are applied using K8S kinds (typically CRDs) implemented by application specific operators. For a given application, type of configuration is similar (but not the values), therefore configuration templates are created by applications. These templates are for each application and are expected to be created even before Day 2 configuration is applied. Once the templates are created, configuration can be applied by choosing the right template. Day 2 configuration is applied by users as and when new configuration is required. As a user, he/she should select the template and supply values to apply new configuration.
Configuration Template API
...
Command to POST (create) Template:
|
...
1 |
|
Command to UPLOAD Template:
|
Command to GET Templates:
|
Command to DELETE Templates:
|
Example
Example Contents of Tar File
|
Configuration Values API
...
In Day 2 apply configuration API each instance of configuration is identified by rb_name, rb_version and profile_name. The body of the API contains set of parameter and value list.
Command to POST (create) Configuration Values
|
...
|
Command to DELETE Configuration Values
|
Command to PUT (Modify) Configuration Values
|
...
|
Command to TAG configuration Values
This will add the tag name to the current config version
...
With the following JSON content (values.json )
|
Command to ROLLBACK configuration Values
Rollbacks configuration to a config version or a tag.
...
|
Reachability/Connectivity Info API
...
API to support Reachability for Kubernetes Cloud
Command to POST Connectivity Info
Code Block | ||
---|---|---|
| ||
{ “cloud-region” : “<name>”, // Must be unique across “cloud-owner” : “<owner>”, “other-connectivity-list” : { //Extendible list of name value pairs “connectivity-records” : [ { “connectivity-record-name” : “<name>”, // example: OVN “FQDN-or-ip” : “<fqdn>”, “ca-cert-to-verify-server” : “<contents of CA certificate to validate the OVN server>”, “ssl-initiator” : “<true/false”>, “user-name”: “<user name>”, //valid if ssl-initator is false “password” : “<password>”, // valid if ssl-initiator is false “private-key” : “<contents of private key in PEM>”, // valid if ssl-initiator is true “cert-to-present” : “<contents of certificate to present to server>” , //valid if ssl-initiator is true }, ] } } |
...
|
Command to GET Connectivity Info
|
Command to DELETE Connectivity Info
|
Command to UPDATE/PUT Connectivity Info
|
...