-
Notifications
You must be signed in to change notification settings - Fork 30
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
virtual-kubelet controller integration #130
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1e5abca
Virtual kubelet controller integration
galal-hussein d58829c
Add k3k-kubelet image to the release workflow
galal-hussein 1dccdb4
Add k3k-kubelet image to the release workflow
galal-hussein 0f82e3c
Fix build/release workflow
galal-hussein be255f7
Remove pkg directory in k3k-kubelet
galal-hussein 6b02fd9
rename Type to Config
galal-hussein 4035566
Move the kubelet and config outside of pkg
galal-hussein d17ae34
fix comments
galal-hussein 070389c
Fix naming throughout the package
galal-hussein 7fc0477
Fix comments
galal-hussein 1750c52
more fixes to naming
galal-hussein 629c0c5
fixes
galal-hussein 36b12dd
fixes
galal-hussein 567be34
fixes
galal-hussein 3512617
fixes
galal-hussein 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
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
File renamed without changes.
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,76 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
// config has all virtual-kubelet startup options | ||
type config struct { | ||
ClusterName string `yaml:"clusterName,omitempty"` | ||
ClusterNamespace string `yaml:"clusterNamespace,omitempty"` | ||
NodeName string `yaml:"nodeName,omitempty"` | ||
Token string `yaml:"token,omitempty"` | ||
AgentHostname string `yaml:"agentHostname,omitempty"` | ||
HostConfigPath string `yaml:"hostConfigPath,omitempty"` | ||
VirtualConfigPath string `yaml:"virtualConfigPath,omitempty"` | ||
KubeletPort string `yaml:"kubeletPort,omitempty"` | ||
} | ||
|
||
func (c *config) unmarshalYAML(data []byte) error { | ||
var conf config | ||
|
||
if err := yaml.Unmarshal(data, &conf); err != nil { | ||
return err | ||
} | ||
|
||
if c.ClusterName == "" { | ||
c.ClusterName = conf.ClusterName | ||
} | ||
if c.ClusterNamespace == "" { | ||
c.ClusterNamespace = conf.ClusterNamespace | ||
} | ||
if c.HostConfigPath == "" { | ||
c.HostConfigPath = conf.HostConfigPath | ||
} | ||
if c.VirtualConfigPath == "" { | ||
c.VirtualConfigPath = conf.VirtualConfigPath | ||
} | ||
if c.KubeletPort == "" { | ||
c.KubeletPort = conf.KubeletPort | ||
} | ||
if c.AgentHostname == "" { | ||
c.AgentHostname = conf.AgentHostname | ||
} | ||
if c.NodeName == "" { | ||
c.NodeName = conf.NodeName | ||
} | ||
return nil | ||
} | ||
|
||
func (c *config) validate() error { | ||
if c.ClusterName == "" { | ||
return errors.New("cluster name is not provided") | ||
} | ||
if c.ClusterNamespace == "" { | ||
return errors.New("cluster namespace is not provided") | ||
} | ||
if c.AgentHostname == "" { | ||
return errors.New("agent Hostname is not provided") | ||
} | ||
return nil | ||
} | ||
|
||
func (c *config) parse(path string) error { | ||
if _, err := os.Stat(path); os.IsNotExist(err) { | ||
return nil | ||
} | ||
|
||
b, err := os.ReadFile(path) | ||
if err != nil { | ||
return err | ||
} | ||
return c.unmarshalYAML(b) | ||
} |
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.
Nit: to avoid copying over the fields (which will get worse over time as we add more fields), you can instead change the method to just return the config:
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.
the problem is that we want the user to be able to mix and match for example, the user can set the --agent-hostname as a flag and at the same time add
nodeName
in the config file, if we just returned the unmarshalled config it will ignore all the flags sat on the command line