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:
  denyAllRequests: {}
  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:
  denyAllRequests: {}
  rules: []
  serverSelector:
    expressions:
    - geoip.ves.io/region in (US-West), deployment in (testing)
  simpleRules: []
systemMetadata:
  creationTimestamp: "2021-07-14T08:08:11.702061269Z"
  creatorClass: examplesvc
  creatorId: examplesvc
  finalizers: []
  tenant: acmecorp
  uid: 61f75d6a-38be-4ce5-854a-5a4fad0f7c74

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)"]},"denyAllRequests":{}}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build381173587_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: 869
Content-Type: application/json
Date: Wed, 14 Jul 2021 08:08:11 GMT
Vary: Accept-Encoding

{
  "metadata": {
    "name": "service-policy-1",
    "namespace": "documentation",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "61f75d6a-38be-4ce5-854a-5a4fad0f7c74",
    "creation_timestamp": "2021-07-14T08:08:11.702061269Z",
    "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)"
      ]
    },
    "port_matcher": null,
    "rules": [
    ],
    "deny_all_requests": {

    },
    "simple_rules": [
    ]
  }
}