Documentation ¶
Index ¶
- Constants
- Variables
- func AddFeatureGate(current, new string) string
- func AtomicWrite(fileName string, data []byte, perm os.FileMode) error
- func BuildControllerEventRecorder(k8s clientset.Interface, controllerName, namespace string) record.EventRecorder
- func EncodeCertsPEM(cert *x509.Certificate, caCerts []*x509.Certificate) []byte
- func ExecCommand(command string, args []string) (string, error)
- func GetAddresses(endpoint *v1.Endpoints) []string
- func GetClientSet(file string) (clientset.Interface, error)
- func GetDefaultAddresses(nodeIP net.IP) (string, string, string, error)
- func GetFirst4String(elems []string) (string, error)
- func GetFirst6String(elems []string) (string, error)
- func GetFirstString(elems []string) (string, bool, error)
- func GetFirstValidIPString(s cli.StringSlice) string
- func GetFunctionName(i interface{}) string
- func GetHostnameAndIPs(name string, nodeIPs cli.StringSlice) (string, []net.IP, error)
- func GetIPFromInterface(ifaceName string) (string, error)
- func GetKubeConfigPath(file string) string
- func GetTokenHash(config *config.Control) (string, error)
- func GetUserAgent(controllerName string) string
- func IPStringToIPNet(address string) (*net.IPNet, error)
- func IPToIPNet(ip net.IP) (*net.IPNet, error)
- func JoinIP4Nets(elems []*net.IPNet) string
- func JoinIP6Nets(elems []*net.IPNet) string
- func JoinIPNets(elems []*net.IPNet) string
- func JoinIPs(elems []net.IP) string
- func NormalizeToken(token string) (string, error)
- func ParseStringSliceToIPs(s cli.StringSlice) ([]net.IP, error)
- func Random(size int) (string, error)
- func ReadFile(path string) (string, error)
- func ReadTokenFromFile(serverToken, certs, dataDir string) (string, error)
- func SetFileModeForFile(file *os.File, mode os.FileMode) error
- func SetFileModeForPath(name string, mode os.FileMode) error
- func ShortHash(s string, i int) string
- func SplitStringSlice(ss []string) []string
- func WaitForAPIServerReady(ctx context.Context, kubeconfigPath string, timeout time.Duration) error
- func WaitForRBACReady(ctx context.Context, kubeconfigPath string, timeout time.Duration, ...) error
Constants ¶
const ( MasterRoleLabelKey = "node-role.kubernetes.io/master" ControlPlaneRoleLabelKey = "node-role.kubernetes.io/control-plane" ETCDRoleLabelKey = "node-role.kubernetes.io/etcd" )
const DefaultAPIServerReadyTimeout = 15 * time.Minute
This sets a default duration to wait for the apiserver to become ready. This is primarily used to block startup of agent supervisor controllers until the apiserver is ready to serve requests, in the same way that the apiReady channel is used in the server packages, so it can be fairly long. It must be at least long enough for downstream projects like RKE2 to start the apiserver in the background.
Variables ¶
var ErrCommandNoArgs = errors.New("this command does not take any arguments")
var ErrUnsupportedPlatform = errors.New("unsupported platform")
Functions ¶
func AddFeatureGate ¶
AddFeatureGate correctly appends a feature gate key pair to the feature gates CLI switch.
func AtomicWrite ¶
AtomicWrite firsts writes data to a temp file, then renames to the destination file. This ensures that the destination file is never partially written.
func BuildControllerEventRecorder ¶
func BuildControllerEventRecorder(k8s clientset.Interface, controllerName, namespace string) record.EventRecorder
func EncodeCertsPEM ¶
func EncodeCertsPEM(cert *x509.Certificate, caCerts []*x509.Certificate) []byte
EncodeCertsPEM is a wrapper around the EncodeCertPEM function to return the PEM encoding of a cert and chain, instead of just a single cert.
func ExecCommand ¶
ExecCommand executes a command using the VPN binary In case of error != nil, the string returned var will have more information
func GetAddresses ¶
func GetClientSet ¶
GetClientSet creates a Kubernetes client from the kubeconfig at the provided path.
func GetDefaultAddresses ¶
GetFirstIP checks what is the IPFamily of the first item. Based on that, returns a set of values
func GetFirst4String ¶
GetFirst4String returns the first IPv4 address from a list of IP address strings. If no IPv4 addresses are found, an error is raised.
func GetFirst6String ¶
GetFirst6String returns the first IPv6 address from a list of IP address strings. If no IPv6 addresses are found, an error is raised.
func GetFirstString ¶
GetFirstString returns the first IP4 address from a list of IP address strings. If no IPv4 addresses are found, returns the first IPv6 address if neither of IPv4 or IPv6 are found an error is raised.
func GetFirstValidIPString ¶
func GetFirstValidIPString(s cli.StringSlice) string
GetFirstValidIPString returns the first valid address from a list of IP address strings, without preference for IP family. If no address are found, an empty string is returned.
func GetFunctionName ¶
func GetFunctionName(i interface{}) string
func GetHostnameAndIPs ¶
GetHostnameAndIPs takes a node name and list of IPs, usually from CLI args. If set, these are used to return the node's name and addresses. If not set, the system hostname and primary interface addresses are returned instead.
func GetIPFromInterface ¶
GetIPFromInterface is the public function that returns the IP of an interface
func GetKubeConfigPath ¶
GetKubeConfigPath can be used to search for a kubeconfig in standard locations if an empty string is passed. If a non-empty string is passed, that path is used.
func GetUserAgent ¶
GetUserAgent builds a complete UserAgent string for a given controller, including the node name if possible.
func IPStringToIPNet ¶
IPStringToIPNet converts an IP string to an IPNet, using a fully filled mask appropriate for the address family.
func IPToIPNet ¶
IPToIPNet converts an IP to an IPNet, using a fully filled mask appropriate for the address family.
func JoinIP4Nets ¶
JoinIP4Nets stringifies and joins a list of IPv4 networks with commas.
func JoinIP6Nets ¶
JoinIP6Nets stringifies and joins a list of IPv6 networks with commas.
func JoinIPNets ¶
JoinIPNets stringifies and joins a list of IP networks with commas.
func NormalizeToken ¶
NormalizeToken will normalize the token read from file or passed as a cli flag
func ParseStringSliceToIPs ¶
func ParseStringSliceToIPs(s cli.StringSlice) ([]net.IP, error)
ParseStringSliceToIPs converts slice of strings that in turn can be lists of comma separated unparsed IP addresses into a single slice of net.IP, it returns error if at any point parsing failed
func ReadTokenFromFile ¶
ReadTokenFromFile will attempt to get the token from <data-dir>/token if it the file not found in case of fresh installation it will try to use the runtime serverToken saved in memory after stripping it from any additional information like the username or cahash, if the file found then it will still strip the token from any additional info
func SplitStringSlice ¶
SplitStringSlice is a helper function to handle StringSliceFlag containing multiple values By default, StringSliceFlag only supports repeated values, not multiple values e.g. --foo="bar,car" --foo=baz will result in []string{"bar", "car". "baz"}
func WaitForAPIServerReady ¶
WaitForAPIServerReady waits for the API Server's /readyz endpoint to report "ok" with timeout. This is modified from WaitForAPIServer from the Kubernetes controller-manager app, but checks the readyz endpoint instead of the deprecated healthz endpoint, and supports context.
func WaitForRBACReady ¶
func WaitForRBACReady(ctx context.Context, kubeconfigPath string, timeout time.Duration, ra authorizationv1.ResourceAttributes, user string, groups ...string) error
WaitForRBACReady polls an AccessReview request until it returns an allowed response. If the user and group are empty, it uses SelfSubjectAccessReview, otherwise SubjectAccessReview is used. It will return an error if the timeout expires, or nil if the SubjectAccessReviewStatus indicates the access would be allowed.
Types ¶
This section is empty.