Modifying the Container Configuration

You can further configure the connector container. You can either modify the provided sample or create a custom application.yml or application.properties file in the configdirectory containing the properties required for the connector.

To use the connector in a container:

Prerequisites

Using the Connector for Google Pub/Sub with containers requires:

Getting Started Using Connectors With Containers

You can run the connector in a container with the minimal configuration. Optionally, you can specify connecter services on the host or a health check. Perform the following steps to start the connector with a minimal configuration in a container:

  1. Create a directory called config.

  2. Create an application.yml or application.properties file in the config directory containing the properties needed for your connector. For an example of an configuration file, see the samples/config directory in the archive (ZIP) file you downloaded for this connector.

  3. The Application Default Credentials (ADC) by Using the Google Cloud CLI has been setup, and application_default_credentials.json is in the default location.

  4. Set the spring.cloud.gcp.credentials.location property in application.yml or application.properties to /app/external/gcp/config/application_default_credentials.json.

  5. Run the container with minimal configuration as follows:

    In Docker, use the following command:

    docker run -d --name my-connector \
    -v `pwd`/libs/:/app/external/libs/:ro \
    -v `pwd`/config/:/app/external/spring/config/:ro \
    -v
    $HOME/.config/gcloud/application_default_credentials.json:/app/external/gcp/config/
    application_default_credentials.json:ro \
    solace/solace-pubsub-connector-gcppubsub:<version>

    In Podman, use the following command:

    podman run -d --name my-connector \
    -v `pwd`/libs/:/app/external/libs/:ro \
    -v `pwd`/config/:/app/external/spring/config/:ro \
    -v
    $HOME/.config/gcloud/application_default_credentials.json:/app/external/gcp/config/
    application_default_credentials.json:ro \
    solace/solace-pubsub-connector-gcppubsub:<version>

Where <version> is the version of the connector you are using, such as 2.0.0.

On Windows, the default location of application_default_credentials.json is %APPDATA%\gcloud\application_default_credentials.json, so change the volume mount accordingly.
Presuming that the Google Cloud application_default_credentials.json is in the default location, add a volume mount to all Docker or Podman commands in reset of this document depending on your environment:

  • On Linux or MacOS: -v $HOME/.config/gcloud/application_default_credentials.json:/app/external/gcp/con fig/application_default_credentials.json:ro \

  • On Windows: -v %APPDATA%\gcloud\application_default_credentials.json:/app/external/gcp/config/ application_default_credentials.json:ro \

Connecting to Services on the Host

If services (for example a PubSub+ event broker) are exposed on the localhost, they can be referenced using the container platform’s special DNS name with SOLACE_JAVA_HOST, which resolves to an internal IP address that's used by the host.

For example in Docker, use the following command:

docker run -d --name my-connector \
-v `pwd`/libs/:/app/external/libs/:ro \
-v `pwd`/config/:/app/external/spring/config/:ro \
--env SOLACE_JAVA_HOST=host.docker.internal:55555 \
solace/solace-pubsub-connector-gcppubsub:2.0.0

For example in Podman, use the following command:

podman run -d --name my-connector \
-v `pwd`/libs/:/app/external/libs/:ro \
-v `pwd`/config/:/app/external/spring/config/:ro \
--env SOLACE_JAVA_HOST=host.containers.internal:55555 \
solace/solace-pubsub-connector-gcppubsub:2.0.0

Configuring a Health Check

You can configure the health to perform the following tasks:

  • Create a regular read-only user called healthcheck with a password using SOLACE_CONNECTOR_SECURITY_USERS_0_NAME and SOLACE_CONNECTOR_SECURITY_USERS_0_PASSWORD.
  • Use the healthcheck user as the user to poll the management health endpoint in the container’s healthcheck command and fails it if the connector is unhealthy.

Here’s a basic example command of how to configure the health check for the container:

For example in Docker, use the following command:

docker run -d --name my-connector \
-v `pwd`/libs/:/app/external/libs/:ro \
-v `pwd`/application.yml:/app/external/spring/config/application.yml:ro \
--env SOLACE_CONNECTOR_SECURITY_USERS_0_NAME=healthcheck \
--env SOLACE_CONNECTOR_SECURITY_USERS_0_PASSWORD=healthcheck \
--healthcheck-command="curl -X GET -u healthcheck:healthcheck --fail
localhost:8090/actuator/health" \
solace/solace-pubsub-connector-gcppubsub:2.0.0

For example in Podman, use the following command:

podman run -d --name my-connector \
-v `pwd`/libs/:/app/external/libs/:ro \
-v `pwd`/application.yml:/app/external/spring/config/application.yml:ro \
--env SOLACE_CONNECTOR_SECURITY_USERS_0_NAME=healthcheck \
--env SOLACE_CONNECTOR_SECURITY_USERS_0_PASSWORD=healthcheck \
--healthcheck-command="curl -X GET -u healthcheck:healthcheck --fail
localhost:8090/actuator/health" \
solace/solace-pubsub-connector-gcppubsub:2.0.0

Specifying Configuration Using Spring Configuration Properties

You can provide Spring configuration properties to this container using one of the following ways:

Port Configuration

The following ports are required for the container:

Port Usage
8090

The connector’s management endpoint.

Volume Configuration

These are the supported directories for which volumes and bind mounts can be created:

Contents Container Path Required or Optional Recommended Permission
Spring configuration files

/app/external/spring/config/

Required unless all properties are defined using environment variables Read-Only
Libraries /app/external/libs/ Required Read-Only
Classpath files /app/external/classpath/ Optional Read-Only
Output files /app/external/output/ Optional Read/Write

 

Volume: Spring Configuration Files

The Spring configuration files volume is used to add Spring configuration files (such as application.yml, etc.), add a read-only volume, or bind a mount to /app/external/spring/config/.

This directory follows the same semantics as Spring’s default config/ directory. This fact means that this connector automatically finds and loads Spring configuration files from the following locations when the connector starts:

  • The root of /app/external/spring/config/.
  • Immediate child directories of /app/external/spring/config/.

If you want configuration files for multiple, different connectors within the same config directory for use in different environments (e.g., development, production, etc.), we recommend that you use Spring Boot Profiles instead of child directories. For example:

  • Set up your configuration like this:

    • config/application-prod.yml
    • config/application-dev.yml

  • Do not do this:

    • config/prod/application.yml
    • config/dev/application.yml

Child directories are intended to be used for merging configuration from multiple sources of config properties. For more information and an example of when you might want to use multiple child directories to compose your application’s configuration, see the Spring Boot documentation.

Volume: Libraries

The Libraries volume adds additional libraries, adds a read-only volume, or binds a mount to /app/external/libs/.

This libs directory is provided as the location for the Java library dependencies (external JAR files) that are either required or required only when using certain features of the connector (such as Prometheus libraries when using the metrics export to Prometheus feature in your connector configuration). Solace does not provide the required JAR files due to licensing considerations. These JAR files are required as part of the deployment of the connector for it to operate correctly.

See the documentation provided in the libs directory of the connector in the ZIP file for more information.

Volume: Classpath Files

The Classpath Files volume adds a location for arbitrary files (not JAR libraries nor Spring Boot configuration files), adds a read-only volume, or binds a mount to /app/external/classpath/.

This directory must not contain JAR files for libraries or Spring Boot configuration files, otherwise there is a risk of libraries not getting picked up during the deployment of the connector and overwriting the connector’s internal configuration.

Volume: Output Files

The Output Files volume is for some features that support writing output files, such as logging to a file. To capture these, add a read/write volume or bind the mount to /app/external/output/.

When using features that generates files, you must configure the features so that the files are generated to the /app/external/output/ directory. Generating files to any other directory is not supported.

Configuring the JVM

You can set the JDK_JAVA_OPTIONS environment variable on the container to configure the Java Virtual Machine (JVM). See the JDK documentation for more information.

This container is provided as an example and has been tested using:

  • Two active processsors (specified using -XX:ActiveProcessorCount=2).
  • A maximum heap memory of 2 GB (specified using -Xmx2048m).