ves-io-schema-network_policy_rule-API-Create

Examples of creating networkpolicyrule

Usecase:

Create network-policy-rule-1

Request using vesctl:

vesctl configuration create network_policy_rule -i network_policy_rule.yaml

where file networkpolicyrule.yaml has following contents (networkpolicyrule.CreateRequest):

metadata:
  name: network-policy-rule-1
  namespace: documentation
spec:
  action: ALLOW
  labelMatcher:
    keys:
    - app
  ports:
  - "80"
  prefixSelector:
    expressions:
    - app == web
  protocol: tcp

vesctl yaml response:

metadata:
  annotations: {}
  labels: {}
  name: network-policy-rule-1
  namespace: documentation
spec:
  action: ALLOW
  labelMatcher:
    keys:
    - app
  ports:
  - "80"
  prefixSelector:
    expressions:
    - app == web
  protocol: tcp
systemMetadata:
  creationTimestamp: "2020-05-15T10:52:49.877456657Z"
  creatorClass: examplesvc.ves.io
  finalizers: []
  tenant: acmecorp
  uid: 07530861-33b2-48b4-8549-fd62d9aad33e

Request using curl:

curl -X 'POST' -d '{"metadata":{"name":"network-policy-rule-1","namespace":"documentation"},"spec":{"action":"ALLOW","ports":["80"],"protocol":"tcp","prefixSelector":{"expressions":["app == web"]},"labelMatcher":{"keys":["app"]}}}' -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_policy_rules'

curl response:

HTTP/1.1 200 OK
Content-Length: 832
Content-Type: application/json
Date: Fri, 15 May 2020 10:52:49 GMT
Vary: Accept-Encoding

{
  "metadata": {
    "name": "network-policy-rule-1",
    "namespace": "documentation",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "07530861-33b2-48b4-8549-fd62d9aad33e",
    "creation_timestamp": "2020-05-15T10:52:49.877456657Z",
    "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": {
    "action": "ALLOW",
    "ports": [
      "80"
    ],
    "protocol": "tcp",
    "prefix_selector": {
      "expressions": [
        "app == web"
      ]
    },
    "label_matcher": {
      "keys": [
        "app"
      ]
    }
  }
}