Documentation ¶
Overview ¶
Package kubernetes ...
Package kubernetes provides functionality for kubernetes.
Package kubernetes ...
Package kubernetes ...
Package kubernetes ...
Index ¶
- Constants
- Variables
- func IsContainerInState(containerStatuses []corev1.ContainerStatus, state ContainerState) bool
- func IsNodeInCondition(node corev1.Node, conditionType corev1.NodeConditionType) bool
- type ClusterType
- type ContainerState
- type InstallOperatorRequest
- type Kubernetes
- func (k *Kubernetes) ApplyObject(obj runtime.Object) error
- func (k *Kubernetes) ClusterName() string
- func (k *Kubernetes) CreateClusterRole(name string, rules []rbac.PolicyRule) error
- func (k *Kubernetes) CreateClusterRoleBinding(namespace, name, roleName, serviceAccountName string) error
- func (k *Kubernetes) CreateDatabaseCluster(cluster *everestv1alpha1.DatabaseCluster) error
- func (k *Kubernetes) CreateNamespace(name string) error
- func (k *Kubernetes) CreatePMMSecret(namespace, secretName string, secrets map[string][]byte) error
- func (k *Kubernetes) CreateRestore(restore *everestv1alpha1.DatabaseClusterRestore) error
- func (k *Kubernetes) CreateRole(namespace, name string, rules []rbac.PolicyRule) error
- func (k *Kubernetes) CreateRoleBinding(namespace, name, roleName, serviceAccountName string) error
- func (k *Kubernetes) CreateServiceAccount(name, namespace string) error
- func (k *Kubernetes) CreateServiceAccountToken(serviceAccountName, secretName, namespace string) error
- func (k *Kubernetes) DeleteAllMonitoringResources(ctx context.Context, namespace string) error
- func (k *Kubernetes) DeleteDatabaseCluster(ctx context.Context, name string) error
- func (k *Kubernetes) DeleteObject(obj runtime.Object) error
- func (k *Kubernetes) GenerateKubeConfigWithToken(user string, secret *corev1.Secret) (string, error)
- func (k *Kubernetes) GetClusterServiceVersion(ctx context.Context, key types.NamespacedName) (*v1alpha1.ClusterServiceVersion, error)
- func (k *Kubernetes) GetClusterType(ctx context.Context) (ClusterType, error)
- func (k *Kubernetes) GetDBaaSOperatorVersion(ctx context.Context) (string, error)
- func (k *Kubernetes) GetDatabaseCluster(ctx context.Context, name string) (*everestv1alpha1.DatabaseCluster, error)
- func (k *Kubernetes) GetDefaultStorageClassName(ctx context.Context) (string, error)
- func (k *Kubernetes) GetEvents(ctx context.Context, pod string) ([]string, error)
- func (k *Kubernetes) GetLogs(ctx context.Context, containerStatuses []corev1.ContainerStatus, ...) ([]string, error)
- func (k *Kubernetes) GetNamespace(ctx context.Context, name string) (*corev1.Namespace, error)
- func (k *Kubernetes) GetPSMDBOperatorVersion(ctx context.Context) (string, error)
- func (k *Kubernetes) GetPXCOperatorVersion(ctx context.Context) (string, error)
- func (k *Kubernetes) GetPersistentVolumes(ctx context.Context) (*corev1.PersistentVolumeList, error)
- func (k *Kubernetes) GetPods(ctx context.Context, namespace string, labelSelector *metav1.LabelSelector) (*corev1.PodList, error)
- func (k *Kubernetes) GetSecret(ctx context.Context, name, namespace string) (*corev1.Secret, error)
- func (k *Kubernetes) GetServerVersion() (*version.Info, error)
- func (k *Kubernetes) GetStorageClasses(ctx context.Context) (*storagev1.StorageClassList, error)
- func (k *Kubernetes) GetWorkerNodes(ctx context.Context) ([]corev1.Node, error)
- func (k *Kubernetes) InstallOLMOperator(ctx context.Context, upgrade bool) error
- func (k *Kubernetes) InstallOperator(ctx context.Context, req InstallOperatorRequest) error
- func (k *Kubernetes) InstallPerconaCatalog(ctx context.Context) error
- func (k *Kubernetes) ListClusterServiceVersion(ctx context.Context, namespace string) (*v1alpha1.ClusterServiceVersionList, error)
- func (k *Kubernetes) ListDatabaseClusters(ctx context.Context) (*everestv1alpha1.DatabaseClusterList, error)
- func (k *Kubernetes) ListEngineDeploymentNames(ctx context.Context, namespace string) ([]string, error)
- func (k *Kubernetes) ListSecrets(ctx context.Context) (*corev1.SecretList, error)
- func (k *Kubernetes) ListSubscriptions(ctx context.Context, namespace string) (*v1alpha1.SubscriptionList, error)
- func (k *Kubernetes) PatchDatabaseCluster(cluster *everestv1alpha1.DatabaseCluster) error
- func (k *Kubernetes) ProvisionMonitoring(namespace string) error
- func (k *Kubernetes) RestartDatabaseCluster(ctx context.Context, name string) error
- func (k *Kubernetes) RestartEverestOperator(ctx context.Context, namespace string) error
- func (k *Kubernetes) UpgradeOperator(ctx context.Context, namespace, name string) error
- type NodeFileSystemSummary
- type NodeSummary
- type NodeSummaryNode
- type OperatorServiceManager
Constants ¶
const ( // ClusterTypeUnknown is for unknown type. ClusterTypeUnknown ClusterType = "unknown" // ClusterTypeMinikube is for minikube. ClusterTypeMinikube ClusterType = "minikube" // ClusterTypeEKS is for EKS. ClusterTypeEKS ClusterType = "eks" // ClusterTypeGeneric is a generic type. ClusterTypeGeneric ClusterType = "generic" // ContainerStateWaiting represents a state when container requires some // operations being done in order to complete start up. ContainerStateWaiting ContainerState = "waiting" // ContainerStateTerminated indicates that container began execution and // then either ran to completion or failed for some reason. ContainerStateTerminated ContainerState = "terminated" // APIVersionCoreosV1 constant for some API requests. APIVersionCoreosV1 = "operators.coreos.com/v1" )
Variables ¶
var ( // ErrEmptyVersionTag Got an empty version tag from GitHub API. ErrEmptyVersionTag error = errors.New("got an empty version tag from Github") )
Functions ¶
func IsContainerInState ¶
func IsContainerInState(containerStatuses []corev1.ContainerStatus, state ContainerState) bool
IsContainerInState returns true if container is in give state, otherwise false.
func IsNodeInCondition ¶
func IsNodeInCondition(node corev1.Node, conditionType corev1.NodeConditionType) bool
IsNodeInCondition returns true if node's condition given as an argument has status "True". Otherwise it returns false.
Types ¶
type ContainerState ¶
type ContainerState string
ContainerState describes container's state - waiting, running, terminated.
type InstallOperatorRequest ¶
type InstallOperatorRequest struct { Namespace string Name string OperatorGroup string CatalogSource string CatalogSourceNamespace string Channel string InstallPlanApproval v1alpha1.Approval StartingCSV string }
InstallOperatorRequest holds the fields to make an operator install request.
type Kubernetes ¶
type Kubernetes struct {
// contains filtered or unexported fields
}
Kubernetes is a client for Kubernetes.
func New ¶
func New(kubeconfigPath string, l *zap.SugaredLogger) (*Kubernetes, error)
New returns new Kubernetes object.
func NewEmpty ¶
func NewEmpty(l *zap.SugaredLogger) *Kubernetes
NewEmpty returns new Kubernetes object.
func (*Kubernetes) ApplyObject ¶ added in v0.4.0
func (k *Kubernetes) ApplyObject(obj runtime.Object) error
ApplyObject applies object.
func (*Kubernetes) ClusterName ¶
func (k *Kubernetes) ClusterName() string
ClusterName returns the name of the k8s cluster.
func (*Kubernetes) CreateClusterRole ¶
func (k *Kubernetes) CreateClusterRole(name string, rules []rbac.PolicyRule) error
CreateClusterRole creates a new cluster role.
func (*Kubernetes) CreateClusterRoleBinding ¶
func (k *Kubernetes) CreateClusterRoleBinding(namespace, name, roleName, serviceAccountName string) error
CreateClusterRoleBinding binds a cluster role to a service account.
func (*Kubernetes) CreateDatabaseCluster ¶
func (k *Kubernetes) CreateDatabaseCluster(cluster *everestv1alpha1.DatabaseCluster) error
CreateDatabaseCluster creates database cluster.
func (*Kubernetes) CreateNamespace ¶
func (k *Kubernetes) CreateNamespace(name string) error
CreateNamespace creates a new namespace.
func (*Kubernetes) CreatePMMSecret ¶
func (k *Kubernetes) CreatePMMSecret(namespace, secretName string, secrets map[string][]byte) error
CreatePMMSecret creates pmm secret in kubernetes.
func (*Kubernetes) CreateRestore ¶
func (k *Kubernetes) CreateRestore(restore *everestv1alpha1.DatabaseClusterRestore) error
CreateRestore creates a restore.
func (*Kubernetes) CreateRole ¶
func (k *Kubernetes) CreateRole(namespace, name string, rules []rbac.PolicyRule) error
CreateRole creates a new role.
func (*Kubernetes) CreateRoleBinding ¶
func (k *Kubernetes) CreateRoleBinding(namespace, name, roleName, serviceAccountName string) error
CreateRoleBinding binds a role to a service account.
func (*Kubernetes) CreateServiceAccount ¶
func (k *Kubernetes) CreateServiceAccount(name, namespace string) error
CreateServiceAccount creates a new service account.
func (*Kubernetes) CreateServiceAccountToken ¶
func (k *Kubernetes) CreateServiceAccountToken(serviceAccountName, secretName, namespace string) error
CreateServiceAccountToken creates a new secret with service account token.
func (*Kubernetes) DeleteAllMonitoringResources ¶
func (k *Kubernetes) DeleteAllMonitoringResources(ctx context.Context, namespace string) error
DeleteAllMonitoringResources deletes all resources related to monitoring from k8s cluster. If namespace is empty, a default namespace is used.
func (*Kubernetes) DeleteDatabaseCluster ¶
func (k *Kubernetes) DeleteDatabaseCluster(ctx context.Context, name string) error
DeleteDatabaseCluster deletes database cluster.
func (*Kubernetes) DeleteObject ¶
func (k *Kubernetes) DeleteObject(obj runtime.Object) error
DeleteObject deletes an object.
func (*Kubernetes) GenerateKubeConfigWithToken ¶
func (k *Kubernetes) GenerateKubeConfigWithToken(user string, secret *corev1.Secret) (string, error)
GenerateKubeConfigWithToken returns a kubeconfig with the token as provided in the secret.
func (*Kubernetes) GetClusterServiceVersion ¶
func (k *Kubernetes) GetClusterServiceVersion( ctx context.Context, key types.NamespacedName, ) (*v1alpha1.ClusterServiceVersion, error)
GetClusterServiceVersion retrieves a ClusterServiceVersion by namespaced name.
func (*Kubernetes) GetClusterType ¶
func (k *Kubernetes) GetClusterType(ctx context.Context) (ClusterType, error)
GetClusterType tries to guess the underlying kubernetes cluster based on storage class.
func (*Kubernetes) GetDBaaSOperatorVersion ¶
func (k *Kubernetes) GetDBaaSOperatorVersion(ctx context.Context) (string, error)
GetDBaaSOperatorVersion parses DBaaS operator version from operator deployment.
func (*Kubernetes) GetDatabaseCluster ¶
func (k *Kubernetes) GetDatabaseCluster(ctx context.Context, name string) (*everestv1alpha1.DatabaseCluster, error)
GetDatabaseCluster returns PXC clusters by provided name.
func (*Kubernetes) GetDefaultStorageClassName ¶
func (k *Kubernetes) GetDefaultStorageClassName(ctx context.Context) (string, error)
GetDefaultStorageClassName returns first storageClassName from kubernetes cluster.
func (*Kubernetes) GetLogs ¶
func (k *Kubernetes) GetLogs( ctx context.Context, containerStatuses []corev1.ContainerStatus, pod, container string, ) ([]string, error)
GetLogs returns logs as slice of log lines - strings - for given pod's container.
func (*Kubernetes) GetNamespace ¶ added in v0.2.0
GetNamespace returns a namespace.
func (*Kubernetes) GetPSMDBOperatorVersion ¶
func (k *Kubernetes) GetPSMDBOperatorVersion(ctx context.Context) (string, error)
GetPSMDBOperatorVersion parses PSMDB operator version from operator deployment.
func (*Kubernetes) GetPXCOperatorVersion ¶
func (k *Kubernetes) GetPXCOperatorVersion(ctx context.Context) (string, error)
GetPXCOperatorVersion parses PXC operator version from operator deployment.
func (*Kubernetes) GetPersistentVolumes ¶
func (k *Kubernetes) GetPersistentVolumes(ctx context.Context) (*corev1.PersistentVolumeList, error)
GetPersistentVolumes returns list of persistent volumes.
func (*Kubernetes) GetPods ¶
func (k *Kubernetes) GetPods( ctx context.Context, namespace string, labelSelector *metav1.LabelSelector, ) (*corev1.PodList, error)
GetPods returns list of pods.
func (*Kubernetes) GetServerVersion ¶
func (k *Kubernetes) GetServerVersion() (*version.Info, error)
GetServerVersion returns server version.
func (*Kubernetes) GetStorageClasses ¶
func (k *Kubernetes) GetStorageClasses(ctx context.Context) (*storagev1.StorageClassList, error)
GetStorageClasses returns all storage classes available in the cluster.
func (*Kubernetes) GetWorkerNodes ¶
GetWorkerNodes returns list of cluster workers nodes.
func (*Kubernetes) InstallOLMOperator ¶
func (k *Kubernetes) InstallOLMOperator(ctx context.Context, upgrade bool) error
InstallOLMOperator installs the OLM in the Kubernetes cluster.
func (*Kubernetes) InstallOperator ¶
func (k *Kubernetes) InstallOperator(ctx context.Context, req InstallOperatorRequest) error
InstallOperator installs an operator via OLM.
func (*Kubernetes) InstallPerconaCatalog ¶
func (k *Kubernetes) InstallPerconaCatalog(ctx context.Context) error
InstallPerconaCatalog installs percona catalog and ensures that packages are available.
func (*Kubernetes) ListClusterServiceVersion ¶
func (k *Kubernetes) ListClusterServiceVersion( ctx context.Context, namespace string, ) (*v1alpha1.ClusterServiceVersionList, error)
ListClusterServiceVersion list all CSVs for the given namespace.
func (*Kubernetes) ListDatabaseClusters ¶
func (k *Kubernetes) ListDatabaseClusters(ctx context.Context) (*everestv1alpha1.DatabaseClusterList, error)
ListDatabaseClusters returns list of managed PCX clusters.
func (*Kubernetes) ListEngineDeploymentNames ¶ added in v0.4.0
func (k *Kubernetes) ListEngineDeploymentNames(ctx context.Context, namespace string) ([]string, error)
ListEngineDeploymentNames returns a string array containing found engine deployments for the Everest.
func (*Kubernetes) ListSecrets ¶
func (k *Kubernetes) ListSecrets(ctx context.Context) (*corev1.SecretList, error)
ListSecrets returns secret by name.
func (*Kubernetes) ListSubscriptions ¶
func (k *Kubernetes) ListSubscriptions(ctx context.Context, namespace string) (*v1alpha1.SubscriptionList, error)
ListSubscriptions all the subscriptions in the namespace.
func (*Kubernetes) PatchDatabaseCluster ¶
func (k *Kubernetes) PatchDatabaseCluster(cluster *everestv1alpha1.DatabaseCluster) error
PatchDatabaseCluster patches CR of managed Database cluster.
func (*Kubernetes) ProvisionMonitoring ¶
func (k *Kubernetes) ProvisionMonitoring(namespace string) error
ProvisionMonitoring provisions PMM monitoring.
func (*Kubernetes) RestartDatabaseCluster ¶
func (k *Kubernetes) RestartDatabaseCluster(ctx context.Context, name string) error
RestartDatabaseCluster restarts database cluster.
func (*Kubernetes) RestartEverestOperator ¶ added in v0.4.0
func (k *Kubernetes) RestartEverestOperator(ctx context.Context, namespace string) error
RestartEverestOperator restarts everest pod.
func (*Kubernetes) UpgradeOperator ¶
func (k *Kubernetes) UpgradeOperator(ctx context.Context, namespace, name string) error
UpgradeOperator upgrades an operator to the next available version.
type NodeFileSystemSummary ¶
type NodeFileSystemSummary struct {
UsedBytes uint64 `json:"usedBytes,omitempty"`
}
NodeFileSystemSummary holds a summary of Node's filesystem.
type NodeSummary ¶
type NodeSummary struct {
Node NodeSummaryNode `json:"node,omitempty"`
}
NodeSummary holds summary of the Node. One gets this by requesting Kubernetes API endpoint: /v1/nodes/<node-name>/proxy/stats/summary.
type NodeSummaryNode ¶
type NodeSummaryNode struct {
FileSystem NodeFileSystemSummary `json:"fs,omitempty"`
}
NodeSummaryNode holds information about Node inside Node's summary.
type OperatorServiceManager ¶
type OperatorServiceManager interface { // SetKubeConfig receives a new config and establish a new connection to the K8 cluster. SetKubeConfig(kubeConfig string) error // InstallOLMOperator installs the OLM in the Kubernetes cluster. InstallOLMOperator(ctx context.Context) error // InstallOperator installs an operator via OLM. InstallOperator(ctx context.Context, req InstallOperatorRequest) error // ListSubscriptions all the subscriptions in the namespace. ListSubscriptions(ctx context.Context, namespace string) (*v1alpha1.SubscriptionList, error) // UpgradeOperator upgrades an operator to the next available version. UpgradeOperator(ctx context.Context, namespace, name string) error }
OperatorServiceManager ...