Documentation ¶
Overview ¶
Package shared implements utility routines, data structures, and constants used by multiple other KubeDirector packages.
Index ¶
- Constants
- func AddGlobalConfig(config *kdv1.KubeDirectorConfig)
- func Client() k8sClient.Client
- func ClientSet() kubernetes.Interface
- func ClustersUsingApp(appNamespace string, appID string) []string
- func Config() *rest.Config
- func EnsureClusterAppReference(clusterNamespace string, clusterName string, appCatalog string, appID string)
- func EnsureFinalizer(cr KubeDirectorObject)
- func GetDefaultServiceType() string
- func GetDefaultStorageClass() string
- func GetKubeDirectorNamespace() (string, error)
- func GetNativeSystemdSupport() bool
- func GetRequiredSecretPrefix() string
- func GetSvcClusterDomainBase() string
- func HasFinalizer(cr KubeDirectorObject) bool
- func ListIsUnique(list []string) bool
- func LogError(logger logr.Logger, err error, obj runtime.Object, eventReason string, ...)
- func LogErrorf(logger logr.Logger, err error, obj runtime.Object, eventReason string, ...)
- func LogEvent(obj runtime.Object, eventType string, eventReason string, msg string)
- func LogEventf(obj runtime.Object, eventType string, eventReason string, format string, ...)
- func LogInfo(logger logr.Logger, obj runtime.Object, eventReason string, msg string)
- func LogInfof(logger logr.Logger, obj runtime.Object, eventReason string, format string, ...)
- func RemoveClusterAppReference(clusterNamespace string, clusterName string, appCatalog string, appID string)
- func RemoveFinalizer(cr KubeDirectorObject)
- func RemoveGlobalConfig()
- func ServiceType(crServicetype string) corev1.ServiceType
- func SetClient(c k8sClient.Client)
- func StrPtr(s string) *string
- func StringInList(test string, list []string) bool
- type KubeDirectorObject
- type StatusGen
- type StatusGens
- func (s *StatusGens) DeleteStatusGen(uid types.UID)
- func (s *StatusGens) ReadStatusGen(uid types.UID) (StatusGen, bool)
- func (s *StatusGens) StatusGenCount() int
- func (s *StatusGens) ValidateStatusGen(uid types.UID)
- func (s *StatusGens) WriteStatusGen(uid types.UID, newGenUID string)
- func (s *StatusGens) WriteValidatedStatusGen(uid types.UID, newGenUID string)
Constants ¶
const ( // DefaultSvcDomainBase contains the initial segments used to build FQDNs // for cluster members DefaultSvcDomainBase = ".svc.cluster.local" // KubeDirectorNamespaceEnvVar is the constant for env variable MY_NAMESPACE // which is the namespace of the kubedirector pod. KubeDirectorNamespaceEnvVar = "MY_NAMESPACE" // KubeDirectorGlobalConfig is the name of the kubedirector config CR KubeDirectorGlobalConfig = "kd-global-config" //KdDomainBase - Annotation DNS subdomain prefix KdDomainBase = "kubedirector.bluedata.io" // DefaultServiceType - default service type if not specified in // the configCR DefaultServiceType = "LoadBalancer" )
const ( EventReasonNoEvent = "" EventReasonCluster = "Cluster" EventReasonRole = "Role" EventReasonMember = "Member" EventReasonConfig = "Config" )
Event reason constants for recording events
const ( AppCatalogLocal = "local" AppCatalogSystem = "system" )
Settings for appCatalog
const ( // KubeDirectorFinalizerID is added to KubeDirector objects' finalizers // to prevent them from being deleted before we can clean up. KubeDirectorFinalizerID = "kubedirector.bluedata.io/cleanup" )
Variables ¶
This section is empty.
Functions ¶
func AddGlobalConfig ¶ added in v0.3.0
func AddGlobalConfig(config *kdv1.KubeDirectorConfig)
AddGlobalConfig adds the globalConfig CR data
func ClustersUsingApp ¶ added in v0.3.0
ClustersUsingApp returns the list of clusters referencing the given app.
func EnsureClusterAppReference ¶ added in v0.3.0
func EnsureClusterAppReference( clusterNamespace string, clusterName string, appCatalog string, appID string, )
EnsureClusterAppReference notes that an app type is in use by this cluster. The cluster namespace and name are stored in a map indexed by the app CR's namespace+name. Note that we only expect this to be called once per cluster in the current design, but we will still protect against storing duplicates.
func EnsureFinalizer ¶ added in v0.3.0
func EnsureFinalizer( cr KubeDirectorObject, )
EnsureFinalizer adds the KubeDirector finalizer into the CR's finalizers list (if it is not in there).
func GetDefaultServiceType ¶ added in v0.3.0
func GetDefaultServiceType() string
GetDefaultServiceType extracts the default service type from the globalConfig CR data if present, otherwise returns the default value (NodePort).
func GetDefaultStorageClass ¶ added in v0.3.0
func GetDefaultStorageClass() string
GetDefaultStorageClass extracts the default storage class from the globalConfig CR data if present, otherwise returns an empty string
func GetKubeDirectorNamespace ¶
GetKubeDirectorNamespace is a utility function to fetch the namespace where kubedirector is running
func GetNativeSystemdSupport ¶ added in v0.3.0
func GetNativeSystemdSupport() bool
GetNativeSystemdSupport extracts the flag definition from the globalConfig CR data if present, otherwise returns false
func GetRequiredSecretPrefix ¶ added in v0.3.0
func GetRequiredSecretPrefix() string
GetRequiredSecretPrefix returns a string that must prefix-match a secret name in order to allow that secret to be mounted by us. May be emptystring if no match required.
func GetSvcClusterDomainBase ¶ added in v0.3.1
func GetSvcClusterDomainBase() string
GetSvcClusterDomainBase extracts the default svc cluster domain from the globalConfig CR data if present, otherwise returns the default value (NodePort).
func HasFinalizer ¶ added in v0.3.1
func HasFinalizer( cr KubeDirectorObject, ) bool
HasFinalizer checks whether the KubeDirector finalizer is among the CR's finalizers list.
func ListIsUnique ¶ added in v0.2.0
ListIsUnique is a utility function that checks if a given slice of strings is free of duplicates.
func LogErrorf ¶
func LogErrorf( logger logr.Logger, err error, obj runtime.Object, eventReason string, format string, args ...interface{}, )
LogErrorf logs the given message format and payload at Error level.
func LogEvent ¶ added in v0.2.0
LogEvent posts an event to event recorder with the given msg using the CR object as reference
func LogEventf ¶ added in v0.2.0
func LogEventf( obj runtime.Object, eventType string, eventReason string, format string, args ...interface{}, )
LogEventf posts an event to event recorder with the given message format and payload using the CR object as reference
func LogInfof ¶
func LogInfof( logger logr.Logger, obj runtime.Object, eventReason string, format string, args ...interface{}, )
LogInfof logs the given message format and payload at Info level.
func RemoveClusterAppReference ¶ added in v0.3.0
func RemoveClusterAppReference( clusterNamespace string, clusterName string, appCatalog string, appID string, )
RemoveClusterAppReference notes that an app type is no longer in use by this cluster. The cluster namespace+name is removed from the list of such references marked against the app's namespace+name. Note that we only expect this to be called when a reference to the cluster does exist; but if for some reason the reference does not exist this call is a NOP.
func RemoveFinalizer ¶ added in v0.3.0
func RemoveFinalizer( cr KubeDirectorObject, )
RemoveFinalizer removes the KubeDirector finalizer from the CR's finalizers list (if it is in there).
func RemoveGlobalConfig ¶ added in v0.3.0
func RemoveGlobalConfig()
RemoveGlobalConfig removes the current globalConfig
func ServiceType ¶ added in v0.3.0
func ServiceType( crServicetype string, ) corev1.ServiceType
ServiceType is a utility function that converts serviceType string to Kubedirector-Plus supported service types as a corev1.ServiceType returns corev1.ServiceTypeNodePort if crServicetype is not ClusterIP or LoadBalancer
func StringInList ¶
StringInList is a utility function that checks if a given string is present at least once in the given slice of strings.
Types ¶
type KubeDirectorObject ¶ added in v0.3.0
KubeDirectorObject is an interface that most KubeDirector CRs implement. Currently it's used to add/remove the KubeDirector finalizer from KubeDirector resources.
type StatusGens ¶ added in v0.3.0
type StatusGens struct {
// contains filtered or unexported fields
}
StatusGens provides thread safe access to a map of StatusGen's.
func NewStatusGens ¶ added in v0.3.0
func NewStatusGens() *StatusGens
NewStatusGens is a StatusGens constructor
func (*StatusGens) DeleteStatusGen ¶ added in v0.3.0
func (s *StatusGens) DeleteStatusGen(uid types.UID)
DeleteStatusGen provides thread safe delete of a status gen.
func (*StatusGens) ReadStatusGen ¶ added in v0.3.0
func (s *StatusGens) ReadStatusGen(uid types.UID) (StatusGen, bool)
ReadStatusGen provides thread safe read of a status gen UID string and validated flag.
func (*StatusGens) StatusGenCount ¶ added in v0.3.0
func (s *StatusGens) StatusGenCount() int
StatusGenCount provides thread safe number of current status gens.
func (*StatusGens) ValidateStatusGen ¶ added in v0.3.0
func (s *StatusGens) ValidateStatusGen(uid types.UID)
ValidateStatusGen provides thread safe mark-validated of a status gen.
func (*StatusGens) WriteStatusGen ¶ added in v0.3.0
func (s *StatusGens) WriteStatusGen(uid types.UID, newGenUID string)
WriteStatusGen provides thread safe write of a status gen UID string. The validated flag will begin as false.
func (*StatusGens) WriteValidatedStatusGen ¶ added in v0.3.0
func (s *StatusGens) WriteValidatedStatusGen(uid types.UID, newGenUID string)
WriteValidatedStatusGen does WriteStatusGen + ValidateStatusGen atomically.