-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* imeplement plc4x * dump yaml.v2 => yaml.v3 * modify crd * Update azure-pipelines.yml for Azure Pipelines * Update codecov.yml * modify test * revert some file * add dockerfile and pipeline * fix pipeline * add deployment YAML file * fix parse param but dockerfile need to update * fix dockerfile * fix pipeline * dump go.mod * test in pipeline * Update azure-pipelines.yml * modify io/ioutil => io * add other protocol on plc4x * rename deployment file name * tiny change * tiny modify the file * fix pipeline * Revert "tiny modify the file" This reverts commit bc8a02e. * Revert "fix pipeline" This reverts commit 42bebf2. * tidy up * tidy fix
- Loading branch information
Showing
25 changed files
with
724 additions
and
303 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
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
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
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
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,35 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/edgenesis/shifu/pkg/deviceshifu/deviceshifubase" | ||
"github.com/edgenesis/shifu/pkg/deviceshifu/deviceshifuplc4x" | ||
|
||
"k8s.io/apimachinery/pkg/util/wait" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
func main() { | ||
deviceName := os.Getenv("EDGEDEVICE_NAME") | ||
namespace := os.Getenv("EDGEDEVICE_NAMESPACE") | ||
|
||
deviceShifuMetadata := &deviceshifubase.DeviceShifuMetaData{ | ||
Name: deviceName, | ||
ConfigFilePath: deviceshifubase.DeviceConfigmapFolderPath, | ||
KubeConfigPath: deviceshifubase.KubernetesConfigDefault, | ||
Namespace: namespace, | ||
} | ||
|
||
ds, err := deviceshifuplc4x.New(deviceShifuMetadata) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
|
||
err = ds.Start(wait.NeverStop) | ||
if err != nil { | ||
klog.Errorf("deviceshifu start default, error: %v", err) | ||
return | ||
} | ||
select {} | ||
} |
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,40 @@ | ||
# Build the manager binary | ||
FROM --platform=$BUILDPLATFORM golang:1.19.1 as builder | ||
|
||
WORKDIR /shifu | ||
|
||
ENV GO111MODULE=on | ||
|
||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY pkg/k8s pkg/k8s | ||
COPY cmd/deviceshifu/cmdplc4x cmd/deviceshifu/cmdplc4x | ||
COPY pkg/deviceshifu pkg/deviceshifu | ||
|
||
RUN apt-get update | ||
RUN apt-get install libpcap-dev -y | ||
|
||
RUN go mod download | ||
RUN mkdir -p /output/lib | ||
RUN cp $(whereis liblz4.so.1 | awk '{ print $2 }') /output/lib | ||
RUN cp $(whereis liblzma.so.5 | awk '{ print $2 }') /output/lib | ||
RUN cp $(whereis libzstd.so.1 | awk '{ print $2 }') /output/lib | ||
RUN cp $(whereis libdbus-1.so.3 | awk '{ print $2 }') /output/lib | ||
RUN cp $(whereis libpcap.so.0.8 | awk '{ print $2 }') /output/lib | ||
RUN cp $(whereis libsystemd.so.0 | awk '{ print $2 }') /output/lib | ||
RUN cp $(whereis libgcrypt.so.20 | awk '{ print $2 }') /output/lib | ||
RUN cp $(whereis libgpg-error.so.0 | awk '{ print $2 }') /output/lib | ||
|
||
# Build the Go app | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
RUN CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -v -o /output/deviceshifu cmd/deviceshifu/cmdplc4x/main.go | ||
|
||
FROM gcr.io/distroless/base | ||
WORKDIR / | ||
COPY --from=builder /output/deviceshifu deviceshifu | ||
COPY --from=builder /output/lib /lib | ||
|
||
USER 65532:65532 | ||
ENTRYPOINT ["/deviceshifu"] |
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
13 changes: 13 additions & 0 deletions
13
examples/plc4xDeviceShifu/deployment/plc4x_deviceshifu_configmap.yaml
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 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: plc4x-configmap | ||
namespace: deviceshifu | ||
data: | ||
driverProperties: | | ||
driverSku: testPlc4x | ||
driverImage: | ||
instructions: | | ||
instructions: | ||
telemetries: | | ||
telemetrySettings: |
36 changes: 36 additions & 0 deletions
36
examples/plc4xDeviceShifu/deployment/plc4x_deviceshifu_deployment.yaml
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,36 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: deviceshifu-plc4x-deployment | ||
name: deviceshifu-plc4x-deployment | ||
namespace: deviceshifu | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: deviceshifu-plc4x-deployment | ||
template: | ||
metadata: | ||
labels: | ||
app: deviceshifu-plc4x-deployment | ||
spec: | ||
containers: | ||
- image: edgehub/deviceshifu-http-plc4x:nightly | ||
name: deviceshifu-http | ||
ports: | ||
- containerPort: 8080 | ||
volumeMounts: | ||
- name: deviceshifu-config | ||
mountPath: "/etc/edgedevice/config" | ||
readOnly: true | ||
env: | ||
- name: EDGEDEVICE_NAME | ||
value: "edgedevice-plc4x" | ||
- name: EDGEDEVICE_NAMESPACE | ||
value: "devices" | ||
volumes: | ||
- name: deviceshifu-config | ||
configMap: | ||
name: plc4x-configmap | ||
serviceAccountName: edgedevice-sa |
16 changes: 16 additions & 0 deletions
16
examples/plc4xDeviceShifu/deployment/plc4x_deviceshifu_service.yaml
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,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: deviceshifu-plc4x-deployment | ||
name: deviceshifu-plc4x | ||
namespace: deviceshifu | ||
spec: | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
targetPort: 8080 | ||
selector: | ||
app: deviceshifu-plc4x-deployment | ||
type: LoadBalancer | ||
|
13 changes: 13 additions & 0 deletions
13
examples/plc4xDeviceShifu/deployment/plc4x_edgedevice.yaml
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 @@ | ||
apiVersion: shifu.edgenesis.io/v1alpha1 | ||
kind: EdgeDevice | ||
metadata: | ||
name: edgedevice-plc4x | ||
namespace: devices | ||
spec: | ||
sku: "testPlc4x" | ||
connection: Ethernet | ||
address: 192.168.0.1 #change this accordingly | ||
protocol: PLC4X | ||
protocolSettings: | ||
PLC4XSetting: | ||
protocol: s7 |
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
Oops, something went wrong.