​
Select Service
ves-io-schema-service_policy-API-Create
Published April 5, 2023 | Last modified March 20, 2025
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": {}
}
}
Copied!
vesctl yaml response:
ResponseJSON:
{
"metadata": {
"name": "service-policy-1",
"namespace": "documentation",
"labels": {},
"annotations": {},
"description": "",
"disable": false
},
"system_metadata": {
"uid": "1d1fafcb-006e-49da-a096-f9bd3d367de0",
"creation_timestamp": "2025-03-11T00:56:30.260989Z",
"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": []
}
}
Copied!
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=_var_folders_q2_3kp8z3zs0x5_m7pk1bgb0_ph0000gp_T_go-build436303540_b001_apidocs.test/host=MTY6VVHQPH/svc=S:examplesvc/site=mytestce01' 'https://acmecorp.console.ves.volterra.io/api/config/namespaces/documentation/service_policys'
Copied!
curl response:
HTTP/1.1 200 OK
Content-Length: 889
Content-Type: application/json
Date: Tue, 11 Mar 2025 00:56:30 GMT
Vary: Accept-Encoding
{
"metadata": {
"name": "service-policy-1",
"namespace": "documentation",
"labels": {
},
"annotations": {
},
"description": "",
"disable": false
},
"system_metadata": {
"uid": "1d1fafcb-006e-49da-a096-f9bd3d367de0",
"creation_timestamp": "2025-03-11T00:56:30.260989Z",
"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": [
]
}
}
Copied!