Skip to content

Deploying sample applications in containers

The Automotive SIG repo contains containerized sample applications that you can use to learn how to deploy applications in containers in your AutoSD image.

Use the root-root.aib.yml manifest to build a virtual machine OS image that includes containerized sample applications.

The sample applications include two SOME/IP services:

  • radio-service that simulates a radio.
  • engine-service that simulates other parts of the car.

There is also a command line application radio-client, which talks to the services displaying the current status and allowing you to control the radio. For more information, see the sample-apps README.

The image uses the COVESA vsomeip implementation of SOME/IP as packaged in Fedora, and rebuilt in COPR. The image starts the vsomeip routing manager (non-contained) as a systemd service, with a custom SELinux policy that controls access.

After you boot the OS image, two container-based systemd sample services are running: radio.service and engine.service.

Prerequisites

Procedure

  1. Create and go to a new directory called sample-auto-apps:

    $ mkdir sample-auto-apps && cd sample-auto-apps
    
  2. Create and go to a new subdirectory called root-root:

    $ mkdir root-root && cd root-root
    
  3. Create and save a file called radio.container that contains the following code:

    [Unit]
    Description=Demo radio service container
    # routingmanagerd.socket is not included in vsomeip3 3.5.11, so let's use routingmanagerd.service for now
    Requires=routingmanagerd.service
    After=routingmanagerd.service
    Requires=radio.socket
    After=radio.socket
    Wants=engine.service
    
    [Container]
    Image=localhost/auto-apps
    Exec=/usr/bin/radio-service
    Volume=/run/vsomeip:/run/vsomeip
    Volume=/run/root-ipc-demo:/run/root-ipc-demo
    
    [Service]
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  4. Create and save a file called engine.container that contains the following code:

    [Unit]
    Description=Demo engine service container
    # routingmanagerd.socket is not included in vsomeip3 3.5.11, so let's use routingmanagerd.service for now
    Requires=routingmanagerd.service
    After=routingmanagerd.service
    
    [Container]
    Image=localhost/auto-apps
    Exec=/usr/bin/engine-service
    Volume=/run/vsomeip:/run/vsomeip
    Volume=/run/root-ipc-demo:/run/root-ipc-demo
    
    [Service]
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  5. Create and save a file called radio.socket that contains the following code:

    [Unit]
    Description=example systemd unix socket
    
    [Socket]
    ListenStream=%t/root-ipc-demo/root_ipc.socket
    RuntimeDirectory=root-ipc-demo
    
    [Install]
    WantedBy=sockets.target
    
  6. Create and save an Automotive Image Builder manifest named root-root.aib.yml that contains the following YAML code:

    # root-root IPC communications demo
    
    name: root-root-IPC-communications
    
    content:
      repos:
        - id: epel
          metalink: https://mirrors.fedoraproject.org/metalink?repo=epel-10&arch=$arch
    
      rpms:
        - podman
        - netavark
        - aardvark-dns
        - vsomeip3-routingmanager
        - dlt-daemon
        # For testing the image only:
        - openssh-server
        - openssh-clients
    
      container_images:
        # Get the auto-apps container image from gitlab
        - source: registry.gitlab.com/centos/automotive/sample-images/demo/auto-apps
          tag: latest
          name: localhost/auto-apps
    
      add_files:
        - path: /etc/containers/systemd/radio.container
          source_path: ./radio.container
        - path: /etc/containers/systemd/engine.container
          source_path: ./engine.container
        - path: /etc/systemd/system/radio.socket
          source_path: ./radio.socket
    
      # Required for testing the image only:
      systemd:
        enabled_services:
          # Enable ssh daemon
          - sshd.service
          # Enable the dlt daemon
          - dlt
          # Enable the IPC socket
          - radio.socket
    
    auth:
      # "password"
      root_password: $6$xoLqEUz0cGGJRx01$H3H/bFm0myJPULNMtbSsOFd/2BnHqHkMD92Sfxd.EKM9hXTWSmELG8cf205l6dktomuTcgKGGtGDgtvHVXSWU.
      # Required for testing the image only:
      sshd_config:
        PasswordAuthentication: true
        PermitRootLogin: true
    
  7. Export the current system’s CPU architecture as a variable:

    $ arch=$(arch)
    
  8. Run the following command to build the OS image:

    $ automotive-image-builder --verbose \
      --include=. \
      build \
      --distro autosd10 \
      --target qemu \
      --mode image \
      --build-dir=_build \
      --export image \
      root-root.aib.yml \
      root-root.$arch.img
    
  9. Boot the OS image as a virtual machine (VM) in QEMU:

    $ air --nographics root-root.$arch.img
    
  10. Log in to the VM as the root user with the password password.

  11. Verify that the auto-apps container exists:

    # podman image list
    
  12. Verify that the radio service is running:

    # systemctl status radio.service
    
  13. Verify that the engine service is running:

    # systemctl status engine.service
    
  14. When you are done, run the following command to shut down the VM and return to your local terminal:

    # poweroff
    

© Red Hat