ves-io-schema-discovery-API-Create

Examples of creating discovery

Usecase:

Create discovery object that will discover services from external kubernetes cluster. Any VIP(s) that are advertised on sites selected by virtual site acmecorp-vsite can be discovered by subdomian internal.bookinfo.com

Request using vesctl:

vesctl configuration create discovery -i discovery.yaml

where file discovery.yaml has following contents (discovery.CreateRequest):

RequestJSON:

{
    "metadata": {
        "name": "k8s-discovery",
        "namespace": "system"
    },
    "spec": {
        "where": {
            "virtual_site": {
                "ref": [
                    {
                        "kind": "virtual_site",
                        "tenant": "acmecorp",
                        "namespace": "system",
                        "name": "acmecorp-vsite"
                    }
                ]
            }
        },
        "discovery_k8s": {
            "access_info": {
                "kubeconfig_url": {
                    "clear_secret_info": {
                        "url": "string://\u003cbase64\u003e"
                    }
                },
                "isolated": {}
            },
            "publish_info": {
                "dns_delegation": {
                    "subdomain": "internal.bookinfo.com"
                }
            }
        }
    }
}

vesctl yaml response:

ResponseJSON:

{
    "metadata": {
        "name": "k8s-discovery",
        "namespace": "system",
        "labels": {},
        "annotations": {},
        "description": "",
        "disable": false
    },
    "system_metadata": {
        "uid": "eadf9b2f-c854-404f-a970-67693ea09edb",
        "creation_timestamp": "2022-09-23T13:11:54.776923608Z",
        "deletion_timestamp": null,
        "modification_timestamp": null,
        "initializers": null,
        "finalizers": [],
        "tenant": "acmecorp",
        "creator_class": "examplesvc",
        "creator_id": "examplesvc",
        "object_index": 0,
        "owner_view": null,
        "labels": {}
    },
    "spec": {
        "where": {
            "virtual_site": {
                "ref": [
                    {
                        "kind": "virtual_site",
                        "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
                        "tenant": "acmecorp",
                        "namespace": "system",
                        "name": "acmecorp-vsite"
                    }
                ],
                "network_type": "VIRTUAL_NETWORK_SITE_LOCAL"
            }
        },
        "type": "INVALID_DISCOVERY",
        "publish_vip": null,
        "discovery_k8s": {
            "access_info": {
                "kubeconfig_url": {
                    "clear_secret_info": {
                        "provider": "",
                        "url": "string://\u003cbase64\u003e"
                    },
                    "blindfold_secret_info_internal": null,
                    "secret_encoding_type": "EncodingNone"
                },
                "isolated": {}
            },
            "publish_info": {
                "dns_delegation": {
                    "subdomain": "internal.bookinfo.com",
                    "dns_mode": "CORE_DNS"
                }
            }
        },
        "no_cluster_id": {}
    }
}

Request using curl:

curl -X 'POST' -d '{"metadata":{"name":"k8s-discovery","namespace":"system"},"spec":{"where":{"virtual_site":{"ref":[{"kind":"virtual_site","tenant":"acmecorp","namespace":"system","name":"acmecorp-vsite"}]}},"discovery_k8s":{"access_info":{"kubeconfig_url":{"clear_secret_info":{"url":"string://\u003cbase64\u003e"}},"isolated":{}},"publish_info":{"dns_delegation":{"subdomain":"internal.bookinfo.com"}}}}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build243329498_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/config/namespaces/system/discoverys'

curl response:

HTTP/1.1 200 OK
Content-Type: application/json
Date: Fri, 23 Sep 2022 13:11:54 GMT
Vary: Accept-Encoding

{
  "metadata": {
    "name": "k8s-discovery",
    "namespace": "system",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "eadf9b2f-c854-404f-a970-67693ea09edb",
    "creation_timestamp": "2022-09-23T13:11:54.776923608Z",
    "deletion_timestamp": null,
    "modification_timestamp": null,
    "initializers": null,
    "finalizers": [
    ],
    "tenant": "acmecorp",
    "creator_class": "examplesvc",
    "creator_id": "examplesvc",
    "object_index": 0,
    "owner_view": null,
    "labels": {
    }
  },
  "spec": {
    "where": {
      "virtual_site": {
        "ref": [
          {
            "kind": "virtual_site",
            "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
            "tenant": "acmecorp",
            "namespace": "system",
            "name": "acmecorp-vsite"
          }
        ],
        "network_type": "VIRTUAL_NETWORK_SITE_LOCAL"
      }
    },
    "type": "INVALID_DISCOVERY",
    "publish_vip": null,
    "discovery_k8s": {
      "access_info": {
        "kubeconfig_url": {
          "clear_secret_info": {
            "provider": "",
            "url": "string://\u003cbase64\u003e"
          },
          "blindfold_secret_info_internal": null,
          "secret_encoding_type": "EncodingNone"
        },
        "isolated": {

        }
      },
      "publish_info": {
        "dns_delegation": {
          "subdomain": "internal.bookinfo.com",
          "dns_mode": "CORE_DNS"
        }
      }
    },
    "no_cluster_id": {

    }
  }
}