Updated Architecture Chapter 1
[policy/parent.git] / docs / architecture / architecture.rst
1 .. This work is licensed under a
2 .. Creative Commons Attribution 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
4
5
6 Architecture
7 ############
8
9 Abstract
10
11 This document describes the ONAP Policy Framework. It lays out the
12 architecture of the framework and specifies the APIs provided to other
13 components that interwork with the framework. It describes the
14 implementation of the framework, mapping out the components, software
15 structure, and execution ecosystem of the framework. It goes on to
16 provide examples that illustrate how to write, deploy, and run policies
17 of various types using the framework.
18
19 .. contents::
20     :depth: 6
21
22 1. Overview
23 ===========
24
25 The ONAP Policy Framework is a comprehensive policy design, deployment,
26 and execution environment. The Policy Framework is the decision
27 making component in `an ONAP
28 system <https://www.onap.org/wp-content/uploads/sites/20/2018/11/ONAP_CaseSolution_Architecture_112918FNL.pdf>`__.
29 It allows you to specify, deploy, and execute the governance of the
30 features and functions in your ONAP system, be they closed loop,
31 orchestration, or more traditional open loop use case implementations.
32 The Policy Framework is the component that is the source of truth for
33 all policy decisions.
34
35 One of the most important goals of the Policy Framework is to support
36 Policy Driven Operational Management during the execution of ONAP
37 control loops at run time. In addition, use case implementations such as
38 orchestration and control benefit from the ONAP policy Framework because
39 they can use the capabilities of the framework to manage and execute
40 their policies rather than embedding the decision making in their
41 applications.
42
43 The Policy Framework is deployment agnostic, the Policy Framework
44 manages Policy Execution (in PDPs) and Enforcement (in PEPs) regardless
45 of how the PDPs and PEPs are deployed. This allows policy execution and
46 enforcement can be deployed in a manner that meets the performance
47 requirements of a given application or use case. In one deployment,
48 policy execution could be deployed in a separate executing entity in a
49 Docker container. In another, policy execution could be co-deployed with
50 an application to increase performance. An example of co-deployment is the
51 Drools PDP Control Loop image, which is a Docker image that combines the ONAP
52 Drools use case application and dependencies with the Drools PDP engine.
53
54 The ONAP Policy Framework architecture separates policies from the
55 platform that is supporting them. The framework supports development,
56 deployment, and execution of any type of policy in ONAP. The Policy
57 Framework is metadata (model) driven so that policy development,
58 deployment, and execution is as flexible as possible and can support
59 modern rapid development ways of working such as DevOps. A metadata
60 driven approach also allows the amount of programmed support required
61 for policies to be reduced or ideally eliminated.
62
63 We have identified five capabilities as being essential for the
64 framework:
65
66 1. Most obviously, the framework must be capable of being triggered by
67    an event or invoked, and making decisions at run time.
68
69 2. It must be deployment agnostic; capable of managing policies for
70    various Policy Decision Points (PDPs) or policy engines.
71
72 3. It must be metadata driven, allowing policies to be deployed,
73    modified, upgraded, and removed as the system executes.
74
75 4. It must provide a flexible model driven policy design approach for
76    policy type programming and specification of policies.
77
78 5. It must be extensible, allowing straightforward integration of new
79    PDPs, policy formats, and policy development environments.
80
81 Another important aim of the architecture of a model driven policy
82 framework is that it enables much more flexible policy specification.
83 The ONAP Policy Framework complies with the
84 `TOSCA <http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.1/TOSCA-Simple-Profile-YAML-v1.1.pdf>`__
85 modelling approach for policies, see the :ref:`TOSCA Policy Primer <tosca-label>` for more
86 information on how policies are modeled in TOSCA.
87
88 1. A Policy Type is a general implementation of a policy for a feature.
89    For example, a Policy Type could be written to manage Service Level
90    Agreements for VPNs. The Policy Type is designed by a domain expert,
91    who specifies the parameters, triggers, and actions that the Policy
92    Type will have. The implementation (the logic, rules, and tasks of
93    the Policy Type) is implemented by a skilled policy developer in
94    consultation with domain experts.
95
96    1. For example, the VPN Policy Type is used to create VPN policies
97       for a bank network, a car dealership network, or a university with
98       many campuses.
99
100    2. In ONAP, specific ONAP Policy Types are used to create specific
101       policies that drive the ONAP Platform and Components.
102
103 2. A Policy is created by configuring a Policy Type with parameters. For
104    example, the SLA values in the car dealership VPN policy for a
105    particular dealership are configured with values appropriate for the
106    expected level of activity in that dealership.
107
108 For more detailed information on designing Policy Types and developing an
109 implementation for that policy type, see :ref:`Policy Design and Development <design-label>`. 
110
111 The ONAP Policy Framework for building, configuring and deploying PDPs
112 is extendable. It allows the use of ONAP PDPs as is, the extension of
113 ONAP PDPs, and lastly provides the capability for users to create and
114 deploy their own PDPs. The ONAP Policy Framework provides distributed
115 policy management for **all** policies in ONAP at run time. Not only
116 does this provide unified policy access and version control, it provides
117 life cycle control for policies and allows detection of conflicts across
118 all policies running in an ONAP installation.
119
120 2. Architecture
121 ===============
122
123 The diagram below shows the architecture of the ONAP Policy Framework at
124 its highest level.
125
126 .. image:: images/highest.png
127
128 The *PolicyDevelopment* component implements the functionality for
129 development of policy types and policies. *PolicyAdministration* is
130 responsible for the deployment life cycle of policies as well as
131 interworking with the mechanisms required to orchestrate the nodes and
132 containers on which policies run. *PolicyAdministration* is also
133 responsible for the administration of policies at run time; ensuring
134 that policies are available to users, that policies are executing
135 correctly, and that the state and status of policies is monitored.
136 *PolicyExecution* is the set of PDPs running in the ONAP system and is
137 responsible for making policy decisions and for managing the
138 administrative state of the PDPs as directed
139 by \ *PolicyAdministration.* 
140
141 *PolicyDevelopment* creates policy artifacts and supporting information
142 in the policy database. \ *PolicyAdministration* reads those artifacts
143 and the supporting information from the policy database whilst deploying
144 policy artifacts. Once the policy artifacts are deployed,
145 *PolicyAdministration* handles the run-time management of the PDPs on
146 which the policies are running. *PolicyDevelopment* interacts with ONAP
147 design time components, and has no programmatic interface with
148 *PolicyAdministration*, *PolicyExecution* or any other run-time ONAP
149 components.
150
151 The diagram below shows a more detailed view of the architecture, as
152 inspired by `RFC-2753 <https://tools.ietf.org/html/rfc2753>`__ and
153 `RFC-3198 <https://tools.ietf.org/html/rfc3198>`__.
154
155 .. image:: images/detailed.png
156
157 *PolicyDevelopment* provides a
158 `CRUD <https://en.wikipedia.org/wiki/Create,_read,_update_and_delete>`__
159 API for policy types and policies. The policy types and policy artifacts
160 and their metadata (Information about policies, policy types, and their
161 interrelations ) are stored in the *PolicyDB*. The *PolicyDevGUI*,
162 PolicyDistribution, and other applications such as *CLAMP* can use the
163 *PolicyDevelopment* API to create, update, and delete policy types and
164 policies.
165
166 *PolicyAdministration* has two important functions:
167
168 -  Management of the life cycle of PDPs in an ONAP installation. PDPs
169    register with *PolicyAdministration* when they come up.
170    *PolicyAdministration* handles the allocation of PDPs to a PDP Groups
171    and PDP Subgroups, so that they can be managed as microservices in
172    Kubernetes.
173
174 -  Management of the deployment of policies to PDPs in an ONAP
175    installation. *PolicyAdministration* gives each PDP group a set of
176    domain policies to execute.
177
178 *PolicyAdministration* handles PDPs and policy allocation to PDPs using
179 asynchronous messaging over DMaaP.
180
181 *PolicyAdministation* provides three APIs:
182
183 -  a CRUD API for policy groups and subgroups
184
185 -  an API that allows the allocation of policies PDP groups and
186    subgroups to be controlled
187
188 -  an API allows policy execution to be managed, showing the status of
189    policy execution on PDP Groups, subgroups, and individual PDPs as
190    well as the life cycle state of PDPs
191
192 *PolicyExecution* is the set of running PDPs that are executing
193 policies, logically partitioned into PDP groups and subgroups.
194
195 .. image:: images/execution.png
196
197 The figure above shows how *PolicyExecution* looks at run time with PDPs
198 running in Kubernetes. A *PDPGroup* is a purely logical construct that
199 collects all the PDPs that are running policies for a particular domain
200 together. A *PDPSubGroup* is a group of PDPs of the same type that are
201 running the same policies. *A PDPSubGroup* is deployed as a Kubernetes
202 `Deployment <https://kubernetes.io/docs/concepts/workloads/controllers/deployment/>`__.
203 PDPs are defined as Kubernetes
204 `Pods <https://kubernetes.io/docs/concepts/workloads/pods/pod/>`__. At
205 run time,  the actual number of PDPs in each *PDPSubGroup* is specified
206 in the configuration of the *Deployment* of that *PDPSubGroup* in
207 Kubernetes. This structuring of PDPs is required because, in order to
208 simplify deployment and scaling of PDPs in Kubernetes, we gather all the
209 PDPs of the same type that are running the same policies together for
210 deployment.
211
212 For example, assume we have policies for the SON (Self Organizing
213 Network) and ACPE (Advanced Customer Premises Service) domains. For SON,
214 we have XACML, Drools, and APEX policies, and for ACPE we have XACML and
215 Drools policies. The table below shows the resulting\ *PDPGroup*,
216 *PDPSubGroup*, and PDP allocations:
217
218 ============= ================ ========================= ========================================================================== ================
219 **PDP Group** **PDP Subgroup** **Kubernetes Deployment** **Kubernetes Deployment Strategy**                                         **PDPs in Pods**
220 ============= ================ ========================= ========================================================================== ================
221 SON           SON-XACML        SON-XACML-Dep             Always 2, be geo redundant                                                 2 PDP-X
222 \             SON-Drools       SON-Drools-Dep            At Least 4, scale up on 70% load, scale down on 40% load, be geo-redundant >= 4 PDP-D
223 \             SON-APEX         SON-APEX-Dep              At Least 3, scale up on 70% load, scale down on 40% load, be geo-redundant >= 3 PDP-A
224 ACPE          ACPE-XACML       ACPE-XACML-Dep            Always 2                                                                   2 PDP-X
225 \             ACPE-Drools      ACPE-Drools-Dep           At Least 2, scale up on 80% load, scale down on 50% load                   >=2 PDP-D
226 ============= ================ ========================= ========================================================================== ================
227
228 For more details on *PolicyAdministration* API's and management of *PDPGroup* and *PDPSubGroup*,
229 see the documentation for :ref:`Policy Administration Point (PAP) Architecture <pap-label>`. 
230
231 2.1 Policy Framework Object Model
232 ---------------------------------
233
234 This section describes the structure of and relations between the main
235 concepts in the Policy Framework. This model is implemented as a common
236 model and is used by *PolicyDevelopment*, *PolicyDeployment,* and
237 *PolicyExecution.*
238
239 .. image:: images/objectmodel1.png
240
241 The UML class diagram above shows the portion of the Policy Framework
242 Object Model that applies to *PolicyDeployment* and *PolicyExecution.*
243
244 .. image:: images/objectmodel2.png
245
246 The UML class diagram above shows the portion of the Policy Framework
247 Object Model that applies to *PolicyDevelopment* and *PolicyDeployment.*
248
249 2.2 Policy Design Architecture
250 ------------------------------
251
252 This section describes the architecture of the model driven system used
253 to develop policy types and to create concrete policies using policy
254 types. The output of Policy Design is deployment-ready artifacts and
255 Policy metadata in the Policy Framework database.
256
257 Policies that are expressed via natural language or a model require some
258 development work ahead of time for them to be translated into concrete
259 runtime policies. Some Policy Domains will be setup and available in the
260 platform during startup such as Control Loop Operational Policy Models,
261 OOF placement Models, DCAE microservice models. Policy type
262 implementation development is done by an experienced developer.
263
264 2.2.1 Policy Type Design
265 ^^^^^^^^^^^^^^^^^^^^^^^^
266
267 Policy Type Design is the task of creating policy types that capture the
268 generic and vendor independent aspects of a policy for a particular
269 domain use case. The policy type implementation specifies the model
270 information, rules, and tasks that a policy type requires to generate
271 concrete policies.
272
273 All policy types must implement the ONAP Policy Framework *PolicyType*
274 interface. This interface allows \ *PolicyDevelopment* to manage policy
275 types and to generate policies from these policy types in a uniform way
276 regardless of the domain that the policy type is addressing or the PDP
277 technology that will execute the policy. The interface is used by
278 *PolicyDevelopment* to determine the PDP technology of the policy type,
279 the structure, type, and definition of the model information that must
280 be supplied to the policy type to generate a concrete policy.
281
282 A \ *PolicyTypeImpl* is developed for a certain type of PDP (for example
283 XACML oriented for decision policies or Drools rules oriented for ECA
284 policies). The design environment and tool chain for a policy type is
285 specific for the type of policy being designed.
286
287 The \ *PolicyTypeImpl*  implementation (or raw policy) is the
288 specification of the specific rules or tasks, the flow of the policy,
289 its internal states and data structures and other relevant information.
290 A *PolicyTyp*\ e\ *Impl* is specific to a PDP technology, that is XACML,
291 Drools, or APEX. *A PolicyTypeImpl* can be specific to a particular
292 policy type, it can be more general, providing the implementation of a
293 class of policy types, or the same policy type may have many
294 implementations.
295
296 *PolicyDevelopment* provides the RESTful `Policy Design
297 API <https://wiki.onap.org/display/DW/Policy+Design+and+API+Flow+for+Model+Driven+Control+Loop+-+Draft>`__,
298 which allows other components to query policy types and policy type
299 implementations, to determine the model information, rules, or tasks
300 that they require, to specialize policy flow, and to generate policies
301 from policy types. This API is used by the ONAP Policy Framework and
302 other components such as \ *PolicyDistribution* to create policies from
303 policy types.
304
305 Consider a policy type created for managing faults on vCPE equipment in
306 a vendor independent way. The policy type captures the generic logic
307 required to manage the faults and specifies the vendor specific
308 information that must be supplied to the type for specific vendor vCPE
309 VFs. The actual  vCPE policy that is used for managing particular vCPE
310 equipment is created by setting the parameters specified in the policy
311 type together with the specific modeled information, rules and tasks in
312 the policy type implementation for that vendor model of vCPE.
313
314 2.2.2 Generating Policy Types
315 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
316
317 It is possible to generate policy types using MDD (Model Driven
318 Development) techniques. Policy types are expressed using a DSL (Domain
319 Specific Language) or a policy specification environment for a
320 particular application domain. For example, policy types for specifying
321 SLAs could be expressed in a SLA DSL and policy types for managing SON
322 features could be generated from a visual SON management tool. The ONAP
323 Policy framework provides an API that allows tool chains to create
324 policy types. SDC uses this approach for generating Policy Types in the
325 Policy Framework, see the `Model driven Control Loop
326 Design <file://localhost/display/DW/Model+driven+Control+Loop+Design>`__
327 page.
328
329 The SDC GUI supports several types of policies that can be captured at
330 design time. DCAE micro service configuration policies can be onboarded
331 via the DCAE-DS (DCAE Design Studio).
332
333 The GUI implementation in another ONAP component such as SDC DCAE-DS
334 uses the *API_User* API to create and edit ONAP policy types.
335
336 2.2.1.1 Programming Policy Type Implementations
337 """""""""""""""""""""""""""""""""""""""""""""""
338
339 For skilled developers, the most straightforward way to create a policy
340 type is to program it. Programming a policy type might simply mean
341 creating and editing text files, thus manually creating the TOSCA Policy
342 Type Yaml file and the policy type implementation for the policy type.
343
344 A more formal approach is preferred. For policy type implementations,
345 programmers use a specific Eclipse project type for developing each type
346 of implementation, a Policy Type Implementation SDK. The project is
347 under source control in git. This Eclipse project is structured
348 correctly for creating implementations for a specific type of PDP. It
349 includes the correct POM files for generating the policy type
350 implementation and has editors and perspectives that aid  programmers in
351 their work
352
353 2.2.2 Policy Design
354 ^^^^^^^^^^^^^^^^^^^
355
356 The *PolicyCreation* function of *PolicyDevelopment* creates policies
357 from a policy type.  The information expressed during policy type design
358 is used to parameterize a policy type to create an executable policy. A
359 service designer and/or operations team can use tooling that reads the
360 TOSCA Policy Type specifications to express and capture a policy at its
361 highest abstraction level. Alternatively, the parameter for the policy
362 can be expressed in a raw JSON or YAML file and posted over the policy
363 design API described on the `Model driven Control Loop
364 Design <file://localhost/display/DW/Model+driven+Control+Loop+Design>`__
365 page.
366
367 A number of mechanisms for  policy creation are supported in ONAP. The
368 process in *PolicyDevelopment* for creating a policy is the same for all
369 mechanisms. The most general mechanism for creating a policy is using
370 the RESTful *Policy Design API*, which provides a full interface to the
371 policy creation support of *PolicyDevelopment*. This API may be
372 exercised directly using utilities such as *curl*. \ *PolicyDevelopment*
373 provides a command line tool that is a loose wrapper around the API. It
374 also provides a general purpose Policy GUI in the ONAP Portal for policy
375 creation, which again is a general purpose wrapper around the policy
376 creation API. The Policy GUI can interpret any TOSCA Model ingested and
377 flexibly presents a GUI for a user to create policies from. The
378 development of these mechanisms will be phased over a number of ONAP
379 releases.
380
381 A number of ONAP components use policy in manners which are specific to
382 their particular needs. The manner in which the policy creation process
383 is triggered and the way in which information required to create a
384 policy is specified and accessed is specialized for these ONAP
385 components.
386
387 The following subsections outline the mechanisms for policy creation and
388 modification supported by the ONAP Policy Framework.
389
390 2.2.2.1 Policy Design in the ONAP Policy Framework
391 """"""""""""""""""""""""""""""""""""""""""""""""""
392
393 Policy creation in *PolicyDevelopment* follows the general sequence
394 shown in the sequence diagram below. An *API_USER* is any component that
395 wants to create a policy from a policy type. *PolicyDevelopment*
396 supplies a REST interface that exposes the API and also provides a
397 command line tool and general purpose client that wraps the API.
398
399 A *PolicyDevAPIUser* first gets a reference to and the metadata for the
400 Policy type for the policy they want to work on from
401 *PolicyDevelopment*. \ *PolicyDevelopment* reads the metadata and
402 artifact for the policy type from the database. The *API_User* then asks
403 for a reference and the metadata for the policy. \ *PolicyDevelopment*
404 looks up the policy in the database. If the policy already
405 exists, \ *PolicyDevelopment* reads the artifact and returns the
406 reference of the existing policy to the \ *PolicyDevAPIUser* with the
407 metadata for the existing policy. If the policy does not
408 exist, \ *PolicyDevelopment* creates and new reference and metadata and
409 returns that to the \ *API_User*.
410
411 The \ *PolicyDevAPIUser* may now proceed with a policy specification
412 session, where the parameters are set for the policy using the policy
413 type specification. Once the \ *PolicyDevAPIUser* is happy that the
414 policy is completely and correctly specified, it
415 requests \ *PolicyDevelopment* to create the
416 policy. \ *PolicyDevelopment* creates the policy, stores the created
417 policy artifact and its metadata in the database.
418
419 2.2.2.2 Model Driven VF (Virtual Function) Policy Design via VNF SDK Packaging
420 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
421
422 VF vendors express policies such as SLA, Licenses, hardware placement,
423 run-time metric suggestions, etc. These details are captured within the
424 VNF SDK and uploaded into the SDC Catalog. The `SDC Distribution
425 APIs <file://localhost/display/DW/SDC+API>`__ are used to interact with
426 SDC. For example, SLA and placement policies may be captured via TOSCA
427 specification. License policies can be captured via TOSCA or an XACML
428 specification. Run-time metric vendor recommendations can be captured
429 via VES Standard specification.
430
431 The sequence diagram below is a high level view of SDC-triggered
432 concrete policy generation for some arbitrary entity *EntityA*. The
433 parameters to create a policy are read from a TOSCA Policy specification
434 read from a CSAR received from SDC.
435
436 *PolicyDesign* uses the *PolicyDistribution* component for managing
437 SDC-triggered  policy creation and update requests. *PolicyDistribution*
438 is an *API_User*, it uses the Policy Design API for policy creation and
439 update. It reads the information it needs to populate the policy type
440 from a TOSCA specification in a CSAR received from SDC and then uses
441 this information to automatically generate a policy.
442
443 Note that SDC provides a wrapper for the SDC API as a Java Client and
444 also provides a TOSCA parser. See `Policy Platform - SDC Service
445 Distribution Software
446 Architecture <file://localhost/display/DW/Policy+Platform+-+SDC+Service+Distribution+Software+Architecture>`__
447
448 In Step 4 above, the \ *PolicyDesign* must download the CSAR file. If
449 the policy is to be composed from the TOSCA definition, it must also
450 parse the TOSCA definition.
451
452 In Step 9 above, the \ *PolicyDesign* must send back/publish status
453 events to SDC such as DOWNLOAD_OK, DOWNLOAD_ERROR, DEPLOY_OK,
454 DEPLOY_ERROR, NOTIFIED.
455
456 2.2.2.3 Scripted Model Driven Policy Design
457 """""""""""""""""""""""""""""""""""""""""""
458
459 Service policies such as optimization and placement policies can be
460 specified as a TOSCA Policy at design time. These policies use a TOSCA
461 Policy Type specification as their schemas. Therefore, scripts can be
462 used to create TOSCA policies using TOSCA Policy Types.
463
464 One straightforward way of generating policies from Policy types is to
465 use directives specified in a script file. The command line utility is
466 an *API_User*. The script reads directives from a file. For each
467 directive, it reads the policy type using the Policy Type API, and uses
468 the parameters of the directive to create a TOSCA Policy. It then uses
469 the Policy API to create the policy.
470
471 2.2.3 Policy Design Process
472 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
473
474 All policy types must be certified as being fit for deployment prior to
475 run time deployment. In the case of design-time via the SDC application,
476 it is assumed the lifecycle being implemented by SDC will suffice for
477 any policy types that are declared within the ONAP Service CSAR. For
478 other policy types and policy type implementations, the lifecycle
479 associated with software development process will suffice. Since policy
480 types and their implementations will be designed and implemented using
481 software development best practices, they can be utilized and configured
482 for various environments (eg. development, testing, production) as
483 desired.
484
485 2.3 Policy Runtime Architecture
486 -------------------------------
487
488 The Policy Framework Platform components are themselves designed as
489 micro services that are easy to configure and deploy via Docker images
490 and K8S both supporting resiliency and scalability if required. PAPs and
491 PDPs are deployed by the underlying ONAP management infrastructure and
492 are designed to comply with the ONAP interfaces for deploying
493 containers.
494
495 The PAPs keep track of PDPs, support the deployment of PDP groups and
496 the deployment of a policy set across those PDP groups. A PAP is
497 stateless in a RESTful sense. Therefore, if there is more than one PAP
498 deployed, it does not matter which PAP a user contacts to handle a
499 request. The PAP uses the database (persistent storage) to keep track of
500 ongoing sessions with clients. Policy management on PDPs is the
501 responsibility of PAPs; management of policy sets or policies by any
502 other manner is not permitted.
503
504 In the ONAP Policy Framework, the interfaces to the PDP are designed to
505 be as streamlined as possible. Because the PDP is the main unit of
506 scalability in the Policy Framework, the PF is designed to allow PDPs in
507 a PDP group to arbitrarily appear and disappear and for policy
508 consistency across all PDPs in a PDP group to be easily maintained.
509 Therefore, PDPs have just two interfaces; an interface that users can
510 use to execute policies and interface to the PAP for administration,
511 life cycle management and monitoring. The PAP is responsible for
512 controlling the state across the PDPs in a PDP group. The PAP interacts
513 with the Policy database and transfers policy sets to PDPs, and may
514 cache the policy sets for PDP groups.
515
516 See also Sectino 2 of the `Policy Design and API Flow for Model Driven
517 Control
518 Loop <file://localhost/display/DW/Policy+Design+and+API+Flow+for+Model+Driven+Control+Loop>`__
519 page, where the mechanisms for PDP Deployment and Registration with PAP
520 are explained.
521
522 2.3.1 Policy Framework Services
523 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
524
525 The ONAP Policy Framework follows the architectural approach for micro
526 services recommended by the `ONAP Architecture
527 Subcommittee <https://wiki.onap.org/display/DW/Architecture+Subcommittee>`__.
528
529 The ONAP Policy Framework defines `Kubernetes
530 Services <https://kubernetes.io/docs/concepts/services-networking/service/>`__
531 to manage the life cycle of Policy Framework executable components at
532 runtime. A Kubernetes service allows, among other parameters,  the
533 number of instances (pods in Kubernetes terminology) that should be
534 deployed for a particular service to be specified and a common endpoint
535 for that service to be defined. Once the service is started in
536 Kubernetes, Kubernetes ensures that the specified number of instances is
537 always kept running. As requests are received on the common endpoint,
538 they are distributed across the service instances. More complex call
539 distribution and instance deployment strategies may be used; please see
540 the `Kubernetes
541 Services <https://kubernetes.io/docs/concepts/services-networking/service/>`__
542 documentation for those details.
543
544 If, for example, a service called *policy-pdpd-control-loop* is defined
545 that runs 5 PDP-D instances. The service has the end point
546 *https://policy-pdpd-control-loop.onap/<service-specific-path>*. When
547 the service is started, Kubernetes spins up 5 PDP-Ds. Calls to the end
548 point *https://policy-pdpd-control-loop.onap/<service-specific-path>*
549 are distributed across the 5 PDP-D instances. Note that the *.onap* part
550 of the service endpoint is the namespace being used and is specified for
551 the full ONAP Kubernetes installation.
552
553 The following services will be required for the ONAP Policy Framework:
554
555 ================ ============================== ===============================================================================================================================================================================================================================================================
556 **Service**      **Endpoint**                   **Description**
557 ================ ============================== ===============================================================================================================================================================================================================================================================
558 PAP              https://policy-pap             The PAP service, used for policy administration and deployment. See `Policy Design and API Flow for Model Driven Control Loop <file://localhost/display/DW/Policy+Design+and+API+Flow+for+Model+Driven+Control+Loop>`__ for details of the API for this service
559 PDP-X-\ *domain* https://policy-pdpx-\ *domain* A PDP service is defined for each PDP group. A PDP group is identified by the domain on which it operates.
560                                                
561                                                 For example, there could be two PDP-X domains, one for admission policies for ONAP proper and another for admission policies for VNFs of operator *Supacom*. Two PDP-X services are defined:
562                                                
563                                                 | https://policy-pdpx-onap
564                                                 | https://policy-pdpx-\ *supacom*
565 PDP-D-\ *domain* https://policy-pdpd-\ *domain*
566 PDP-A-\ *domain* https://policy-pdpa-\ *domain*
567 ================ ============================== ===============================================================================================================================================================================================================================================================
568
569 There is one and only one PAP service, which handles policy deployment,
570 administration, and monitoring for all policies in all PDPs and PDP
571 groups in the system. There are multiple PDP services, one PDP service
572 for each domain for which there are policies.
573
574 2.3.2 The Policy Framework Information Structure
575 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
576
577 The following diagram captures the relationship between Policy Framework
578 concepts at run time.
579
580 There is a one to one relationship between a PDP SubGroup, a Kubernetes
581 PDP service, and the set of policies assigned to run in the PDP
582 subgroup. Each PDP service runs a single PDP subgroup with multiple
583 PDPs, which executes a specific Policy Set containing a number of
584 policies that have been assigned to that PDP subgroup. Having and
585 maintaining this principle makes policy deployment and administration
586 much more straightforward than it would be if complex relationships
587 between PDP services, PDP subgroups, and policy sets.
588
589 The topology of the PDPs and their policy sets is held in the Policy
590 Framework database and is administered by the PAP service.
591
592 The diagram above gives an indicative structure of the run time topology
593 information in the Policy Framework database. Note that
594 the \ *PDP_SUBGROUP_STATE* and \ *PDP_STATE* fields hold state
595 information for life cycle management of PDP groups and PDPs.
596
597 2.3.3 Startup, Shutdown and Restart
598 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
599
600 This section describes the interactions between Policy Framework
601 components themselves and with other ONAP components at startup,
602 shutdown and restart.
603
604 2.3.3.1 PAP Startup and Shutdown
605 """"""""""""""""""""""""""""""""
606
607 The sequence diagram below shows the actions of the PAP at startup.
608
609 The PAP is the run time point of coordination for the ONAP Policy
610 Framework. When it is started, it initializes itself using data from the
611 database.  It then waits for periodic PDP status updates and for
612 administration requests.
613
614 PAP shutdown is trivial. On receipt or a shutdown request, the PAP
615 completes or aborts any ongoing operations and shuts down gracefully.
616
617 2.3.3.2 PDP Startup and Shutdown
618 """"""""""""""""""""""""""""""""
619
620 The sequence diagram below shows the actions of the PDP at startup. See
621 also Section 4 of the `Policy Design and API Flow for Model Driven
622 Control
623 Loop <file://localhost/display/DW/Policy+Design+and+API+Flow+for+Model+Driven+Control+Loop>`__
624 page for the API used to implement this sequence.
625
626 At startup, the PDP initializes itself.  At this point it is in PASSIVE
627 mode. The PDP begins sending periodic Status messages to the PAP.
628
629 The first Status message initializes the process of loading the correct
630 Policy Set on the PDP in the PAP.
631
632 On receipt or a shutdown request, the PDP completes or aborts any
633 ongoing policy executions and shuts down gracefully.
634
635 2.3.4 Policy Execution
636 ^^^^^^^^^^^^^^^^^^^^^^
637
638 Policy execution is the execution of a policy in a PDP. Policy
639 enforcement occurs in the component that receives a policy decision.
640
641 Policy execution can be *synchronous* or *asynchronous*. In
642 *synchronous* policy execution, the component requesting a policy
643 decision requests a policy decision and waits for the result. The PDP-X
644 and PDP-A use synchronous policy execution. In *asynchronous* policy
645 execution, the component that requests a policy decision does not wait
646 for the decision. Indeed, the decision may be passed to another
647 component. The PDP-D and PDP-A use asynchronous policy execution.
648
649 Policy execution is carried out using the current life cycle mode of
650 operation of the PDP. While the actual implementation of the mode may
651 vary somewhat between PDPs of different types, the principles below hold
652 true for all PDP types:
653
654 ================== ===========================================================================================================================================================================================================================================================================================================================
655 **Lifecycle Mode** **Behaviour**
656 ================== ===========================================================================================================================================================================================================================================================================================================================
657 PASSIVE MODE       Policy execution is always rejected irrespective of PDP type.
658 ACTIVE MODE        Policy execution is executed in the live environment by the PDP.
659 SAFE MODE          Policy execution proceeds, but changes to domain state or context are not carried out. The PDP returns an indication that it is running in SAFE mode together with the action it would have performed if it was operating in ACTIVE mode. The PDP type and the policy types it is running must support SAFE mode operation.
660 TEST MODE          Policy execution proceeds and changes to domain and state are carried out in a test or sandbox environment. The PDP returns an indication it is running in TEST mode together with the action it has performed on the test environment. The PDP type and the policy types it is running must support TEST mode operation.
661 ================== ===========================================================================================================================================================================================================================================================================================================================
662
663 2.3.5 Policy Lifecycle Management
664 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
665
666 Policy lifecycle management manages the deployment and life cycle of
667 policies in PDP groups at run time. Policy sets can be deploy at run
668 time without restarting PDPs or stopping policy execution. PDPs preserve
669 state for minor/patch version upgrades and rollbacks.
670
671 2.3.5.1 Load/Update Policies on PDP
672 """""""""""""""""""""""""""""""""""
673
674 The sequence diagram below shows how policies are loaded or updated on a
675 PDP.
676
677 This sequence can be initiated in two ways; from the PDP or from a user
678 action.
679
680 1. A PDP sends regular status update messages to the PAP. If this
681    message indicates that the PDP has no policies or outdated policies
682    loaded, then this sequence is initiated
683
684 2. A user may explicitly trigger this sequence to load policies on a PDP
685
686 The PAP controls the entire process. The PAP reads the current PDP
687 metadata and the required policy and policy set artifacts from the
688 database. It then builds the policy set for the PDP. Once the policies
689 are ready, the PAP sets the mode of the PDP to PASSIVE. The Policy Set
690 is transparently passed to the PDP by the PAP. The PDP loads all the
691 policies in the policy set including any models, rules, tasks, or flows
692 in the policy set in the policy implementations.
693
694 Once the Policy Set is loaded, the PAP orders the PDP to enter the life
695 cycle mode that has been specified for it (ACTIVE/SAFE/TEST). The PDP
696 beings to execute policies in the specified mode (see section 2.3.4).
697
698 2.3.5.2 Policy Rollout
699 """"""""""""""""""""""
700
701 A policy set steps through a number of life cycle modes when it is
702 rolled out.
703
704 The user defines the set of policies for a PDP group. It is deployed to
705 a PDP group and is initially in PASSIVE mode. The user sets the PDP
706 Group into TEST mode. The policies are run in a test or sandboxed
707 environment for a period of time. The test results are passed back to
708 the user. The user may revert the policy set to PASSIVE mode a number of
709 times and upgrade the policy set during test operation.
710
711 When the user is satisfied with policy set execution and when quality
712 criteria have been reached for the policy set, the PDP group is set to
713 run in SAFE mode. In this mode, the policies run on the actual target
714 environment but do not actually exercise any actions or change any
715 context in the target environment. Again, as in TEST mode, the operator
716 may decide to revert back to TEST mode or even PASSIVE mode if issues
717 arise with a policy set.
718
719 Finally, when the user is satisfied with policy set execution and when
720 quality criteria have been reached, the PDP group is set into ACTIVE
721 state and the policy set executes on the target environment. The results
722 of target operation are reported. The PDP group can be reverted to SAFE,
723 TEST, or even PASSIVE mode at any time if problems arise.
724
725 2.3.5.3 Policy Upgrade and Rollback
726 """""""""""""""""""""""""""""""""""
727
728 There are a number of approaches for managing policy upgrade and
729 rollback.
730
731 The most straightforward approach is to use the approach described in
732 section 2.2.5.2 for upgrading and rolling back policy sets. In order to
733 upgrade a policy set, one follows the process in 2.2.5.2 with the new
734 policy set version. For rollback, one follows the process in section
735 2.2.5.2 with the older policy set, most probably setting the old policy
736 set into ACTIVE mode immediately. The advantage of this approach is that
737 the approach is straightforward. The obvious disadvantage is that the
738 PDP group is not executing on the target environment while the new
739 policy set is in PASSIVE, TEST, and SAFE mode. 
740
741 A second manner to tackle upgrade and rollback is to use a spare-wheel
742 approach. An special upgrade PDP group service is set up as a K8S
743 service in parallel with the active one during the upgrade procedure.
744 The spare wheel service is used to execute the process described in
745 section 2.2.5.2. When the time comes to activate the policy set, the
746 references for the active and spare wheel services are simply swapped.
747 The advantage of this approach is that the down time during upgrade is
748 minimized, the spare wheel PDP group can be abandoned at any time
749 without affecting the in service PDP group, and the upgrade can be
750 rolled back easily for a period simply by preserving the old service for
751 a time. The disadvantage is that this approach is more complex than the
752 first approach.
753
754 A third approach is to have two policy sets running in each PDP, an
755 active set and a standby set. However such an approach would increase
756 the complexity of implementation in PDPs significantly.
757
758 2.3.6 Policy Monitoring
759 ^^^^^^^^^^^^^^^^^^^^^^^
760
761 PDPs provide a periodic report of their status to the PAP. All PDPs
762 report using a standard reporting format that is extended to provide
763 information for specific PDP types. PDPs provide at least the
764 information below:
765
766 ===================== ===============================================================================
767 **Field**             **Description**
768 ===================== ===============================================================================
769 State                 Lifecycle State (PASSIVE/TEST/SAFE/ACTIVE)
770 Timestamp             Time the report record was generated
771 InvocationCount       The number of execution invocations the PDP has processed since the last report
772 LastInvocationTime    The time taken to process the last execution invocation
773 AverageInvocationTime The average time taken to process an invocation since the last report
774 StartTime             The start time of the PDP
775 UpTime                The length of time the PDP has been executing
776 RealTimeInfo          Real time information on running policies.
777 ===================== ===============================================================================
778
779 2.3.7 PEP Registration and Enforcement Guidelines
780 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
781
782 In ONAP there are several applications outside the Policy Framework that
783 enforce policy decisions based on models provided to the Policy
784 Framework. These applications are considered Policy Enforcement Engines
785 (PEP) and roles will be provided to those applications using AAF/CADI to
786 ensure only those applications can make calls to the Policy Decision
787 API's. Some example PEP's are: DCAE, OOF, and SDNC.
788
789 See Section 3.4 of the `Policy Design and API Flow for Model Driven
790 Control
791 Loop <file://localhost/display/DW/Policy+Design+and+API+Flow+for+Model+Driven+Control+Loop>`__
792 for more information on the Decision APIs.
793
794 3. APIs Provided by the Policy Framework
795 ========================================
796
797 See the `Policy Design and API Flow for Model Driven Control
798 Loop <file://localhost/display/DW/Policy+Design+and+API+Flow+for+Model+Driven+Control+Loop>`__
799 page.
800
801 4. Terminology
802 ==============
803
804 ================================= =========================================================================================================================================================
805 PAP (Policy Administration Point) A component that administers and manages policies
806 ================================= =========================================================================================================================================================
807 PDP (Policy Deployment Point)     A component that executes a policy artifact (One or many?)
808 PDP_<>                            A specific type of PDP
809 PDP Group                         A group of PDPs that execute the same set of policies
810 Policy Development                The development environment for policies
811 Policy Type                       A generic prototype definition of a type of policy in TOSCA, see the `TOSCA Policy Primer <file://localhost/display/DW/TOSCA+Policy+Primer>`__
812 Policy                            An executable policy defined in TOSCA and created using a Policy Type, see  the `TOSCA Policy Primer <file://localhost/display/DW/TOSCA+Policy+Primer>`__
813 Policy Set                        A set of policies that are deployed on a PDP group. One and only one Policy Set is deployed on a PDP group
814 ================================= =========================================================================================================================================================
815
816
817 End of Document