forked from rancher/k3k
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
virtual-kubelet controller integration (rancher#130)
* Virtual kubelet controller integration Signed-off-by: galal-hussein <[email protected]> * Add k3k-kubelet image to the release workflow Signed-off-by: galal-hussein <[email protected]> * Add k3k-kubelet image to the release workflow Signed-off-by: galal-hussein <[email protected]> * Fix build/release workflow Signed-off-by: galal-hussein <[email protected]> * Remove pkg directory in k3k-kubelet Signed-off-by: galal-hussein <[email protected]> * rename Type to Config Signed-off-by: galal-hussein <[email protected]> * Move the kubelet and config outside of pkg Signed-off-by: galal-hussein <[email protected]> * fix comments Signed-off-by: galal-hussein <[email protected]> * Fix naming throughout the package Signed-off-by: galal-hussein <[email protected]> * Fix comments Signed-off-by: galal-hussein <[email protected]> * more fixes to naming Signed-off-by: galal-hussein <[email protected]> * fixes Signed-off-by: galal-hussein <[email protected]> * fixes Signed-off-by: galal-hussein <[email protected]> * fixes Signed-off-by: galal-hussein <[email protected]> * fixes Signed-off-by: galal-hussein <[email protected]> --------- Signed-off-by: galal-hussein <[email protected]>
- Loading branch information
1 parent
593455e
commit 823ed32
Showing
36 changed files
with
1,252 additions
and
837 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
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.