[DCAEGEN2-Services] Add example policy types, policies and instrucitons for policy...
[dcaegen2/deployments.git] / dcae-services-policy-sync / README.md
index 519aea6..7dfa09e 100644 (file)
@@ -1,11 +1,13 @@
 # Policy Sync\r
 This page serves as an implementation for the Policy sync container described in the [wiki](https://wiki.onap.org/display/DW/Policy+function+as+Sidecar)\r
 \r
-\r
 Policy Sync utility is a python based utility that interfaces with the ONAP/ECOMP policy websocket and REST APIs. It is designed to keep a local listing of policies in sync with an environment's policy distribution point (PDP). It functions well as a Kubernetes sidecar container which can pull down the latest policies for consumption by an application container. \r
 \r
 The sync utility primarily utilizes the PDP's websocket notification API to receive policy update notifications. It also includes a periodic check of the  PDP for resilliency purposes in the event of websocket API issues. \r
 \r
+Policy Sync provides a way to realize runtime configuration for DCAE microservices through Policy Module. \r
+\r
+Currently, SON-Handler and SliceMS is utilizing policy sync.\r
 \r
 ## Build and Run\r
 Easiest way to use is via docker by building the provided docker file\r
@@ -39,7 +41,7 @@ General configuration that is used regardless of which PDP API you are using.
 | POLICY_SYNC_PDP_URL       | --pdp-url          | PDP URL to query                             | None (must be set in env or flag) |\r
 | POLICY_SYNC_FILTER        | --filters          | yaml list of regex of policies to match      | []                                |\r
 | POLICY_SYNC_ID            | --ids              | yaml list of ids of policies to match        | []                                |\r
-| POLICY_SYNC_DURATION      | --duration         | duration in seconds for periodic checks      | 2600                              |\r
+| POLICY_SYNC_DURATION      | --duration         | duration in seconds for periodic checks      | 1200                              |\r
 | POLICY_SYNC_OUTFILE       | --outfile          | File to output policies to                   | ./policies.json                   |\r
 | POLICY_SYNC_PDP_USER      | --pdp-user         | Set user if you need basic auth for PDP      | None                              |\r
 | POLICY_SYNC_PDP_PASS      | --pdp-password     | Set pass if you need basic auth for PDP      | None                              |\r
@@ -85,7 +87,7 @@ docker run
     --env POLICY_SYNC_V1_DMAAP_USER='<pass>' \\r
     --env POLICY_SYNC_ID=['DCAE.Config_MS_AGING_UVERSE_PROD'] \\r
     -v $(pwd)/policy-volume:/etc/policy \\r
-    nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.policy-sync:1.0.0\r
+    nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.policy-sync:1.0.1\r
 ```\r
 \r
 Or on Kubernetes: \r
@@ -125,7 +127,7 @@ spec:
  \r
   # Sample app that uses inotifyd (part of busybox/alpine). For demonstration purposes only...\r
   - name: main\r
-    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.policy-sync:1.0.0\r
+    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.policy-sync:1.0.1\r
     volumeMounts:\r
     - name: policy-shared\r
       mountPath: /etc/policies.json\r
@@ -137,7 +139,7 @@ spec:
  \r
     # The sidecar app which keeps the policies in sync\r
   - name: policy-sync\r
-    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.policy-sync:1.0.0\r
+    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.policy-sync:1.0.1\r
     envFrom:\r
       - configMapRef:\r
           name: special-config\r
@@ -147,4 +149,14 @@ spec:
       mountPath: /etc/policies\r
 ```\r
 \r
-\r
+## How to apply\r
+Steps to utilize policy sync as a way to do runtime configuration:\r
+1. Create policy Type: curl -k -v --user '<policyApiUserName>:<policyApiPassword>' -X POST "https://{{Policy-API-IP}}:6969/policy/api/v1/policytypes" -H "Content-Type:application/json" -H "Accept: application/json" -d @policy_type.json \r
+2. Create xcaml policy: curl -v -k --silent --user '<policyApiUserName>:<policyApiPassword>' -X POST "https://{{Policy-API-IP}}:6969/policy/api/v1/policytypes/{{PolicyType}}}/versions/{PolicyVersion}/policies" -H "Accept: application/json" -H "Content-Type: application/json" -d @policy.json\r
+   * URL param "PolicyType" value is used to tell policy api which policy type should the current policy belongs to\r
+   * URL param "PolicyType" value should refer to Policy Type Name you define in policy_type.json\r
+   * URL param "PolicyVersion" value should refer to Version you define in policy.json\r
+   * "Policy Id" defines in policy.json should be consistent with the "policyID" in /oom/kubernetes/dcaegen2-services/components/dcae-slice-analysis-ms/values.yaml\r
+3. Deploy policy to xacml pdp engine: curl --silent -k --user '<policyApiUserName>:<policyApiPassword>' -X POST "https://{{Policy-PAP-IP}}:6969/policy/pap/v1/pdps/policies" -H "Accept: application/json" -H "Content-Type: application/json" -d @deploy.json\r
+4. Example policy_type.json, policy.json, deploy.json can be found in resources \r
+Notice: Default '<policyApiUserName>:<policyApiPassword>' & '<policyApiUserName>:<policyApiPassword>' value is 'policyadmin:zb!XztG34'\r