-
Notifications
You must be signed in to change notification settings - Fork 44
Single Node deployment with bootstrap-in-place #51
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
Merged
openshift-merge-robot
merged 5 commits into
openshift:master
from
eranco74:bootstrap-in-place-go-mod
Feb 8, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
085f84b
Wait for api after starting bootstrap control plane
tsorya a5f0a12
Retrun an error if waiting for assetsDone timed out.
eranco74 2ab720b
Added a flag for setting the assets creation timeout
eranco74 52d7a6f
Adding bootstrap-in-place functionality
eranco74 cf4ffde
Updated vendoring
eranco74 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 hidden or 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,65 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "errors" | ||
|
|
||
| "github.com/openshift/cluster-bootstrap/pkg/bootstrapinplace" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var ( | ||
| CmdBootstrapInPlace = &cobra.Command{ | ||
| Use: "bootstrap-in-place", | ||
| Short: "Create Ignition based on Fedora CoreOS Config", | ||
| Long: "", | ||
| PreRunE: validateBootstrapInPlaceOpts, | ||
| RunE: runCmdBootstrapInPlace, | ||
| SilenceUsage: true, | ||
| } | ||
|
|
||
| bootstrapInPlaceOpts struct { | ||
| assetDir string | ||
| ignitionPath string | ||
| input string | ||
| Strict bool | ||
| Pretty bool | ||
| } | ||
| ) | ||
|
|
||
| func init() { | ||
| cmdRoot.AddCommand(CmdBootstrapInPlace) | ||
| CmdBootstrapInPlace.Flags().BoolVarP(&bootstrapInPlaceOpts.Strict, "strict", "s", true, "fail on any warning") | ||
| CmdBootstrapInPlace.Flags().BoolVarP(&bootstrapInPlaceOpts.Pretty, "pretty", "p", true, "output formatted json") | ||
| CmdBootstrapInPlace.Flags().StringVar(&bootstrapInPlaceOpts.input, "input", "", "fcc input file path") | ||
| CmdBootstrapInPlace.Flags().StringVar(&bootstrapInPlaceOpts.ignitionPath, "output", "o", "Ignition output file path") | ||
| CmdBootstrapInPlace.Flags().StringVarP(&bootstrapInPlaceOpts.assetDir, "asset-dir", "d", "", "allow embedding local files from this directory") | ||
| } | ||
|
|
||
| func runCmdBootstrapInPlace(cmd *cobra.Command, args []string) error { | ||
| bip, err := bootstrapinplace.NewBootstrapInPlaceCommand(bootstrapinplace.BootstrapInPlaceConfig{ | ||
| AssetDir: bootstrapInPlaceOpts.assetDir, | ||
| IgnitionPath: bootstrapInPlaceOpts.ignitionPath, | ||
| Input: bootstrapInPlaceOpts.input, | ||
| Strict: bootstrapInPlaceOpts.Strict, | ||
| Pretty: bootstrapInPlaceOpts.Pretty, | ||
| }) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return bip.Create() | ||
| } | ||
|
|
||
| func validateBootstrapInPlaceOpts(cmd *cobra.Command, args []string) error { | ||
| if bootstrapInPlaceOpts.ignitionPath == "" { | ||
| return errors.New("missing required flag: --output") | ||
| } | ||
| if bootstrapInPlaceOpts.assetDir == "" { | ||
| return errors.New("missing required flag: --asset-dir") | ||
| } | ||
| if bootstrapInPlaceOpts.input == "" { | ||
| return errors.New("missing required flag: --input") | ||
| } | ||
| return nil | ||
| } |
This file contains hidden or 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 hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,73 @@ | ||
| // Copyright 2019 Red Hat, Inc | ||
|
|
||
| package bootstrapinplace | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "io/ioutil" | ||
| "os" | ||
|
|
||
| "github.com/coreos/fcct/config" | ||
| fcctCommon "github.com/coreos/fcct/config/common" | ||
| ) | ||
|
|
||
| func fail(format string, args ...interface{}) { | ||
| fmt.Printf(format, args...) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| type BootstrapInPlaceConfig struct { | ||
| AssetDir string | ||
| IgnitionPath string | ||
| Input string | ||
| Strict bool | ||
| Pretty bool | ||
| } | ||
| type BootstrapInPlaceCommand struct { | ||
| config BootstrapInPlaceConfig | ||
| } | ||
|
|
||
| func NewBootstrapInPlaceCommand(config BootstrapInPlaceConfig) (*BootstrapInPlaceCommand, error) { | ||
| return &BootstrapInPlaceCommand{ | ||
| config: config, | ||
| }, nil | ||
| } | ||
|
|
||
| // Creating master ignition that will be used by node after reboot | ||
| // Using fcct tool (tool that takes yaml and according to it creates ignition): | ||
| // 1. Read actions yaml that has all the data needed by fcct to create master.ign | ||
| // 2. Create ignition data | ||
| // 3. Write created data to file | ||
| func (i *BootstrapInPlaceCommand) Create() error { | ||
| infile, err := os.Open(i.config.Input) | ||
| if err != nil { | ||
| fail("Error occurred while trying to open %s: %v\n", i.config.Input, err) | ||
| } | ||
| defer infile.Close() | ||
|
|
||
| dataIn, err := ioutil.ReadAll(infile) | ||
| if err != nil { | ||
| fail("Error occurred while trying to read %s: %v\n", infile.Name(), err) | ||
| } | ||
|
|
||
| dataOut, r, err := config.TranslateBytes(dataIn, fcctCommon.TranslateBytesOptions{ | ||
| TranslateOptions: fcctCommon.TranslateOptions{FilesDir: i.config.AssetDir}, | ||
| Pretty: i.config.Pretty, | ||
| Strict: i.config.Strict}, | ||
| ) | ||
| fmt.Println(r.String()) | ||
| if err != nil { | ||
| fail("Error translating config: %v\n", err) | ||
| } | ||
|
|
||
| outfile, err := os.OpenFile(i.config.IgnitionPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) | ||
| if err != nil { | ||
| fail("Failed to open %s: %v\n", i.config.IgnitionPath, err) | ||
| } | ||
| defer outfile.Close() | ||
|
|
||
| if _, err := outfile.Write(append(dataOut, '\n')); err != nil { | ||
| fail("Failed to write config to %s: %v\n", outfile.Name(), err) | ||
| } | ||
| return nil | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
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.
these changes should be squashed into first commit