EdgeX Foundry Go Implementation
repository·main·Indexed 23 days ago
https://github.com/edgexfoundry/edgex-goGo implementation of EdgeX Foundry microservices, providing build, containerization, and bootstrapping logic for the open-source IoT edge computing framework. Includes documentation for the Command Service, security utilities like secrets-config, security-secretstore-setup, and security-proxy-setup, as well as token providers such as SPIFFE and security-file-token-provider.
What's inside edgex-go
- The Core Data service provides a centralized persistence facility for data readings collected by devices and sensors. It allows device services to store sensor and device data locally on the edge system (such as a gateway) until the data can be moved 'north' to enterprise and cloud systems.
What is the EdgeX Foundry Command Service?
mainThe Command Service acts as a conduit for other services to trigger actions on devices or sensors through their managing device services. It provides an API to retrieve lists of available commands for all devices or for a specific device.
Commands are categorized into two groups:
- Gets: Issued to a device/sensor to retrieve the current value of a particular attribute (e.g., current temperature from a thermostat or the on/off status of a light).
- Puts: Issued to a device/sensor to change its current state or status (e.g., setting a motor's speed in RPMs or adjusting a dimmer light's brightness).
What is the EdgeX Foundry Core Keeper Service?
mainCore Keeper is a lightweight configuration and registry service designed to replace Consul within the EdgeX architecture. It leverages Redis as its persistent data store and implements configuration and registry abstractions by utilizing thego-mod-configurationandgo-mod-registrymodules.What is the security-proxy-setup container?
mainThe
security-proxy-setupcontainer is used to configure the NGINX reverse proxy and contains a copy of thesecrets-configutility.Note for users migrating from EdgeX 3.0 or earlier: The
security-proxy-setupbinary that previously configured the Kong reverse proxy has been removed in favor of this NGINX-based approach.What is the Core Metadata Service
mainThe Core Metadata Service is responsible for retaining and providing access to knowledge about devices and sensors connected to EdgeX.
Key responsibilities include:
- Managing information about connected devices and sensors (type, organization of reported data, and command capabilities).
- Managing configuration metadata used by other gateway services, such as cleanup schedules and hardware configuration (e.g., Wi-Fi connection info, MQTT queues).
Note: Non-device metadata may be stored in different databases or managed by other services depending on the specific implementation.
Access EdgeX when security components are enabled
mainStarting with the Fuji release, enhanced security features are enabled by default, managed by
Security-secretstore-setupandSecurity-proxy-setup.Note: In the Ireland release,
security-secrets-setupis no longer an internal service because service-to-service communication does not run in TLS by default within a single box.When security is enabled, you must follow these rules:
- Access Tokens: You must create an access token and associate every REST request with it.
- Proxy Access: Exported external ports (e.g.,
59880,59881) are inaccessible. All REST requests must be routed through the proxy, which redirects them to individual microservices on your behalf.
Refer to
SECURITY.mdfor specific steps on token creation and usage.What the Core Common Config Bootstrapper Service does
mainThe Core Common Config Bootstrapper is a service that pushes common settings into the EdgeX Configuration Provider upon startup. It also provides a specific override flag common to all services that allows you to force a re-push of the configuration into the Configuration Provider.Install and Deploy Core Keeper via Docker
mainYou can containerize Core Keeper using the included Dockerfile. Before building the image, you must run
make prepareto update dependencies.Prerequisites:
- Docker must be installed on your system.
Execution Steps:
- Build the Docker image using
make. - Create a container from the image (requires specifying a name and network).
- Start the container.
Note: EdgeX recommends using Docker Compose for managing containers, networks, and dependencies instead of manual Docker commands.
cd $GOPATH/src go get github.com/edgexfoundry/edgex-go cd $GOPATH/src/github.com/edgexfoundry/edgex-go # To create the Docker image sudo make docker_core_keeper # To create a container from the image sudo docker create --name "[DOCKER_CONTAINER_NAME]" --network "[DOCKER_NETWORK]" [DOCKER_IMAGE_NAME] # To run the container sudo docker start [DOCKER_CONTAINER_NAME]Install and build EdgeX as native Go binaries
mainEdgeX is organized as Go Modules.
Prerequisites
- Go Runtime: Target version is
v1.18.x. Minimum supported version isv1.18.x.
Installation
You can clone the repository and build directly:
git clone git@github.com:edgexfoundry/edgex-go.git cd edgex-go make buildAlternatively, if you prefer using
$GOPATH:GO111MODULE=on && export GO111MODULE go get github.com/edgexfoundry/edgex-go cd $GOPATH/src/github.com/edgexfoundry/edgex-go make build- Go Runtime: Target version is
Override default Redis ACL configuration for debugging
mainThe
security-bootstrapperservice'sconfigureRedisfunction generates an ACL configuration file for the Redisdefaultuser namededgex_redis_acl.conf. If you need to test different ACL rules (e.g., enablingdangerouscommands likeINFO,MONITOR,BGSAVE, orFLUSHDBfor debugging), you can override the built-in behavior using one of two methods:Method 1: Use a custom Redis configuration file
You can provide your own
redis.confthat points to a different ACL file name.- Create a custom ACL file (e.g.,
developer-acl.conf) containing your desired rules. Use the+directive to add commands. Note: You must still use the{{.HashedRedisPwd}}placeholder so the password can be dynamically populated from the Vault secretstore. Example rule:user default on allkeys +@all -@dangerous #_{{.HashedRedisPwd}}_ +INFO +MONITOR +BGSAVE +FLUSHDB - Update your
redis.confto point to this new file. - Modify the
databaseservice in yourdocker-composefile to use your custom config file in the entrypoint script:exec /usr/local/bin/docker-entrypoint.sh redis-server developer_redis.conf
Method 2: Modify the existing ACL file directly
If you have the necessary permissions to update the file, you can modify
edgex_redis_acl.confdirectly. After making changes, use the RedisACL LOADorACL SAVEcommands to apply and persist the new rules.- Create a custom ACL file (e.g.,
Install and Deploy Command Service natively
mainTo run the Command Service as a native binary, you must first ensure ZeroMQ is installed on your system.
Note: ZeroMQ setup is not supported on Windows platforms.
Follow these steps to fetch the code, prepare dependencies, build, and execute the microservice:
cd $GOPATH/src go get github.com/edgexfoundry/edgex-go cd $GOPATH/src/github.com/edgexfoundry/edgex-go # pull the 3rd party / vendor packages make prepare # build the microservice make core-command # get to the command microservice executable cd cmd/core-command # run the microservice (may require other dependent services to run correctly) ./core-commandBuild the security-secretstore-setup service
mainYou can build the
security-secretstore-setup(also known asedgex-vault-worker) binary using the Makefile located in the root directory of the repository. A successful build will produce an executable in thecmd/security-secretstore-setup/directory.make cmd/security-secretstore-setup/security-secretstore-setup