ves-io-schema-network_policy-API-Create
On This Page:
Examples of creating network_policy
Usecase:
Create network-policy-1
Request using vesctl:
vesctl configuration create network_policy -i network_policy.yaml
where file networkpolicy.yaml has following contents (networkpolicy.CreateRequest):
metadata:
name: network-policy-1
namespace: documentation
spec:
endpoint:
any: {}
rules:
egressRules:
- ipPrefixSet:
ref:
- kind: ip_prefix_set
name: ips-1
metadata:
name: egr-1
ingressRules:
- ipPrefixSet:
ref:
- kind: ip_prefix_set
name: ips-1
metadata:
name: igr-1
vesctl yaml response:
metadata:
annotations: {}
labels: {}
name: network-policy-1
namespace: documentation
spec:
endpoint:
any: {}
systemMetadata:
creationTimestamp: "2021-03-31T08:29:28.227887Z"
creatorClass: examplesvc
creatorId: examplesvc
finalizers: []
tenant: acmecorp
uid: 49eeddb7-5fb2-4906-92df-3498a7b52cc4
Request using curl:
curl -X 'POST' -d '{"metadata":{"name":"network-policy-1","namespace":"documentation"},"spec":{"endpoint":{"any":{}},"rules":{"ingressRules":[{"metadata":{"name":"igr-1"},"ipPrefixSet":{"ref":[{"kind":"ip_prefix_set","name":"ips-1"}]}}],"egressRules":[{"metadata":{"name":"egr-1"},"ipPrefixSet":{"ref":[{"kind":"ip_prefix_set","name":"ips-1"}]}}]}}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build318584715_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/config/namespaces/documentation/network_policys'
curl response:
HTTP/1.1 200 OK
Content-Length: 645
Content-Type: application/json
Date: Wed, 31 Mar 2021 08:29:28 GMT
Vary: Accept-Encoding
{
"metadata": {
"name": "network-policy-1",
"namespace": "documentation",
"labels": {
},
"annotations": {
},
"description": "",
"disable": false
},
"system_metadata": {
"uid": "49eeddb7-5fb2-4906-92df-3498a7b52cc4",
"creation_timestamp": "2021-03-31T08:29:28.227887Z",
"deletion_timestamp": null,
"modification_timestamp": null,
"initializers": null,
"finalizers": [
],
"tenant": "acmecorp",
"creator_class": "examplesvc",
"creator_id": "examplesvc",
"object_index": 0,
"owner_view": null
},
"spec": {
"endpoint": {
"any": {
}
}
}
}