-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from lostcharlie/merge-modules
Combine all components into "fabedge-node"
- Loading branch information
Showing
20 changed files
with
208 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM golang:1.17.13 as builder | ||
COPY . /fabedge | ||
RUN cd /fabedge && make node QUICK=1 CGO_ENABLED=0 GOPROXY=https://goproxy.cn,direct | ||
|
||
FROM fabedge/cni-plugins:v1.4.0 as cni-plugins | ||
FROM fabedge/base-image:0.1.0 | ||
|
||
COPY --from=builder /fabedge/_output/fabedge-node /usr/local/bin/node | ||
COPY --from=builder /fabedge/build/node/*.sh / | ||
COPY --from=cni-plugins /plugins/ /plugins | ||
|
||
RUN apk --update add keepalived curl && \ | ||
rm -rf /var/cache/apk/* && \ | ||
chmod +x /entrypoint.sh /check-connector-leader.sh | ||
|
||
ENTRYPOINT ["/entrypoint.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,13 @@ | ||
#!/usr/bin/env sh | ||
is_leader=`curl -s http://127.0.0.1:30306/is-leader` | ||
exit_code=$? | ||
|
||
if [ $exit_code != 0 ]; then | ||
exit $exit_code | ||
fi | ||
|
||
if [ $is_leader == "true" ]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |
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,10 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo 'select between the two modes of iptables ("legacy" and "nft")' | ||
/iptables-wrapper-installer.sh | ||
|
||
cmd="/usr/local/bin/node $@" | ||
echo "entrypoint: run command: $cmd" | ||
|
||
exec $cmd |
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,89 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/fabedge/fabedge/pkg/agent" | ||
"github.com/fabedge/fabedge/pkg/cloud-agent" | ||
"github.com/fabedge/fabedge/pkg/common/about" | ||
"github.com/fabedge/fabedge/pkg/connector" | ||
"github.com/fabedge/fabedge/pkg/operator" | ||
logutil "github.com/fabedge/fabedge/pkg/util/log" | ||
flag "github.com/spf13/pflag" | ||
"os" | ||
"time" | ||
) | ||
|
||
func main() { | ||
var component string | ||
|
||
fs := flag.CommandLine | ||
fs.StringVar(&component, "component", "", "the component to initiate") | ||
|
||
// common | ||
var cniType string | ||
var leaseDuration time.Duration | ||
var renewDeadline time.Duration | ||
var retryPeriod time.Duration | ||
var syncPeriod time.Duration | ||
var tunnelInitTimeout uint | ||
|
||
// cloud-agent | ||
var initMembers []string | ||
fs.StringSliceVar(&initMembers, "connector-node-addresses", []string{}, "internal ip address of all connector nodes") | ||
|
||
// common | ||
fs.StringVar(&cniType, "cni-type", "", "The CNI name in your kubernetes cluster") | ||
fs.DurationVar(&leaseDuration, "leader-lease-duration", 15*time.Second, "The duration that non-leader candidates will wait to force acquire leadership") | ||
fs.DurationVar(&renewDeadline, "leader-renew-deadline", 10*time.Second, "The duration that the acting controlplane will retry refreshing leadership before giving up") | ||
fs.DurationVar(&retryPeriod, "leader-retry-period", 2*time.Second, "The duration that the LeaderElector clients should wait between tries of actions") | ||
fs.UintVar(&tunnelInitTimeout, "tunnel-init-timeout", 10, "The timeout of tunnel initiation. Uint: second") | ||
// agent: 30s, connector: 5m | ||
fs.DurationVar(&syncPeriod, "sync-period", 30*time.Second, "The period to synchronize network configuration") | ||
|
||
// operator | ||
operatorConfig := &operator.Options{} | ||
operatorConfig.AddFlags(fs) | ||
|
||
// connector | ||
connectorConfig := &connector.Config{} | ||
connectorConfig.AddFlags(fs) | ||
|
||
// agent | ||
agentConfig := &agent.Config{} | ||
agentConfig.AddFlags(fs) | ||
|
||
logutil.AddFlags(fs) | ||
about.AddFlags(fs) | ||
|
||
flag.Parse() | ||
|
||
fmt.Printf("component: %s\n", component) | ||
|
||
switch component { | ||
case "cloud-agent": | ||
cloud_agent.Execute(initMembers) | ||
case "operator": | ||
operatorConfig.CNIType = cniType | ||
operatorConfig.ManagerOpts.LeaseDuration = &leaseDuration | ||
operatorConfig.ManagerOpts.RenewDeadline = &renewDeadline | ||
operatorConfig.ManagerOpts.RetryPeriod = &retryPeriod | ||
if err := operator.Execute(operatorConfig); err != nil { | ||
os.Exit(1) | ||
} | ||
case "connector": | ||
connectorConfig.CNIType = cniType | ||
connectorConfig.SyncPeriod = syncPeriod | ||
connectorConfig.InitMembers = initMembers | ||
connectorConfig.LeaderElection.LeaseDuration = leaseDuration | ||
connectorConfig.LeaderElection.RenewDeadline = renewDeadline | ||
connectorConfig.LeaderElection.RetryPeriod = retryPeriod | ||
connectorConfig.TunnelInitTimeout = tunnelInitTimeout | ||
connector.Execute(connectorConfig) | ||
case "agent": | ||
agentConfig.SyncPeriod = syncPeriod | ||
agentConfig.TunnelInitTimeout = tunnelInitTimeout | ||
if err := agent.Execute(agentConfig); err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.