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:
  egressRules:
  - kind: network_policy_rule
    name: egress-rule-1
  ingressRules:
  - kind: network_policy_rule
    name: ingress-rule-1
  prefix:
    prefix:
    - 1.1.1.1/32

vesctl yaml response:

metadata:
  annotations: {}
  labels: {}
  name: network-policy-1
  namespace: documentation
spec:
  egressRules:
  - kind: network_policy_rule
    name: egress-rule-1
    namespace: documentation
    tenant: acmecorp
    uid: ffffffff-ffff-ffff-ffff-ffffffffffff
  ingressRules:
  - kind: network_policy_rule
    name: ingress-rule-1
    namespace: documentation
    tenant: acmecorp
    uid: ffffffff-ffff-ffff-ffff-ffffffffffff
  prefix:
    prefix:
    - 1.1.1.1/32
systemMetadata:
  creationTimestamp: "2020-05-15T10:52:49.296703139Z"
  creatorClass: examplesvc.ves.io
  finalizers: []
  tenant: acmecorp
  uid: 4f5dc023-4bb0-412f-b68c-78f1dbcf7c8e

Request using curl:

curl -X 'POST' -d '{"metadata":{"name":"network-policy-1","namespace":"documentation"},"spec":{"prefix":{"prefix":["1.1.1.1/32"]},"ingressRules":[{"kind":"network_policy_rule","name":"ingress-rule-1"}],"egressRules":[{"kind":"network_policy_rule","name":"egress-rule-1"}]}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build144460626_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: 1146
Content-Type: application/json
Date: Fri, 15 May 2020 10:52:49 GMT
Vary: Accept-Encoding

{
  "metadata": {
    "name": "network-policy-1",
    "namespace": "documentation",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "4f5dc023-4bb0-412f-b68c-78f1dbcf7c8e",
    "creation_timestamp": "2020-05-15T10:52:49.296703139Z",
    "deletion_timestamp": null,
    "modification_timestamp": null,
    "initializers": null,
    "finalizers": [
    ],
    "tenant": "acmecorp",
    "creator_class": "examplesvc.ves.io",
    "creator_id": "",
    "object_index": 0,
    "owner_view": null
  },
  "spec": {
    "prefix": {
      "prefix": [
        "1.1.1.1/32"
      ]
    },
    "ingress_rules": [
      {
        "kind": "network_policy_rule",
        "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
        "tenant": "acmecorp",
        "namespace": "documentation",
        "name": "ingress-rule-1"
      }
    ],
    "egress_rules": [
      {
        "kind": "network_policy_rule",
        "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
        "tenant": "acmecorp",
        "namespace": "documentation",
        "name": "egress-rule-1"
      }
    ]
  }
}