-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Core Keeper implementation #10
base: edgex-go-v3.2.0-dev.10
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# Copyright (C) 2024 IOTech Ltd | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ---------------------------------------------------------------------------------- | ||
|
||
# Docker image for Golang Core Keeper micro service | ||
ARG BUILDER_BASE=golang:1.21-alpine3.18 | ||
FROM ${BUILDER_BASE} AS builder | ||
|
||
WORKDIR /edgex-go | ||
|
||
# The main mirrors are giving us timeout issues on builds periodically. | ||
# So we can try these. | ||
|
||
RUN sed -e 's/dl-cdn[.]alpinelinux.org/dl-4.alpinelinux.org/g' -i~ /etc/apk/repositories | ||
|
||
RUN apk add --update --no-cache make git | ||
|
||
COPY go.mod vendor* ./ | ||
RUN [ ! -d "vendor" ] && go mod download all || echo "skipping..." | ||
|
||
COPY . . | ||
RUN make cmd/core-keeper/core-keeper | ||
|
||
#Next image - Copy built Go binary into new workspace | ||
FROM alpine:3.18 | ||
|
||
LABEL license='SPDX-License-Identifier: Apache-2.0' \ | ||
copyright='Copyright (c) 2024: IOTech' | ||
|
||
ENV APP_PORT=59890 | ||
#expose core keeper port | ||
EXPOSE $APP_PORT | ||
|
||
# The main mirrors are giving us timeout issues on builds periodically. | ||
# So we can try these. | ||
RUN sed -e 's/dl-cdn[.]alpinelinux.org/dl-4.alpinelinux.org/g' -i~ /etc/apk/repositories | ||
|
||
RUN apk add --update --no-cache dumb-init | ||
COPY --from=builder /edgex-go/Attribution.txt / | ||
COPY --from=builder /edgex-go/cmd/core-keeper/core-keeper / | ||
COPY --from=builder /edgex-go/cmd/core-keeper/res/configuration.toml /res/configuration.toml | ||
|
||
ENTRYPOINT ["/core-keeper"] | ||
CMD ["--confdir=/res"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Copyright (C) 2024 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/edgexfoundry/edgex-go/internal/core/keeper" | ||
|
||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
func main() { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
keeper.Main(ctx, cancel, echo.New()) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Writable: | ||
LogLevel: INFO | ||
InsecureSecrets: | ||
mqtt: | ||
SecretName: mqtt | ||
SecretData: | ||
username: "" | ||
password: "" | ||
cacert: "" | ||
clientcert: "" | ||
clientkey: "" | ||
DB: | ||
SecretName: "redisdb" | ||
SecretData: | ||
username: "" | ||
password: "" | ||
Service: | ||
Host: localhost | ||
Port: 59890 | ||
StartupMsg: "This is the Core Keeper Microservice" | ||
HealthCheckInterval: "10s" | ||
ServerBindAddr: "" # Leave blank so default to Host value unless different value is needed. | ||
MaxResultCount: 1024 | ||
MaxRequestSize: 0 # Not currently used. Defines the maximum size of http request body in bytes | ||
RequestTimeout: "5s" | ||
EnableNameFieldEscape: false # The name field escape could allow the system to use special or Chinese characters in the different name fields, including device, profile, and so on. If the EnableNameFieldEscape is false, some special characters might cause system error. TODO: This is set to false by default to avoid breaking change and will be removed in EdgeX 4.0 | ||
CORSConfiguration: | ||
EnableCORS: false | ||
CORSAllowCredentials: false | ||
CORSAllowedOrigin: "https://localhost" | ||
CORSAllowedMethods: "GET, POST, PUT, PATCH, DELETE" | ||
CORSAllowedHeaders: "Authorization, Accept, Accept-Language, Content-Language, Content-Type, X-Correlation-ID" | ||
CORSExposeHeaders: "Cache-Control, Content-Language, Content-Length, Content-Type, Expires, Last-Modified, Pragma, X-Correlation-ID" | ||
CORSMaxAge: 3600 | ||
Database: | ||
Host: "localhost" | ||
Port: 6379 | ||
Timeout: "5s" | ||
Type: "redisdb" | ||
MessageBus: | ||
Protocol: "redis" | ||
Host: "localhost" | ||
Port: 6379 | ||
Type: "redis" | ||
AuthMode: "usernamepassword" # required for redis MessageBus (secure or insecure). | ||
SecretName: "redisdb" | ||
BaseTopicPrefix: "edgex/configs" # /<key> will be added to this Base Topic prefix | ||
Optional: | ||
# Default MQTT Specific options that need to be here to enable environment variable overrides of them | ||
Qos: "0" # Quality of Service values are 0 (At most once), 1 (At least once) or 2 (Exactly once) | ||
KeepAlive: "10" # Seconds (must be 2 or greater) | ||
Retained: "false" | ||
AutoReconnect: "true" | ||
ConnectTimeout: "5" # Seconds | ||
SkipCertVerify: "false" | ||
# Additional Default NATS Specific options that need to be here to enable environment variable overrides of them | ||
Format: "nats" | ||
RetryOnFailedConnect: "true" | ||
QueueGroup: "" | ||
Durable: "" | ||
AutoProvision: "true" | ||
Deliver: "new" | ||
DefaultPubRetryAttempts: "2" | ||
Subject: "edgex/#" # Required for NATS JetStream only for stream auto-provisioning | ||
ClientId: core-keeper | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ require ( | |
github.com/google/uuid v1.5.0 | ||
github.com/labstack/echo/v4 v4.11.4 | ||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 | ||
github.com/spf13/cast v1.6.0 | ||
github.com/spiffe/go-spiffe/v2 v2.1.6 | ||
github.com/stretchr/testify v1.8.4 | ||
golang.org/x/crypto v0.18.0 | ||
|
@@ -79,3 +80,11 @@ require ( | |
google.golang.org/grpc v1.56.3 // indirect | ||
google.golang.org/protobuf v1.30.0 // indirect | ||
) | ||
|
||
replace github.com/edgexfoundry/go-mod-core-contracts/v3 => github.com/jackchenjc/go-mod-core-contracts/v3 v3.2.0-dev.4.0.20240130071054-92a2e48bc6ca | ||
|
||
replace github.com/edgexfoundry/go-mod-registry/v3 => github.com/jackchenjc/go-mod-registry/v3 v3.2.0-dev.1.0.20240130024331-d0f728a41496 | ||
|
||
replace github.com/edgexfoundry/go-mod-configuration/v3 => github.com/jackchenjc/go-mod-configuration/v3 v3.2.0-dev.1.0.20240130054648-e25c4056b9df | ||
|
||
replace github.com/edgexfoundry/go-mod-bootstrap/v3 => github.com/jackchenjc/go-mod-bootstrap/v3 v3.2.0-dev.10.0.20240125072932-e0925013f378 | ||
Comment on lines
+84
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this Keeper Service need modified versions of the go-mods? I expect the go-mods to be modified for the new Client, not the Service. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# EdgeX Foundry Core Keeper Service | ||
[](LICENSE) | ||
|
||
Core Keeper is a lightweight configuration and registry service that is aimed to replace Consul in the EdgeX architecture. It uses Redis from the existing EdgeX service architecture as the data persistent store, and implements the configuration and registry abstractions by adopting the go-mod-configuration and go-mod-registry modules from EdgeX. | ||
|
||
# Install and Deploy Native # | ||
|
||
### Installation and Execution ### | ||
To fetch the code and build the microservice execute the following: | ||
|
||
``` | ||
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 keeper | ||
# get to the command microservice executable | ||
cd cmd/core-keeper | ||
# run the microservice (may require other dependent services to run correctly) | ||
./core-keeper | ||
``` | ||
|
||
# Install and Deploy via Docker Container # | ||
This project has facilities to create and run Docker containers. A Dockerfile is included in the repo. Make sure you have already run make prepare to update the dependencies. To do a Docker build using the included Docker file, run the following: | ||
|
||
### Prerequisites ### | ||
See https://docs.docker.com/install/ to learn how to obtain and install Docker. | ||
|
||
### Installation and Execution ### | ||
|
||
``` | ||
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 containter 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] | ||
``` | ||
|
||
*Note* - creating and running the container above requires Docker network setup, may require dependent containers to be setup on that network, and appropriate port access configuration (among other start up parameters). For this reason, EdgeX recommends use of Docker Compose for pulling, building, and running containers. See The Getting Started Guides for more detail. | ||
|
||
|
||
## Community | ||
- Chat: [https://edgexfoundry.slack.com](https://join.slack.com/t/edgexfoundry/shared_invite/enQtNDgyODM5ODUyODY0LWVhY2VmOTcyOWY2NjZhOWJjOGI1YzQ2NzYzZmIxYzAzN2IzYzY0NTVmMWZhZjNkMjVmODNiZGZmYTkzZDE3MTA) | ||
- Mailing lists: https://lists.edgexfoundry.org/mailman/listinfo | ||
|
||
## License | ||
[Apache-2.0](LICENSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yaml file now.