-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add tink-agent binary #762
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,10 @@ | ||
FROM alpine:3.15 | ||
|
||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
RUN apk add --no-cache --update --upgrade ca-certificates | ||
|
||
COPY bin/tink-agent-${TARGETOS}-${TARGETARCH} /usr/bin/tink-agent | ||
|
||
ENTRYPOINT ["/usr/bin/tink-agent"] |
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 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/tinkerbell/tink/internal/cli" | ||
) | ||
|
||
func main() { | ||
if err := cli.NewAgent().Execute(); 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/go-logr/zapr" | ||
"github.com/spf13/cobra" | ||
"github.com/tinkerbell/tink/internal/agent" | ||
"github.com/tinkerbell/tink/internal/agent/runtime" | ||
"github.com/tinkerbell/tink/internal/agent/transport" | ||
"github.com/tinkerbell/tink/internal/proto/workflow/v2" | ||
"go.uber.org/zap" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
// NewAgent builds a command that launches the agent component. | ||
func NewAgent() *cobra.Command { | ||
var opts struct { | ||
AgentID string | ||
TinkServerAddr string | ||
} | ||
|
||
// TODO(chrisdoherty4) Handle signals | ||
cmd := cobra.Command{ | ||
Use: "tink-agent", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
zl, err := zap.NewProduction() | ||
if err != nil { | ||
return fmt.Errorf("init logger: %w", err) | ||
} | ||
logger := zapr.NewLogger(zl) | ||
|
||
rntime, err := runtime.NewDocker() | ||
if err != nil { | ||
return fmt.Errorf("create runtime: %w", err) | ||
} | ||
|
||
conn, err := grpc.DialContext(cmd.Context(), opts.TinkServerAddr) | ||
if err != nil { | ||
return fmt.Errorf("dial tink server: %w", err) | ||
} | ||
defer conn.Close() | ||
trnport := transport.NewGRPC(logger, workflow.NewWorkflowServiceClient(conn)) | ||
|
||
return (&agent.Agent{ | ||
Log: logger, | ||
ID: opts.AgentID, | ||
Transport: trnport, | ||
Runtime: rntime, | ||
}).Start(cmd.Context()) | ||
}, | ||
} | ||
|
||
flgs := cmd.Flags() | ||
flgs.StringVar(&opts.AgentID, "agent-id", "", "An ID that uniquely identifies the agent instance") | ||
flgs.StringVar(&opts.TinkServerAddr, "tink-server-addr", "127.0.0.1:42113", "Tink server address") | ||
|
||
return &cmd | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not sure about the option here. It might be better to use
grpc-addr
complimenting the idea that we could have multiple transports. Introducing the file transport may inform us better.