Before reading this, make sure you read Usage as it applies to this guide as well.
This guide describes usage that only applies to users that run the program inside a docker container.
You should run the program as
docker run <repository/image-name:tag-name>Please read along to learn usage specific to Docker.
In order to use files from your local computer and make them available for use to the docker container, you must first mount those files.
This is done with the -v flag that must be entered before any other flag. With -v you first specify where the file is stored in your computer. Then, after a :, you specify where you wish to mount that file in the container, which is going to be the argument that other flags that accept a path, i.e. --conf will take.
For example, suppose that the path to the configuration file on your computer is ~/Desktop/cnwan/conf/cnwan-reader-conf.yaml and that for simplicity you want to mount it in the container as /conf/cnwan-reader.yaml: then flag looks like this:
-v ~/Desktop/cnwan/conf/cnwan-reader-conf.yaml:/conf/cnwan-reader.yamlNow, when you use a flag to load that file, you must enter the mounted path, that is the one you wrote after : -- remember that -v must be entered before all other flags:
docker run \
-v ~/Desktop/cnwan/conf/cnwan-reader-conf.yaml:/conf/cnwan-reader.yaml\
cnwan/cnwan-reader \
[command] \
--conf /conf/cnwan-reader.yamlThis example follows the same requirements as this example -- replace cnwan/cnwan-reader with your image in case you have built it yourself:
docker run \
-v ~/Desktop/cnwan-credentials/serv-acc.json:/credentials/serv-acc.json \
cnwan/cnwan-reader \
servicedirectory \
--project my-project \
--region us-west2 \
--metadata-key cnwan.io/traffic-profile \
--interval 10 \
--adaptor-api localhost/cnwan/events \
--service-account ./credentials/serv-acc.jsonIf you want to use a configuration file, you can create the same configuration file as in the example. For your convenience:
adaptor: localhost:80/cnwan
metadataKeys:
- cnwan.io/traffic-profile
serviceRegistry:
gcpServiceDirectory:
pollInterval: 10
region: us-west2
projectID: my-project
serviceAccountPath: ./credentials/serv-acc.jsonImportant note: with docker you will need to mount both the configuration file and the service account: therefore serviceAccountPath needs to be modified with the mounted path, not the one on your computer: take a look at its value in the example yaml above.
Now, supposing that the configuration file is located at ~/Desktop/options/conf.yaml, run
docker run \
-v ~/Desktop/cnwan-credentials/serv-acc.json:/credentials/serv-acc.json \
-v ~/Desktop/options/conf.yaml:/options/conf.yaml \
cnwan/cnwan-reader servicedirectory --conf ./options/conf.yamlThis example follows the same requirements as this example -- replace cnwan/cnwan-reader with your image in case you have built it yourself:
docker run \
-v ~/Desktop/cnwan-credentials/aws-credentials:/credentials/aws-credentials \
cnwan/cnwan-reader \
poll cloudmap \
--region us-west-2 \
--metadata-keys cnwan.io/traffic-profile \
--adaptor-api localhost/cnwan/events \
--interval 10 \
--credentials-path /credentials/aws-credentialsThe command above assumes you want to use the default aws profile: append the following flag to the command above in case you want to use another one:
-e AWS_PROFILE=your_profileIf you want to use a configuration file, you can create the same configuration file as in the example. For your convenience:
adaptor: localhost:80/cnwan
metadataKeys:
- cnwan.io/traffic-profile
serviceRegistry:
awsCloudMap:
region: us-west-2
pollInterval: 10
credentialsPath: /credentials/aws-credentialsImportant note: with docker you will need to mount both the configuration file and the credentials file: therefore credentialsPath needs to be modified with the mounted path, not the one on your computer: take a look at its value in the example yaml above.
Now, supposing that the configuration file is located at ~/Desktop/options/conf.yaml, run
docker run \
-v ~/Desktop/cnwan-credentials/aws-credentials:/credentials/aws-credentials \
-v ~/Desktop/options/conf.yaml:/options/conf.yaml \
cnwan/cnwan-reader poll cloudmap --conf ./options/conf.yamlIn the following example, the CN-WAN Reader watches changes in etcd with the following requirements:
- The allowed services have at least the
cnwan.io/traffic-profilekey in their metadata. - Username is
adminand passwords5B7&$n_12C. - There is only one etcd node, on address
10.11.12.13on default port (2379). - The service registry has prefix
/service-registry/ - The endpoint of the adaptor is the default one (
http://localhost:80/cnwan/events). In such a case there is no need to use the--adaptor-apiflag, but here it is included for clarity.
docker run cnwan/cnwan-reader watch etcd \
--metadata-keys cnwan.io/traffic-profile \
--adaptor-api localhost/cnwan/events \
--username admin \
--password s5B7&$n_12C \
--endpoints 10.11.12.13:2379
--prefix /service-registry/