Documentation ¶
Index ¶
- Constants
- Variables
- func ChangedDNSProvider(currentDNS, desiredDNS *pb.DNS) bool
- func CloseClientConnection(connection *grpc.ClientConn)
- func ConcurrentExec[K any](items []K, f func(index int, item K) error) error
- func CountLbNodes(lb *pb.LBcluster) int
- func CountNodes(k *pb.K8Scluster) int
- func CreateDirectory(dir string) error
- func CreateHash(length int) string
- func CreateKeyFile(key string, outputPath string, keyName string) error
- func CreateKeysForStaticNodepools(nps []*pb.NodePool, outputDirectory string) error
- func CreateLoggerWithClusterName(clusterName string) zerolog.Logger
- func CreateLoggerWithProjectAndClusterName(projectName, clusterName string) zerolog.Logger
- func CreateLoggerWithProjectName(projectName string) zerolog.Logger
- func FindAPIEndpointNode(nodepools []*pb.NodePool) (*pb.Node, error)
- func FindControlNode(nodepools []*pb.NodePool) (*pb.Node, error)
- func FindEndpointNode(np *pb.NodePool) (*pb.Node, error)
- func FindLbAPIEndpoint(lbs []*pb.LBcluster) bool
- func FindName(realNames []string, name string) string
- func FindNodepoolWithApiEndpointNode(nodepools []*pb.NodePool) (*pb.NodePool, *pb.Node, error)
- func GetClusterByName(clusterName string, clusters []*pb.K8Scluster) int
- func GetClusterID(clusterInfo *pb.ClusterInfo) string
- func GetCommonDynamicNodePools(nps []*pb.NodePool) []*pb.NodePool
- func GetCommonStaticNodePools(nps []*pb.NodePool) []*pb.NodePool
- func GetDynamicNodePools(nps []*pb.NodePool) []*pb.DynamicNodePool
- func GetDynamicNodePoolsFromCI(ci *pb.ClusterInfo) []*pb.DynamicNodePool
- func GetEnvDefault(envKey string, defaultVal string) string
- func GetLBClusterByName(name string, clusters []*pb.LBcluster) int
- func GetNodePoolByName(nodePoolName string, nodePools []*pb.NodePool) *pb.NodePool
- func GetRegions(nodepools []*pb.DynamicNodePool) []string
- func GroupNodepoolsByProviderNames(clusterInfo *pb.ClusterInfo) map[ProviderNames][]*pb.NodePool
- func GroupNodepoolsByProviderRegion(clusterInfo *pb.ClusterInfo) map[string][]*pb.NodePool
- func GroupNodepoolsByProviderSpecName(clusterInfo *pb.ClusterInfo) map[string][]*pb.NodePool
- func GrpcDialWithRetryAndBackoff(serviceName, serviceURL string) (*grpc.ClientConn, error)
- func HasAPIServerRole(roles []*pb.Role) bool
- func InitLog(moduleName string)
- func Into[K, V any](k []K, f func(k K) *V) []*V
- func IsAutoscaled(cluster *pb.K8Scluster) bool
- func IsConnectionReady(c *grpc.ClientConn) error
- func MergeMaps[M ~map[K]V, K comparable, V any](maps ...M) M
- func NewGRPCServer(opts ...grpc.ServerOption) *grpc.Server
- func SanitiseKubeconfig(s string) string
- func SanitiseString(s string) string
- func SanitiseURI(s string) string
- func Sum[M ~map[K]V, K comparable, V constraints.Integer | constraints.Float](m M) int
- type ClusterView
- func (view *ClusterView) AllClusters() []string
- func (view *ClusterView) MergeChanges(config *pb.Config)
- func (view *ClusterView) RemoveCurrentState(clusterName string)
- func (view *ClusterView) SetWorkflowDone(clusterName string)
- func (view *ClusterView) SetWorkflowError(clusterName string, err error)
- func (view *ClusterView) UpdateCurrentState(clusterName string, c *pb.K8Scluster, lbs []*pb.LBcluster)
- func (view *ClusterView) UpdateDesiredState(clusterName string, c *pb.K8Scluster, lbs []*pb.LBcluster)
- type ProviderNames
Constants ¶
const HashLength = 7
Variables ¶
var ErrConnectionNotReady = errors.New("unhealthy gRPC connection")
Functions ¶
func ChangedDNSProvider ¶
func CloseClientConnection ¶
func CloseClientConnection(connection *grpc.ClientConn)
CloseClientConnection is a wrapper around grpc.ClientConn Close function
func CountLbNodes ¶ added in v0.6.3
func CountNodes ¶ added in v0.6.3
func CountNodes(k *pb.K8Scluster) int
func CreateDirectory ¶
func CreateHash ¶
func CreateKeyFile ¶
CreateKeyFile writes the given key to a file. The key filename is specified by its outputPath and KeyName operands.
func CreateKeysForStaticNodepools ¶ added in v0.4.1
CreateKeysForStaticNodepools creates private keys files for all nodes in the provided static node pools in form of <node name>.pem.
func CreateLoggerWithClusterName ¶ added in v0.3.1
CreateLoggerWithClusterName creates a new logger aware of the cluster-name. Returns the new logger
func CreateLoggerWithProjectAndClusterName ¶ added in v0.3.1
CreateLoggerWithProjectAndClusterName creates a new logger aware of the project-name and cluster-name. Returns the new logger
func CreateLoggerWithProjectName ¶ added in v0.3.1
CreateLoggerWithProjectName creates a new logger aware of the project-name. Returns the new logger
func FindAPIEndpointNode ¶ added in v0.3.1
FindAPIEndpointNode searches the NodePools for a Node with type ApiEndpoint.
func FindControlNode ¶ added in v0.3.1
FindControlNode search the nodepools for a node with type Master.
func FindEndpointNode ¶ added in v0.3.1
FindEndpointNode searches the nodes of the nodepool for a node with type ApiEndpoint.
func FindLbAPIEndpoint ¶ added in v0.3.1
FindLbAPIEndpoint searches for a role with ApiEndpoint among the LBcluster.
func FindName ¶
FindName will return a real node name based on the user defined one example: name defined in cloud provider: gcp-cluster-jkshbdc-gcp-control-1 -> name defined in cluster : gcp-control-1
func FindNodepoolWithApiEndpointNode ¶ added in v0.4.0
FindNodepoolWithApiEndpointNode searches for a nodepool that has the control node representing the Api endpoint of the cluster. Returns the control node if found and its corresponding nodepool.
func GetClusterByName ¶
func GetClusterByName(clusterName string, clusters []*pb.K8Scluster) int
GetClusterByName will return index of Cluster that will have same name as specified in parameters If no name is found, return -1
func GetClusterID ¶ added in v0.3.1
func GetClusterID(clusterInfo *pb.ClusterInfo) string
func GetCommonDynamicNodePools ¶ added in v0.4.0
GetCommonDynamicNodePools returns slice of common node pools, where every node pool is dynamic.
func GetCommonStaticNodePools ¶ added in v0.4.0
GetCommonStaticNodePools returns slice of common node pools, where every node pool is static.
func GetDynamicNodePools ¶ added in v0.4.0
func GetDynamicNodePools(nps []*pb.NodePool) []*pb.DynamicNodePool
GetDynamicNodePools returns slice of dynamic node pools.
func GetDynamicNodePoolsFromCI ¶ added in v0.4.0
func GetDynamicNodePoolsFromCI(ci *pb.ClusterInfo) []*pb.DynamicNodePool
GetDynamicNodePoolsFromCI returns slice of dynamic node pools used in specified cluster info.
func GetEnvDefault ¶ added in v0.4.0
GetEnvDefault take a string representing environment variable as an argument, and a default value If the environment variable is not defined, it returns the provided default value.
func GetLBClusterByName ¶ added in v0.4.0
GetLBClusterByName will return index of Cluster that will have same name as specified in parameters If no name is found, return -1
func GetNodePoolByName ¶
GetNodePoolByName will return first Nodepool that will have same name as specified in parameters If no name is found, return nil
func GetRegions ¶
func GetRegions(nodepools []*pb.DynamicNodePool) []string
GetRegions will return a list of all regions used in list of nodepools
func GroupNodepoolsByProviderNames ¶ added in v0.4.0
func GroupNodepoolsByProviderNames(clusterInfo *pb.ClusterInfo) map[ProviderNames][]*pb.NodePool
GroupNodepoolsByProviderNames groups nodepool by provider spec name into the map[Provider Names][]*pb.Nodepool
func GroupNodepoolsByProviderRegion ¶ added in v0.2.2
func GroupNodepoolsByProviderRegion(clusterInfo *pb.ClusterInfo) map[string][]*pb.NodePool
GroupNodepoolsByProviderRegion groups nodepool by cloud provider instance name and region into the map[<provider-instance-name>-<region>][]*pb.Nodepool
func GroupNodepoolsByProviderSpecName ¶
func GroupNodepoolsByProviderSpecName(clusterInfo *pb.ClusterInfo) map[string][]*pb.NodePool
GroupNodepoolsByProviderSpecName groups nodepool by provider spec name into the map[Provider Name][]*pb.Nodepool
func GrpcDialWithRetryAndBackoff ¶ added in v0.4.1
func GrpcDialWithRetryAndBackoff(serviceName, serviceURL string) (*grpc.ClientConn, error)
GrpcDialWithRetryAndBackoff creates an insecure gRPC connection to serviceURL After successfully connected, any RPC calls made from this connection also have a retry policy of ~10 minutes after which an error is returned that it couldn't connect to the service.
func HasAPIServerRole ¶ added in v0.3.1
HasAPIServerRole checks if there is an API server role.
func InitLog ¶
func InitLog(moduleName string)
Initialize the logging framework. Inputs are the golang module name used as a logging prefix and the env variable with the logging level
func Into ¶ added in v0.4.2
func Into[K, V any](k []K, f func(k K) *V) []*V
Into traverse the elements in k and calls the supplied function f to convert them into elements if type V.
func IsAutoscaled ¶ added in v0.2.2
func IsAutoscaled(cluster *pb.K8Scluster) bool
IsAutoscaled returns true, if cluster has at least one nodepool with autoscaler config.
func IsConnectionReady ¶ added in v0.4.2
func IsConnectionReady(c *grpc.ClientConn) error
func MergeMaps ¶ added in v0.4.1
func MergeMaps[M ~map[K]V, K comparable, V any](maps ...M) M
MergeMaps merges two or more maps together, into single map.
func NewGRPCServer ¶ added in v0.4.1
func NewGRPCServer(opts ...grpc.ServerOption) *grpc.Server
func SanitiseKubeconfig ¶
SanitiseKubeconfig replaces the entire kubeconfig found after the '--kubeconfig' flag with '*****'. This has been decided to be the superior option when compared to matching sensitive fields and obscuring just those.
func SanitiseString ¶ added in v0.4.1
sanitiseString replaces all white spaces and ":" in the string to "-", and converts everything to lower case.
func SanitiseURI ¶
SanitiseURI replaces passwords with '*****' in connection strings that are in the form of <scheme>://<username>:<password>@<domain>.<tld> or <scheme>://<username>:<password>@<pqdn>.
func Sum ¶ added in v0.6.3
func Sum[M ~map[K]V, K comparable, V constraints.Integer | constraints.Float](m M) int
Types ¶
type ClusterView ¶ added in v0.4.1
type ClusterView struct { // CurrentClusters are the individual clusters defined in the kubernetes section of the config of the current state. CurrentClusters map[string]*pb.K8Scluster // DesiredClusters are the individual clusters defined in the kubernetes section of the config of the desired state. DesiredClusters map[string]*pb.K8Scluster // Loadbalancers are the loadbalancers attach to a given kubernetes cluster in the current state. Loadbalancers map[string][]*pb.LBcluster // DesiredLoadbalancers are the loadbalancers attach to a given kubernetes cluster in the desired state. DesiredLoadbalancers map[string][]*pb.LBcluster // DeletedLoadbalancers are the loadbalancers that will be deleted (present in the current state but missing in the desired state) DeletedLoadbalancers map[string][]*pb.LBcluster // ClusterWorkflows is additional information per-cluster workflow (current stage of execution, if any error occurred etc..) ClusterWorkflows map[string]*pb.Workflow }
ClusterView contains the per-cluster view on a given config. No mutex is needed when processing concurrently as long as each cluster only works with related values.
func NewClusterView ¶ added in v0.4.1
func NewClusterView(config *pb.Config) *ClusterView
func (*ClusterView) AllClusters ¶ added in v0.4.1
func (view *ClusterView) AllClusters() []string
AllClusters returns a slice of cluster all cluster names, from both the current state and desired state. This is useful to be abe to distinguish which clusters were deleted and which were not.
func (*ClusterView) MergeChanges ¶ added in v0.4.1
func (view *ClusterView) MergeChanges(config *pb.Config)
MergeChanges propagates the changes made back to the config.
func (*ClusterView) RemoveCurrentState ¶ added in v0.4.2
func (view *ClusterView) RemoveCurrentState(clusterName string)
func (*ClusterView) SetWorkflowDone ¶ added in v0.4.1
func (view *ClusterView) SetWorkflowDone(clusterName string)
func (*ClusterView) SetWorkflowError ¶ added in v0.4.1
func (view *ClusterView) SetWorkflowError(clusterName string, err error)
func (*ClusterView) UpdateCurrentState ¶ added in v0.4.2
func (view *ClusterView) UpdateCurrentState(clusterName string, c *pb.K8Scluster, lbs []*pb.LBcluster)
func (*ClusterView) UpdateDesiredState ¶ added in v0.4.2
func (view *ClusterView) UpdateDesiredState(clusterName string, c *pb.K8Scluster, lbs []*pb.LBcluster)
type ProviderNames ¶ added in v0.4.0
ProviderNames struct hold pair of cloud provider name and user defined name from manifest.