ves-io-schema-network_policy-API-Create

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-07-14T08:07:44.309261545Z"
  creatorClass: examplesvc
  creatorId: examplesvc
  finalizers: []
  tenant: acmecorp
  uid: 538df93b-1057-4d9d-8965-d14233a66247

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-build381173587_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: 648
Content-Type: application/json
Date: Wed, 14 Jul 2021 08:07:44 GMT
Vary: Accept-Encoding

{
  "metadata": {
    "name": "network-policy-1",
    "namespace": "documentation",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "538df93b-1057-4d9d-8965-d14233a66247",
    "creation_timestamp": "2021-07-14T08:07:44.309261545Z",
    "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": {

      }
    }
  }
}