Documentation ¶
Index ¶
- Constants
- Variables
- func AreAllPodsReady(podList *corev1.PodList) bool
- func ArePodIPsReady(pods *corev1.PodList) bool
- func ContainerIndex(containers []corev1.Container, name string) int
- func FilterPodsByOwnerUID(podList *corev1.PodList, ownerId types.UID)
- func FindKubeConfig() string
- func GetContainer(name string, spec *corev1.PodSpec) *corev1.Container
- func GetEnvVarIndex(envVarName string, env *[]corev1.EnvVar) int
- func GetOperatorImage(ctx context.Context, client crclient.Client) (string, error)
- func GetOperatorNamespace() (string, error)
- func GetOperatorPodName() string
- func GetOperatorPodOwnerRef(ns string, client crclient.Client, ctx context.Context) (*metav1.OwnerReference, error)
- func GetPod(ctx context.Context, client crclient.Client, ns string) (*corev1.Pod, error)
- func GetPodMaxMemoryUnboundedBytes(container, podName, namespace string, kube *Kubernetes) (uint64, error)
- func GetPodMemoryLimitBytes(container, podName, namespace string, kube *Kubernetes) (uint64, error)
- func GetWatchNamespace() (string, error)
- func InitContainerFailed(containerStatuses []corev1.ContainerStatus) bool
- func IsControlledByGVK(refs []metav1.OwnerReference, gvk schema.GroupVersionKind) bool
- func IsInitContainersEqual(srcContainer, destContainer []corev1.Container) bool
- func IsOwnedBy(obj, owner crclient.Object) bool
- func IsPodReady(pod corev1.Pod) bool
- func LookupResource(name, namespace string, resource, caller client.Object, client client.Client, ...) (*reconcile.Result, error)
- func SetConfigDefaults(config *rest.Config, scheme *runtime.Scheme) *rest.Config
- type ExecOptions
- type Kubernetes
- func (k Kubernetes) ExecWithOptions(options ExecOptions) (bytes.Buffer, error)
- func (k Kubernetes) GetExternalAddress(route *corev1.Service) string
- func (k Kubernetes) GetKubernetesRESTConfig(masterURL, secretName, namespace string, logger logr.Logger, ...) (*rest.Config, error)
- func (k Kubernetes) GetNodeHost(logger logr.Logger, ctx context.Context) (string, error)
- func (k Kubernetes) GetOpenShiftRESTConfig(masterURL, secretName, namespace string, logger logr.Logger, ...) (*rest.Config, error)
- func (k Kubernetes) GetSecret(secretName, namespace string, ctx context.Context) (*corev1.Secret, error)
- func (k Kubernetes) GetServingCertsMode(ctx context.Context) string
- func (k Kubernetes) IsGroupVersionKindSupported(gvk schema.GroupVersionKind) (bool, error)
- func (k Kubernetes) IsGroupVersionSupported(groupVersion string, kind string) (bool, error)
- func (k Kubernetes) Logs(pod, namespace string, previous bool, ctx context.Context) (logs string, err error)
- func (k Kubernetes) ResourcesList(namespace string, set labels.Set, list runtime.Object, ctx context.Context) error
- func (k Kubernetes) ResourcesListByField(namespace, fieldName, fieldValue string, list runtime.Object, ...) error
- type RunModeType
Constants ¶
const ( // WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE // which is the namespace where the watch activity happens. // this value is empty if the operator is running with clusterScope. WatchNamespaceEnvVar = "WATCH_NAMESPACE" // PodNameEnvVar is the constant for env variable POD_NAME // which is the name of the current pod. PodNameEnvVar = "POD_NAME" )
const (
EventReasonResourceNotReady = "ResourceNotReady"
)
Variables ¶
var ErrNoNamespace = fmt.Errorf("namespace not found for current environment")
ErrNoNamespace indicates that a namespace could not be found for the current environment
var ErrRunLocal = fmt.Errorf("operator run mode forced to local")
ErrRunLocal indicates that the operator is set to run in local mode (this error is returned by functions that only work on operators running in cluster mode)
var ForceRunModeEnv = "OSDK_FORCE_RUN_MODE"
ForceRunModeEnv indicates if the operator should be forced to run in either local or cluster mode (currently only used for local mode)
Functions ¶
func AreAllPodsReady ¶
func ArePodIPsReady ¶
func FilterPodsByOwnerUID ¶
FilterPodsByOwnerUID Remove pods from podList not owned by the provided UID
func FindKubeConfig ¶
func FindKubeConfig() string
FindKubeConfig returns local Kubernetes configuration
func GetOperatorImage ¶
func GetOperatorNamespace ¶
func GetOperatorPodName ¶
func GetOperatorPodName() string
func GetOperatorPodOwnerRef ¶
func GetPod ¶
GetPod returns a Pod object that corresponds to the pod in which the code is currently running. It expects the environment variable POD_NAME to be set by the downwards API.
func GetPodMaxMemoryUnboundedBytes ¶
func GetPodMaxMemoryUnboundedBytes(container, podName, namespace string, kube *Kubernetes) (uint64, error)
func GetPodMemoryLimitBytes ¶
func GetPodMemoryLimitBytes(container, podName, namespace string, kube *Kubernetes) (uint64, error)
func GetWatchNamespace ¶
GetWatchNamespace returns the namespace the operator should be watching for changes
func InitContainerFailed ¶
func InitContainerFailed(containerStatuses []corev1.ContainerStatus) bool
func IsControlledByGVK ¶
func IsControlledByGVK(refs []metav1.OwnerReference, gvk schema.GroupVersionKind) bool
func IsInitContainersEqual ¶
func IsPodReady ¶
Types ¶
type ExecOptions ¶
ExecOptions specify execution options
type Kubernetes ¶
Kubernetes abstracts interaction with a Kubernetes cluster
func NewKubernetesFromConfig ¶
NewKubernetesFromConfig creates a new Kubernetes from the Kubernetes master URL to connect to
func NewKubernetesFromController ¶
func NewKubernetesFromController(mgr manager.Manager) *Kubernetes
NewKubernetesFromController creates a new Kubernetes instance from controller runtime Manager
func (Kubernetes) ExecWithOptions ¶
func (k Kubernetes) ExecWithOptions(options ExecOptions) (bytes.Buffer, error)
ExecWithOptions executes command on pod command example { "/usr/bin/ls", "folderName" }
func (Kubernetes) GetExternalAddress ¶
func (k Kubernetes) GetExternalAddress(route *corev1.Service) string
GetExternalAddress extract LoadBalancer Hostname (typically for AWS load-balancers) or IP (typically for GCE or OpenStack load-balancers) address
func (Kubernetes) GetKubernetesRESTConfig ¶
func (Kubernetes) GetNodeHost ¶
func (Kubernetes) GetOpenShiftRESTConfig ¶
func (Kubernetes) GetSecret ¶
func (k Kubernetes) GetSecret(secretName, namespace string, ctx context.Context) (*corev1.Secret, error)
GetSecret returns secret associated with given secret name
func (Kubernetes) GetServingCertsMode ¶
func (k Kubernetes) GetServingCertsMode(ctx context.Context) string
GetServingCertsMode returns a label that identify the kind of serving certs service is available. Returns 'openshift.io' for service-ca on openshift
func (Kubernetes) IsGroupVersionKindSupported ¶
func (k Kubernetes) IsGroupVersionKindSupported(gvk schema.GroupVersionKind) (bool, error)
func (Kubernetes) IsGroupVersionSupported ¶
func (k Kubernetes) IsGroupVersionSupported(groupVersion string, kind string) (bool, error)
func (Kubernetes) ResourcesList ¶
func (k Kubernetes) ResourcesList(namespace string, set labels.Set, list runtime.Object, ctx context.Context) error
ResourcesList returns a typed list of resource associated with the cluster
func (Kubernetes) ResourcesListByField ¶
type RunModeType ¶
type RunModeType string
const ( LocalRunMode RunModeType = "local" ClusterRunMode RunModeType = "cluster" )