-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue open-horizon#3982 - MMSinCluster: add MMS example operator and …
…services Signed-off-by: Le Zhang <[email protected]>
- Loading branch information
1 parent
65f1e35
commit b139c77
Showing
14 changed files
with
468 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk --no-cache --update add jq bash | ||
|
||
COPY *.sh / | ||
WORKDIR / | ||
CMD /service.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Make targets for building the IBM example hello mms consumer service for edge cluster | ||
|
||
# This imports the variables from horizon/hzn.json. You can ignore these lines, but do not remove them. | ||
-include horizon/.hzn.json.tmp.mk | ||
|
||
# Default ARCH to the architecture of this machines (as horizon/golang describes it) | ||
export ARCH ?= $(shell hzn architecture) | ||
|
||
# Build the docker image for the current architecture | ||
build: | ||
docker build --platform linux/$(ARCH) -t $(DOCKER_IMAGE_BASE)_$(ARCH):$(SERVICE_VERSION) -f ./Dockerfile . | ||
|
||
# Push the docker image | ||
push: | ||
docker push $(DOCKER_IMAGE_BASE)_$(ARCH):$(SERVICE_VERSION) | ||
|
||
clean: | ||
-docker rmi $(DOCKER_IMAGE_BASE)_$(ARCH):$(SERVICE_VERSION) 2> /dev/null || : | ||
|
||
# This imports the variables from horizon/hzn.cfg. You can ignore these lines, but do not remove them. | ||
horizon/.hzn.json.tmp.mk: horizon/hzn.json | ||
@ hzn util configconv -f $< > $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"HZN_ORG_ID": "IBM", | ||
"MetadataVars": { | ||
"DOCKER_IMAGE_BASE": "openhorizon/ibm.hello-k8s-mms-consumer", | ||
"SERVICE_NAME": "ibm.hello-k8s-mms-consumer", | ||
"SERVICE_VERSION": "1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
OBJECT_TYPES_STRING=$MMS_OBJECT_TYPES # operator need to put MMS_OBJECT_TYPES in the deployment as env from the userinput configmap, eg: "model model1 model2" | ||
OBJECT_ID=config.json # this is the file we are watching in this example mms consumer service | ||
# this file is in shared volume. Operator should bind as /ess-store/<objectType>-<objectID> | ||
|
||
echo "Object types to check: $OBJECT_TYPES_STRING" | ||
IFS=' ' read -r -a objecttypes <<< "$OBJECT_TYPES_STRING" | ||
|
||
while true; do | ||
for objecttype in "${objecttypes[@]}" | ||
do | ||
MMS_FILE_NAME="/ess-store/$objecttype-$OBJECT_ID" | ||
echo "MMS_FILE_NAME: $MMS_FILE_NAME" | ||
if [[ -f $MMS_FILE_NAME ]]; then | ||
eval $(jq -r 'to_entries[] | .key + "=\"" + .value + "\""' $MMS_FILE_NAME) | ||
echo "$MMS_FILE_NAME: Hello from ${HW_WHO} from objectType: $objecttype, objectId: $OBJECT_ID!" | ||
else | ||
echo "file $MMS_FILE_NAME not found" | ||
fi | ||
|
||
done | ||
sleep 20 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk --no-cache --update add curl | ||
|
||
COPY start.sh / | ||
COPY service /usr/local/bin/ | ||
|
||
RUN mkdir -p /ess-store | ||
|
||
WORKDIR / | ||
CMD /start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Makefile for hello mms helper service for k8s | ||
|
||
# This imports the variables from horizon/hzn.json. You can ignore these lines, but do not remove them. | ||
-include horizon/.hzn.json.tmp.mk | ||
|
||
# Default ARCH to the architecture of this machines (as horizon/golang describes it) | ||
export ARCH ?= $(shell hzn architecture) | ||
|
||
# Build the docker image for the current architecture | ||
build: | ||
docker build --platform linux/$(ARCH) -t $(DOCKER_IMAGE_BASE)_$(ARCH):$(SERVICE_VERSION) -f ./Dockerfile . | ||
|
||
service: service.go | ||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build service.go | ||
|
||
# Push the docker image | ||
push: | ||
docker push $(DOCKER_IMAGE_BASE)_$(ARCH):$(SERVICE_VERSION) | ||
|
||
clean: | ||
-docker rmi $(DOCKER_IMAGE_BASE)_$(ARCH):$(SERVICE_VERSION) 2> /dev/null || : | ||
|
||
# This imports the variables from horizon/hzn.cfg. You can ignore these lines, but do not remove them. | ||
horizon/.hzn.json.tmp.mk: horizon/hzn.json | ||
@ hzn util configconv -f $< > $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"HW_WHO": "k8sMMS" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module github.com/open-horizon/examples/edge/services/hellok8sMMS/k8s_mms_helper | ||
|
||
go 1.20 | ||
|
||
require ( | ||
github.com/golang/glog v1.2.0 | ||
github.com/open-horizon/edge-sync-service v1.10.1 | ||
) | ||
|
||
require ( | ||
github.com/open-horizon/edge-utilities v0.0.0-20190711093331-0908b45a7152 // indirect | ||
golang.org/x/sync v0.6.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= | ||
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/open-horizon/edge-sync-service v1.10.1 h1:+b+YTPqyxyhieixaFoV03Bs0Fmy5HGZtOIkhMG8OkMo= | ||
github.com/open-horizon/edge-sync-service v1.10.1/go.mod h1:yCK3f59UHnoLU0Tz2/RhuLGygJFlZoqlP8kpmQ3Gqd4= | ||
github.com/open-horizon/edge-utilities v0.0.0-20190711093331-0908b45a7152 h1:YEvNOMo3ANOQ3AwsU0cCcBA4nKHDLUlyUCRWk5rBf68= | ||
github.com/open-horizon/edge-utilities v0.0.0-20190711093331-0908b45a7152/go.mod h1:YCsJWhuG0VERquI0geFKoneCSOVAyMdSmylGz5OlZdE= | ||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= | ||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= |
4 changes: 4 additions & 0 deletions
4
edge/services/hellok8sMMS/k8s_mms_helper/horizon/.hzn.json.tmp.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export HZN_ORG_ID=anaxsquad | ||
export DOCKER_IMAGE_BASE=quay.io/zhangle/hello-k8s-mms-helper | ||
export SERVICE_NAME=hello-k8s-mms-helper | ||
export SERVICE_VERSION=1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"HZN_ORG_ID": "IBM", | ||
"MetadataVars": { | ||
"DOCKER_IMAGE_BASE": "openhorizon/ibm.hello-k8s-mms-helper", | ||
"SERVICE_NAME": "ibm.hello-k8s-mms-helper", | ||
"SERVICE_VERSION": "1.0.0" | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.