This guide will show you how to create a script to export all environment variables used for the remainder of our tutorials. Once created, this script can be used as a starting point for your production deployment process.
Environment variables are inherited from any process started by that environment. It is a good idea to create a script to set environment variables as part of a programs initiation. In this case, environment variables are a good place to store configuration values required to connect to an Eventador deployment. Each language has its own syntax for accessing environment variables. We will cover this in our language specific tutorials.
You can set an environment variable in bash using command
export VARNAME="SOME VALUE". To check current value of an environment variable use
Below is the minimum setup required to connect to your Eventador deployment.
|EVENTADOR_PLAINTEXT_ENDPOINT||Single (or list) of plain text endpoints from your deployment’s connections tab|
First, you will need your plain text endpoint from the UI. To get your endpoint, navigate to the console tab and click your Apache Kafka deployment.
Now switch to the connection tab to find your deployments endpoints.
demotopic as shown in the getting started guide.
#!/bin/bash ## Setup environment variables used by Eventador examples # # Load via: . ./bootstrap_tutorial_environment.sh ### Required # Pull the list of brokers from your deployment's connections tab export EVENTADOR_PLAINTEXT_ENDPOINT=<value_copied_from_UI> # Topic you wish you use. export EVENTADOR_KAFKA_TOPIC="demo"
Additional setup required for more advanced features such as encrypted connections and easier monitoring/debugging.
|EVENTADOR_KAFKA_CA_CERT||Generate & copy from your deployment’s security tab|
|EVENTADOR_KAFKA_CLIENT_CERT||Generate & copy from your deployment’s security tab|
|EVENTADOR_KAFKA_CLIENT_KEY||Generate & copy from your deployment’s security tab|
|EVENTADOR_SSL_ENDPOINT||Single (or list) of SSL endpoints from your deployment’s connections tab|
|EVENTADOR_KAFKA_USE_SSL||Boolean to toggle use of SSL|
|EVENTADOR_KAFKA_CONSUMER_GROUP||Identify a consumer group for splitting messages between multiple consumers|
|EVENTADOR_KAFKA_CLIENT_ID||Identify a client with user generated unique ID, helpful for debugging clients|
|EVENTADOR_ZOOKEEPER_ENSEMBLE||Pull the list of zookeepers from your deployment’s connections tab|
Required if you plan to send / receive encrypted messages.
On the right side of the deployments deployments page click the security button.
Enter a common name and click generate to create a pair of key/certificates.
Do not leave this screen until you copy your keys as shown below below.
EVENTADOR_KAFKA_CLIENT_KEY. Copy full text in each box to their respective environment variable in the
bootstrap_tutorial_environment.shfile. Be sure to include header/footer rows containing
EVENTADOR_SSL_ENDPOINTyou will find this value just below the plain text endpoint.
Finally, the last few are optional but can be helpful as you move past basic examples.
By now, you should have a
bootstrap_tutorial_environment.sh script populated with your desired setup.
Navigate to the directory with your script and run
. ./bootstrap_tutorial_environment.sh. You can check values were properly from command line with
env | grep EVENTADOR
env | grep EVENTADOR EVENTADOR_PLAINTEXT_ENDPOINT=secret EVENTADOR_KAFKA_CLIENT_ID=demo_id EVENTADOR_KAFKA_CA_CERT=-----BEGIN CERTIFICATE----- EVENTADOR_KAFKA_CLIENT_CERT=-----BEGIN CERTIFICATE----- EVENTADOR_KAFKA_TOPIC=demo EVENTADOR_KAFKA_CLIENT_KEY=-----BEGIN PRIVATE KEY----- EVENTADOR_SSL_ENDPOINT=secret EVENTADOR_KAFKA_CONSUMER_GROUP=myconsumer EVENTADOR_ZOOKEEPER_ENSEMBLE=secret
Congratulations! You now have a script which will set the environment variables used throughout our tutorials.
Questions, feedback or find any of these steps unclear? Please contact us. We love helping people get started.