Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 25 Next »

Definitions API

K8splugin artifacts start in the form of Definitions. These are nothing but Helm Charts wrapped with some metadata about the chart itself.

The package can be generated using the helm package command.

A Sample Helm Chart can be viewed in this patch: https://gerrit.onap.org/r/#/c/76371/

The contents for that chart are below.

> 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.

With the following JSON content

{
    "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:

curl -i -d @create_rbdefinition.json -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition

Command to UPLOAD artifact for Definition Created:

curl -i --data-binary @vault-consul-dev.tar.gz -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/test-rbdef/v1/content

Command to GET  Definitions:

# Get all Definitions
curl -i http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition

# Get one Definition
curl -i http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/test-rbdef/v1

Command to DELETE Definitions:

#Delete all versions of definition
curl -i -X DELETE http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/test-rbdef
#Delete a particular version of definition
curl -i -X DELETE http://NODE_IP:30280/api/multicloud-k8s/v1/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.

A profile contains the following:

  1. manifest.yaml
    1. Contains the details for the profile and everything contained within
  2. A HELM values override yaml file.
    1. It can have any name as long as it matches the corresponding entry in the manifest.yaml
  3. Any number of files organized in a folder structure
    1. All these files should have a corresponding entry in manifest.yaml file

Sample Profile is described in the above patch

Create the profile artifact

Creating a Profile Artifact
> cd vagrant/tests/vnfs/testrb/helm/profile
> find .
manifest.yaml
override_values.yaml
testfol
testfol/subdir
testfol/subdir/deployment.yaml

#Create profile tar.gz
> cd profile
> tar -cf profile.tar *
> gzip profile.tar
> mv profile.tar.gz ../

Manifest file contains following

manifest.yaml
---
version: v1
type:
  values: "values_override.yaml"
  configresource:
    - filepath: testfol/subdir/deployment.yaml
      chartpath: vault-consul-dev/templates/deployment.yaml


With this information, we are ready to upload the profile with the following JSON data

Profile JSON Body
{
	"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

#Replace NODE_IP:30280/api/multicloud-k8s/v1 with NODE_PORT:30280/api/multicloud-k8s/v1 if you are connec
curl -i -d @create_rbprofile.json -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/test-rbdef/v1/profile

Command to UPLOAD artifact for Profile

curl -i --data-binary @profile.tar.gz -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/test-rbdef/v1/profile/p1/content

Command to GET Profiles

# Get all Profiles
curl -i http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/test-rbdef/v1/profile

# Get one Profile
curl -i http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/test-rbdef/v1/profile/p1

Command to DELETE Profile

curl -i -X DELETE http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/test-rbdef/v1/profile/p1

Instantiation API

Instantiate the created Profile via the following REST api

Using the following JSON:

{
    "cloud-region": "krd",
    "profile-name": "p1",
	"rb-name":"test-rbdef",
	"rb-version":"v1",
    "labels": {
	}
}

NOTE: Make sure that the namespace is already created before instantiation.
See MULTICLOUD-462 - Getting issue details... STATUS for more details.

Instantiate the profile with the ID provided above

Command to Instantiate a Profile
curl -d @create_rbinstance.json http://NODE_IP:30280/api/multicloud-k8s/v1/v1/instance

This command returns the following JSON:

{
  "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

This executes a Delete operation using the Kubernetes API.

Command to DELETE a resource
curl -X DELETE http://NODE_IP:30280/api/multicloud-k8s/v1/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

This executes a Delete operation using the Kubernetes API.

Command to GET a resource
curl -X GET http://NODE_IP:30280/api/multicloud-k8s/v1/v1/instance/ZKMTSaxv

LIST all Instantiated Kubernetes resources

The following API can be used to GET all the instances we have created.

Command to GET all resources
curl -X GET http://NODE_IP:30280/api/multicloud-k8s/v1/v1/instance

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:

curl -i -d @create_config_template.json -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/config-template

With the following JSON content (create_config_template.json )

1
2
3
4

{
    "template-name""kafka_token",
    "description""testing Kafka Day 2 config configuration"
}

Command to UPLOAD Template:

curl -i --data-binary @kafka-config.tar.gz -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/config-template/{name}/content

Command to GET  Templates:

# Get all Templates [DOES NOT WORK]
curl -i http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/config-template
 
# Get one Template
curl -i http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/config-template/{name}

Command to DELETE Templates:

curl -i -X DELETE http://NODE_IP:30280/api/multicloud-k8s/v1/rb/definition/{name}/{version}/config-template/{name}

Example 

Example Contents of Tar File 

cd demo/vnfs/DAaaS
find kafka-config
kafka-config/values.yaml
kafka-config/Chart.yaml
kafka-config/templates
kafka-config/templates/topic.yaml
 
#Create a tar.gz for upload
tar -cf kafka-config.tar kafka-config
gzip kafka-config.tar

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

curl -i -d @values.json -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/profile/{name}/config

With the following JSON content (values.json )

{
  "template-name""kafka_token",
  "config-name""kafka_token_1",
  "description":"testing Kafka Day 2 config configuration",
   "values":{
      "namespace":"kafka",
      "topic":{
         "name":"orders",
         "cluster":"my-cluster",
         "partitions":10,
         "replicas":2
      }
   }
}


This command returns the following JSON which contains config-version id.

{
   "rb-name":"kafka",
   "rb-version":"kafka-config-1",
   "profile-name":"1234567890",
   "template-name""kafka-token"
   "config-name""kafka_token_1"
   "config-version":"1"
   }
}

Command to GET Configuration Values

# Get all Values [DOES NOT WORK]
curl -i http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/profile/{name}/config
 
# Get one Value with config name
curl -i http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/profile/{name}/config/{name}

Command to DELETE Configuration Values

curl -i -X DELETE http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/profile/{name}/config/{name}

Command to PUT (Modify) Configuration Values 

curl -i -d @values.json -X PUT http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/profile/{name}/config/{name}

With the following JSON content (values.json )

{
  "template-name""kafka_token"
  "config-name""kafka_token_1"
  "description":"testing Kafka Day 2 config configuration",
   "values":{
      "namespace":"kafka",
      "topic":{
         "name":"orders",
         "cluster":"my-cluster",
         "partitions":20,
         "replicas":2
      }
   }
}


This command returns the following JSON which contains config-version.

{
   "rb-name":"kafka",
   "rb-version":"kafka-config-1",
   "profile-name":"1234567890",
   "template-name""kafka-token"
   "config-name""kafka_token_1"
   "config-version":"3"
   }
}

Command to TAG  configuration Values 

This will add the tag name to the current config version

curl -i  -d @values.json -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/profile/{name}/tagit

With the following JSON content (values.json )

{
  "tag-name""my-tag"
}


Command to ROLLBACK   configuration Values 

Rollbacks configuration to a config version or a tag. 

curl -i -d @values.json -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/rb/definition/{name}/{version}/profile/{name}/rollback

With the following JSON content (values.json )

{
  "anyOf": [
    {
      "config-version""<value>"
    },
    {
      "config-tag""<tag name>"
    }
  ]
}


Reachability/Connectivity Info API

API to support Reachability for Kubernetes Cloud

Command to POST Connectivity Info

{
	“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
			},
         ]
	}
}

This is a multipart upload and here is how you do the POST for this.

#Using a json file containing content as above;

curl -i -F "metadata=<jsonfile;type=application/json" -F file=@/home/ad_kkkamine/.kube/config -X POST http://NODE_IP:30280/api/multicloud-k8s/v1/v1/connectivity-info

Command to GET Connectivity Info

curl -i -X GET http://NODE_IP:30280/api/multicloud-k8s/v1/v1/connectivity-info/{name}

Command to DELETE Connectivity Info

curl -i -X DELETE http://NODE_IP:30280/api/multicloud-k8s/v1/v1/connectivity-info/{name}

Command to UPDATE/PUT Connectivity Info

curl -i -d @update.json -X PUT http://NODE_IP:30280/api/multicloud-k8s/v1/v1/connectivity-info/{name}

Infrastructure workload LCM API

APIs defined here conform to API defined by main multicloud broker service: https://docs.onap.org/en/dublin/submodules/multicloud/framework.git/docs/MultiCloud-APIv1-Specification.html#infrastructure-workload-lcm

Example request toward "Instantiate" API can look as follows:

POST http://msb-iag.onap:80/api/multicloud/v1/k8scloudowner4/k8sregionfour/infra_workload

{
    "generic-vnf-id": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b",
    "oof_directives": {},
    "sdnc_directives": {
        "attributes": [
            {
                "attribute_name": "k8s-rb-profile-namespace",
                "attribute_value": "default"
            },
            {
                "attribute_name": "vnf_model_customization_uuid",
                "attribute_value": "366c007e-7684-4a0b-a2f4-9815174bec55"
            },
            {
                "attribute_name": "vfw_int_private2_ip_0",
                "attribute_value": "192.168.20.10"
            },
            {
                "attribute_name": "int_private1_subnet_id",
                "attribute_value": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b-unprotected-network-subnet-1"
            },
            {
                "attribute_name": "public_net_id",
                "attribute_value": "est"
            },
            {
                "attribute_name": "onap_private_subnet_id",
                "attribute_value": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b-namagement-network-subnet-1"
            },
            {
                "attribute_name": "vsn_int_private2_ip_0",
                "attribute_value": "192.168.20.11"
            },
            {
                "attribute_name": "aic-cloud-region",
                "attribute_value": "k8sregionfour"
            },
            {
                "attribute_name": "int_private1_gw_ip",
                "attribute_value": "192.168.10.11"
            },
            {
                "attribute_name": "sec_group",
                "attribute_value": "culpa"
            },
            {
                "attribute_name": "nfc-naming-code",
                "attribute_value": "base_template"
            },
            {
                "attribute_name": "onap_private_net_cidr",
                "attribute_value": "10.0.0.0/8"
            },
            {
                "attribute_name": "nexus_artifact_repo",
                "attribute_value": "https://nexus.onap.org"
            },
            {
                "attribute_name": "vpg_onap_private_ip_0",
                "attribute_value": "10.0.101.10"
            },
            {
                "attribute_name": "image_name",
                "attribute_value": "voluptatem"
            },
            {
                "attribute_name": "int_private2_gw_ip",
                "attribute_value": "192.168.20.9"
            },
            {
                "attribute_name": "flavor_name",
                "attribute_value": "ducimus"
            },
            {
                "attribute_name": "onap_private_gw_ip",
                "attribute_value": "10.0.101.9"
            },
            {
                "attribute_name": "vfw_int_private2_floating_ip",
                "attribute_value": "192.168.10.13"
            },
            {
                "attribute_name": "vf-module-model-invariant-uuid",
                "attribute_value": "750b39d0-7f99-4b7f-9a22-c15c7348221d"
            },
            {
                "attribute_name": "int_private2_net_cidr",
                "attribute_value": "192.168.20.0/24"
            },
            {
                "attribute_name": "int_private2_subnet_id",
                "attribute_value": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b-protected-network-subnet-1"
            },
            {
                "attribute_name": "vf-naming-policy",
                "attribute_value": "SDNC_Policy.Config_MS_ONAP_VNF_NAMING_TIMESTAMP"
            },
            {
                "attribute_name": "net_attachment_definition",
                "attribute_value": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b-ovn-nat"
            },
            {
                "attribute_name": "vf-module-model-version",
                "attribute_value": "8bb9fa50-3e82-4664-bd1c-a29267be726a"
            },
            {
                "attribute_name": "k8s-rb-profile-name",
                "attribute_value": "vfw-cnf-cds-base-profile"
            },
            {
                "attribute_name": "onap_private_net_id",
                "attribute_value": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b-management-network"
            },
            {
                "attribute_name": "vf_module_label",
                "attribute_value": "base_template"
            },
            {
                "attribute_name": "service-instance-id",
                "attribute_value": "0362acff-38e7-4ecc-8ac0-4780161f3ca0"
            },
            {
                "attribute_name": "sdnc_artifact_name",
                "attribute_value": "vnf"
            },
            {
                "attribute_name": "demo_artifacts_version",
                "attribute_value": "et"
            },
            {
                "attribute_name": "aai-vf-module-put",
                "attribute_value": "SUCCESS"
            },
            {
                "attribute_name": "test.param",
                "attribute_value": "testValue"
            },
            {
                "attribute_name": "pub_key",
                "attribute_value": "aut"
            },
            {
                "attribute_name": "vnf-model-customization-uuid",
                "attribute_value": "366c007e-7684-4a0b-a2f4-9815174bec55"
            },
            {
                "attribute_name": "vfw_int_private1_ip_0",
                "attribute_value": "192.168.10.12"
            },
            {
                "attribute_name": "key_name",
                "attribute_value": "aut"
            },
            {
                "attribute_name": "sdnc_model_version",
                "attribute_value": "1.0.7"
            },
            {
                "attribute_name": "int_private1_net_cidr",
                "attribute_value": "192.168.10.0/24"
            },
            {
                "attribute_name": "install_script_version",
                "attribute_value": "suscipit"
            },
            {
                "attribute_name": "vf_module_type",
                "attribute_value": "Base"
            },
            {
                "attribute_name": "vpg_int_private1_ip_0",
                "attribute_value": "192.168.10.14"
            },
            {
                "attribute_name": "int_private2_net_id",
                "attribute_value": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b-protected-network"
            },
            {
                "attribute_name": "sdnc_model_name",
                "attribute_value": "vFW_CNF_CDS"
            },
            {
                "attribute_name": "cloud_env",
                "attribute_value": "openstack"
            },
            {
                "attribute_name": "int_private1_net_id",
                "attribute_value": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b-unprotected-network"
            }
        ]
    },
    "template_data": {
        "disable_rollback": true,
        "environment": "#snipped for readability",
        "parameters": {
            "int_private1_net_cidr": "192.168.10.0/24",
            "int_private2_net_cidr": "192.168.20.0/24",
            "pub_key": "aut",
            "vf_module_id": "34c190c7-e5bc-4e61-a0d9-5fd44416dd96",
            "vnf_id": "6bfca5dc-993d-48f1-ad27-a7a9ea91836b",
            "vnf_name": "FixedVFW 0"
        },
        "stack_name": "SharedPostman-21-base_template",
        "template": "#snipped for readability",
        "timeout_mins": 120
    },
    "template_type": "",
    "user_directives": {},
    "vf-module-id": "34c190c7-e5bc-4e61-a0d9-5fd44416dd96",
    "vf-module-model-customization-id": "603eadfe-50d6-413a-853c-46f5a8e2ddc7",
    "vf-module-model-invariant-id": "750b39d0-7f99-4b7f-9a22-c15c7348221d",
    "vf-module-model-version-id": "8bb9fa50-3e82-4664-bd1c-a29267be726a"
}


  • No labels