ves-io-schema-service_policy-API-Create

Examples of creating service_policy

Usecase:

Create service-policy-1

Request using vesctl:

vesctl configuration create service_policy -i service_policy.yaml

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

metadata:
  name: service-policy-1
  namespace: documentation
spec:
  rules:
  - kind: service_policy_rule
    name: service-policy-rule-1
  - kind: service_policy_rule
    name: service-policy-rule-2
  serverSelector:
    expressions:
    - geoip.ves.io/region in (US-West), deployment in (testing)

vesctl yaml response:

metadata:
  annotations: {}
  labels: {}
  name: service-policy-1
  namespace: documentation
spec:
  rules:
  - kind: service_policy_rule
    name: service-policy-rule-1
    namespace: documentation
    tenant: acmecorp
    uid: ffffffff-ffff-ffff-ffff-ffffffffffff
  - kind: service_policy_rule
    name: service-policy-rule-2
    namespace: documentation
    tenant: acmecorp
    uid: ffffffff-ffff-ffff-ffff-ffffffffffff
  serverSelector:
    expressions:
    - geoip.ves.io/region in (US-West), deployment in (testing)
  simpleRules: []
systemMetadata:
  creationTimestamp: "2020-09-23T09:53:57.825112Z"
  creatorClass: examplesvc
  creatorId: examplesvc
  finalizers: []
  tenant: acmecorp
  uid: c77646f5-0f36-4ba5-9efb-2315ce28e6ff

Request using curl:

curl -X 'POST' -d '{"metadata":{"name":"service-policy-1","namespace":"documentation"},"spec":{"serverSelector":{"expressions":["geoip.ves.io/region in (US-West), deployment in (testing)"]},"rules":[{"kind":"service_policy_rule","name":"service-policy-rule-1"},{"kind":"service_policy_rule","name":"service-policy-rule-2"}]}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build823219857_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/config/namespaces/documentation/service_policys'

curl response:

HTTP/1.1 200 OK
Content-Length: 1268
Content-Type: application/json
Date: Wed, 23 Sep 2020 09:53:57 GMT
Vary: Accept-Encoding

{
  "metadata": {
    "name": "service-policy-1",
    "namespace": "documentation",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "c77646f5-0f36-4ba5-9efb-2315ce28e6ff",
    "creation_timestamp": "2020-09-23T09:53:57.825112Z",
    "deletion_timestamp": null,
    "modification_timestamp": null,
    "initializers": null,
    "finalizers": [
    ],
    "tenant": "acmecorp",
    "creator_class": "examplesvc",
    "creator_id": "examplesvc",
    "object_index": 0,
    "owner_view": null
  },
  "spec": {
    "algo": "FIRST_MATCH",
    "server_selector": {
      "expressions": [
        "geoip.ves.io/region in (US-West), deployment in (testing)"
      ]
    },
    "rules": [
      {
        "kind": "service_policy_rule",
        "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
        "tenant": "acmecorp",
        "namespace": "documentation",
        "name": "service-policy-rule-1"
      },
      {
        "kind": "service_policy_rule",
        "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
        "tenant": "acmecorp",
        "namespace": "documentation",
        "name": "service-policy-rule-2"
      }
    ],
    "port_matcher": null,
    "simple_rules": [
    ]
  }
}