ves-io-schema-service_policy-API-Create
On This Page:
Examples of creating service_policy
Usecase:
Create service-policy-1
Request using vesctl:
vesctl configuration create service_policy -i service_policy.yaml
where file service_policy.yaml has following contents (service_policy.CreateRequest):
RequestJSON:
{"metadata":{"name":"service-policy-1","namespace":"documentation"},"spec":{"server_selector":{"expressions":["geoip.ves.io/region in (US-West), deployment in (testing)"]},"deny_all_requests":{}}}
`
vesctl yaml response:
ResponseJSON:
"metadata": {
"name": "service-policy-1",
"namespace": "documentation",
"labels": {
},
"annotations": {
},
"description": "",
"disable": false
},
"system_metadata": {
"uid": "cd2e48c5-adb6-4fbd-99bf-6258b7b7a14f",
"creation_timestamp": "2022-07-28T12:11:53.317667678Z",
"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": {
"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": [
]
}
}```
`
Request using curl:
curl -X 'POST' -d '{"metadata":{"name":"service-policy-1","namespace":"documentation"},"spec":{"server_selector":{"expressions":["geoip.ves.io/region in (US-West), deployment in (testing)"]},"deny_all_requests":{}}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build1372770011_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: 892 Content-Type: application/json Date: Thu, 28 Jul 2022 12:11:53 GMT Vary: Accept-Encoding
{ "metadata": { "name": "service-policy-1", "namespace": "documentation", "labels": { }, "annotations": { }, "description": "", "disable": false }, "system_metadata": { "uid": "cd2e48c5-adb6-4fbd-99bf-6258b7b7a14f", "creation_timestamp": "2022-07-28T12:11:53.317667678Z", "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": { "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": [
]
} }