docs/doc/source/container_integration/kubernetes/create-test-and-terminate-a-ptp-notification-demo.rst
Adil 716f387f93 Fixed figure width.
Worked on the comments.
Corrected broken link in index.
Added container integration guide.

Signed-off-by: Adil <mohamed.adilassakkali@windriver.com>
Change-Id: Id9d8e1abd8f15a51d9069cf7543e1b559a118369
2021-03-26 11:19:41 -03:00

4.7 KiB

Create, Test, and Terminate a PTP Notification Demo

This section provides instructions on accessing, creating, testing and terminating a ptp-notification-demo.

Use the following procedure to copy the tarball from , create, test, and terminate a ptp-notification-demo.

  1. Copy the ptp-notification-demo_v1.0.2.tgz file from at http://mirror.starlingx.cengn.ca/mirror/starlingx/ to yor system, and extract its content.

    Note

    The tarball includes the docker file and code to build the reference API application, and the Helm chart to install the Sidecar along with the application.

    The following files are part of the tarball:

    • Helm charts
      • Chart.yaml
      • values.yaml
      • _helpers.tpl
      • configmap.yaml
      • deployment.yaml
      • .helmignore
      • ptp-notification-override.yaml
      • app_start.sh
      • sidecar_start.sh
    • notification-docker
      • Dockerfile
      • api

    Note

    The demo uses the following images:

    • starlingx/notificationclient-base:stx.5.0-v1.0.3
    • ptp-base:1.0.1
  2. Build the ptp-base:1.0.1 image using the following commands.

    $ tar xvf ptp-notification-demo_<v1.0.2>.tgz
    $ cd ~/notification-dockers/ptp-base/
    $ sudo docker build . -t ptp-base:1.0.1
    $ sudo docker save ptp-base:1.0.1 -o ptp-base.1.0.1.tar
    $ sudo ctr -n k8s.io image import ./ptp-base.1.0.1.tar
    $ cd ~/charts
    $ tar xvf ptp-notification-demo-1.tgz

    Note

    For -SX and AIO-DX systems, ptp-base.1.0.1.tar should be copied to each node and the import command, sudo ctr -n k8s.io image import ./ptp-base.1.0.1.tar should be run on each node.

  3. Install the demo's pod using the following commands.

    Note

    This pod includes two containers, Sidecar and the referenced API application.

    $ kubectl create namespace ptpdemo 
    $ helm install -n notification-demo ~/charts/ptp-notification-demo -f ~/charts/ptp-notification-demo/ptp-notification-override.yaml 
    $ kubectl get pods -n ptpdemo
    NAME                                         READY   STATUS   RESTARTS AGE
    notification-demo-ptp-notification-demo-cf7b65c47-s5jk6 2/2     Running   0       5m50s
  4. Test the ptp-notification demo.

    1. Display the app logs using the following command.

      $ kubectl logs -f notification-demo-ptp-notification-demo-<xyz> -c ptp-notification-demo-app -n ptpdemo
  5. In another terminal, access the application container.

    $ kubectl exec -it notification-demo-ptp-notification-demo-<zyz> -c ptp-notification-demo-app -n ptpdemo -- bash
    1. Check if you can pull status using the REST API.

      $ curl -v -H 'Content-Type: application/json' http://127.0.0.1:8080/ocloudNotifications/v1/PTP/CurrentState
    2. Subscribe to notifications.

      $ curl -v -d '{"ResourceType": "PTP", "ResourceQualifier": {"NodeName": "controller-0"}, "EndpointUri": "http://127.0.0.1:9090/v1/resource_status/ptp"}' -H 'Content-Type: application/json' -X POST http://127.0.0.1:${SIDECAR_API_PORT}/ocloudNotifications/v1/subscriptions |python -m json.tool
    3. Retrieve a list of subscriptions.

      $ curl -v -H 'Content-Type: application/json' http://127.0.0.1:${SIDECAR_API_PORT}/ocloudNotifications/v1/subscriptions |python -m json.tool

      For example, to get a specific subscription, use the following command.

      $ curl -v -H 'Content-Type: application/json' http://127.0.0.1:${SIDECAR_API_PORT}/ocloudNotifications/v1/subscriptions/<subscriptionId>
    4. To delete a specific subscription with the subscription ID, run the following command.

      $ curl -X DELETE -v -H 'Content-Type: application/json' http://127.0.0.1:${SIDECAR_API_PORT}/ocloudNotifications/v1/subscriptions/<subscriptionId>
  6. Terminate the demo using the following command.

    $ helm del --purge notification-demo