kubeapi

package
v4.3.1-rc.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabelToDeployment

func AddLabelToDeployment(clientset *kubernetes.Clientset, origDeployment *v1.Deployment, key, value, namespace string) error

func AddLabelToPod

func AddLabelToPod(clientset *kubernetes.Clientset, origPod *v1.Pod, key, value, namespace string) error

func CreateConfigMap

func CreateConfigMap(clientset *kubernetes.Clientset, configMap *v1.ConfigMap, namespace string) error

CreateConfigMap creates a ConfigMap

func CreateDeployment

func CreateDeployment(clientset *kubernetes.Clientset, deployment *v1.Deployment, namespace string) error

CreateDeployment creates a deployment

func CreateJob

func CreateJob(clientset *kubernetes.Clientset, job *v1batch.Job, namespace string) (string, error)

CreateJob deletes a backup job

func CreateNamespace

func CreateNamespace(clientset *kubernetes.Clientset, ns *v1.Namespace) error

CreateNamespace

func CreateRole

func CreateRole(clientset *kubernetes.Clientset, role *v1.Role, namespace string) error

CreateRole

func CreateRoleBinding

func CreateRoleBinding(clientset *kubernetes.Clientset, roleBinding *v1.RoleBinding, namespace string) error

CreateRoleBinding

func CreateSecret

func CreateSecret(clientset *kubernetes.Clientset, secret *v1.Secret, namespace string) error

CreateSecret

func CreateSelfSubjectAccessReview

func CreateSelfSubjectAccessReview(clientset *kubernetes.Clientset,
	resourceAttributes *authorizationapi.ResourceAttributes) (*authorizationapi.SelfSubjectAccessReview,
	error)

CreateSelfSubjectAccessReview creates a SelfSubjectAccessReview using the ResourceAttributes provided

func CreateService

func CreateService(clientset *kubernetes.Clientset, svc *v1.Service, namespace string) (*v1.Service, error)

CreateService creates a Service

func CreateServiceAccount

func CreateServiceAccount(clientset *kubernetes.Clientset, sa *v1.ServiceAccount, namespace string) error

CreateServiceAccount

func Createpgcluster

func Createpgcluster(client *rest.RESTClient, cluster *crv1.Pgcluster, namespace string) error

Createpgcluster creates a pgcluster

func Createpgpolicy

func Createpgpolicy(client *rest.RESTClient, policy *crv1.Pgpolicy, namespace string) error

Createpgpolicy creates a pgpolicy

func Createpgreplica

func Createpgreplica(client *rest.RESTClient, replica *crv1.Pgreplica, namespace string) error

Createpgreplica creates a pgreplica

func Createpgtask

func Createpgtask(client *rest.RESTClient, task *crv1.Pgtask, namespace string) error

Createpgtask creates a pgtask

func DeleteConfigMap

func DeleteConfigMap(clientset *kubernetes.Clientset, name, namespace string) error

DeleteConfigMap deletes a ConfigMap by name

func DeleteConfigMaps

func DeleteConfigMaps(clientset *kubernetes.Clientset, selector, namespace string) error

DeleteConfigMaps deletes a ConfigMap by a selector

func DeleteDeployment

func DeleteDeployment(clientset *kubernetes.Clientset, name, namespace string) error

DeleteDeployment deletes a deployment

func DeleteJob

func DeleteJob(clientset *kubernetes.Clientset, jobName, namespace string) error

DeleteJob deletes a job

func DeleteJobs

func DeleteJobs(clientset *kubernetes.Clientset, selector, namespace string) error

DeleteJobs deletes all jobs that match a selector

func DeleteNamespace

func DeleteNamespace(clientset *kubernetes.Clientset, name string) error

DeleteNamespace

func DeletePVC

func DeletePVC(clientset *kubernetes.Clientset, name, namespace string) error

DeletePVC deletes a PVC by name

func DeletePod

func DeletePod(clientset *kubernetes.Clientset, name, namespace string) error

DeletePod deletes a Pod

func DeleteRole

func DeleteRole(clientset *kubernetes.Clientset, name, namespace string) error

DeleteRole

func DeleteRoleBinding

func DeleteRoleBinding(clientset *kubernetes.Clientset, name, namespace string) error

DeleteRoleBinding

func DeleteSecret

func DeleteSecret(clientset *kubernetes.Clientset, name, namespace string) error

DeleteSecret

func DeleteService

func DeleteService(clientset *kubernetes.Clientset, name, namespace string) error

DeleteService deletes a Service

func DeleteServiceAccount

func DeleteServiceAccount(clientset *kubernetes.Clientset, name, namespace string) error

DeleteServiceAccount

func Deletepgcluster

func Deletepgcluster(client *rest.RESTClient, name, namespace string) error

Deletepgcluster deletes pgcluster by name

func Deletepgpolicy

func Deletepgpolicy(client *rest.RESTClient, name, namespace string) error

Deletepgpolicy deletes pgpolicy by name

func Deletepgreplica

func Deletepgreplica(client *rest.RESTClient, name, namespace string) error

Deletepgreplica deletes pgreplica by name

func Deletepgtask

func Deletepgtask(client *rest.RESTClient, name, namespace string) error

Deletepgtask deletes pgtask by name

func Deletepgtasks

func Deletepgtasks(client *rest.RESTClient, selector, namespace string) error

Deletepgtasks deletes pgtask by selector

func ExecToPodThroughAPI

func ExecToPodThroughAPI(config *rest.Config, clientset kubernetes.Interface, command []string, containerName, podName, namespace string, stdin io.Reader) (string, string, error)

ExecToPodThroughAPI uninterractively exec to the pod with the command specified. :param string command: list of the str which specify the command. :param string pod_name: Pod name :param string namespace: namespace of the Pod. :param io.Reader stdin: Standerd Input if necessary, otherwise `nil` :return: string: Output of the command. (STDOUT)

string: Errors. (STDERR)
 error: If any error has occurred otherwise `nil`

func GetAllStorageClasses

func GetAllStorageClasses(clientset *kubernetes.Clientset) (*v1.StorageClassList, error)

GetStorageClasses gets a list of StorageClasses

func GetConfigMap

func GetConfigMap(clientset *kubernetes.Clientset, name, namespace string) (*v1.ConfigMap, bool)

GetConfigMap gets a ConfigMap by name

func GetDeployment

func GetDeployment(clientset *kubernetes.Clientset, name, namespace string) (*v1.Deployment, bool, error)

GetDeployment gets a deployment by name

func GetDeployments

func GetDeployments(clientset *kubernetes.Clientset, selector, namespace string) (*v1.DeploymentList, error)

GetDeployments gets a list of deployments using a label selector

func GetJob

func GetJob(clientset *kubernetes.Clientset, name, namespace string) (*v1batch.Job, bool)

GetJob gets a Job by name

func GetJobs

func GetJobs(clientset *kubernetes.Clientset, selector, namespace string) (*v1batch.JobList, error)

GetJobs gets a list of jobs using a label selector

func GetNamespace

func GetNamespace(clientset *kubernetes.Clientset, name string) (*v1.Namespace, bool, error)

GetNamespace gets a Namespace by name

func GetNamespaces

func GetNamespaces(clientset *kubernetes.Clientset) (*v1.NamespaceList, error)

GetNamespaces gets a list of Namespaces

func GetPVC

func GetPVC(clientset *kubernetes.Clientset, name, namespace string) (*v1.PersistentVolumeClaim, error)

GetPVC gets a PVC by name

func GetPVCIfExists

func GetPVCIfExists(clientset *kubernetes.Clientset, name, namespace string) (*v1.PersistentVolumeClaim, error)

GetPVCIfExists gets a PVC by name. If the PVC does not exist, it returns nils.

func GetPVCs

func GetPVCs(clientset *kubernetes.Clientset, selector, namespace string) (*v1.PersistentVolumeClaimList, error)

GetPVCs gets a list of PVC by selector

func GetPod

func GetPod(clientset *kubernetes.Clientset, name, namespace string) (*v1.Pod, bool, error)

GetPod gets a Pod by name

func GetPods

func GetPods(clientset *kubernetes.Clientset, selector, namespace string) (*v1.PodList, error)

GetPods gets a list of Pods by selector

func GetRole

func GetRole(clientset *kubernetes.Clientset, name, namespace string) (*v1.Role, bool, error)

GetRole gets a Role by name

func GetRoleBinding

func GetRoleBinding(clientset *kubernetes.Clientset, name, namespace string) (*v1.RoleBinding, bool, error)

GetRoleBinding gets a RoleBinding by name

func GetSecret

func GetSecret(clientset *kubernetes.Clientset, name, namespace string) (*v1.Secret, error)

GetSecret gets a Secrets by name

func GetSecrets

func GetSecrets(clientset *kubernetes.Clientset, selector, namespace string) (*v1.SecretList, error)

GetSecrets gets a list of Secrets by selector

func GetService

func GetService(clientset *kubernetes.Clientset, name, namespace string) (*v1.Service, bool, error)

GetService gets a Service by name

func GetServiceAccount

func GetServiceAccount(clientset *kubernetes.Clientset, name, namespace string) (*v1.ServiceAccount, bool, error)

GetServiceAccount gets a ServiceAccount by name

func GetServices

func GetServices(clientset *kubernetes.Clientset, selector, namespace string) (*v1.ServiceList, error)

GetServices gets a list of Services by selector

func GetStorageClass

func GetStorageClass(clientset *kubernetes.Clientset, name string) (*v1.StorageClass, bool)

GetStorageClass gets a single StorageClasse

func GetStorageClasses

func GetStorageClasses(clientset *kubernetes.Clientset, selector string) (*v1.StorageClassList, error)

GetStorageClasses gets a list of StorageClasses using a selector

func Getpgcluster

func Getpgcluster(client *rest.RESTClient, cluster *crv1.Pgcluster, name, namespace string) (bool, error)

Getpgcluster gets a pgcluster by name

func Getpgclusters

func Getpgclusters(client *rest.RESTClient, clusterList *crv1.PgclusterList, namespace string) error

Getpgclusters gets a list of pgclusters

func GetpgclustersBySelector

func GetpgclustersBySelector(client *rest.RESTClient, clusterList *crv1.PgclusterList, selector, namespace string) error

GetpgclustersBySelector gets a list of pgclusters by selector

func Getpgpolicies

func Getpgpolicies(client *rest.RESTClient, policyList *crv1.PgpolicyList, namespace string) error

Getpgpolicies gets a list of pgpolicies

func Getpgpolicy

func Getpgpolicy(client *rest.RESTClient, policy *crv1.Pgpolicy, name, namespace string) (bool, error)

Getpgpolicy gets a pgpolicies by name

func Getpgreplica

func Getpgreplica(client *rest.RESTClient, replica *crv1.Pgreplica, name, namespace string) (bool, error)

Getpgreplica gets a pgreplica by name

func Getpgreplicas

func Getpgreplicas(client *rest.RESTClient, replicaList *crv1.PgreplicaList, namespace string) error

Getpgreplicas gets a list of pgreplicas

func GetpgreplicasBySelector

func GetpgreplicasBySelector(client *rest.RESTClient, replicaList *crv1.PgreplicaList, selector, namespace string) error

GetpgreplicasBySelector gets a list of pgreplicas by selector

func Getpgtask

func Getpgtask(client *rest.RESTClient, task *crv1.Pgtask, name, namespace string) (bool, error)

Getpgtask gets a pgtask by name

func Getpgtasks

func Getpgtasks(client *rest.RESTClient, taskList *crv1.PgtaskList, namespace string) error

Getpgtasks gets a list of pgtasks

func GetpgtasksBySelector

func GetpgtasksBySelector(client *rest.RESTClient, taskList *crv1.PgtaskList, selector, namespace string) error

GetpgtasksBySelector gets a list of pgtasks by selector

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists returns true if the err indicates that a resource already exists.

func IsJobComplete

func IsJobComplete(client *kubernetes.Clientset, namespace string, job *v1batch.Job, timeout time.Duration) error

func IsJobDeleted

func IsJobDeleted(client *kubernetes.Clientset, namespace string, job *v1batch.Job, timeout time.Duration) error

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if err indicates that a resource was not found.

func IsPVCDeleted

func IsPVCDeleted(client *kubernetes.Clientset, timeout time.Duration, pvcName,
	namespace string) error

IsPVCDeleted checks to see if a PVC has been deleted. It will continuously check to see if the PVC has been deleted, only returning once the PVC is verified to have been deleted, or the timeout specified is reached.

func ListConfigMap

func ListConfigMap(clientset *kubernetes.Clientset, label, namespace string) (*v1.ConfigMapList, bool)

ListConfigMap lists ConfigMaps with a given selector

func MergePatchDeployment

func MergePatchDeployment(clientset *kubernetes.Clientset, origDeployment *v1.Deployment, newname, namespace string) error

MergePatchDeployment patches a deployment for failover only at this point

func NewKubeClient

func NewKubeClient() (*rest.Config, *kubernetes.Clientset, error)

NewKubeClient returns a Clientset for interacting with Kubernetes resources, along with the REST config used to create the client

func NewPGOClient

func NewPGOClient() (*rest.Config, *rest.RESTClient, *clientset.Clientset, error)

NewPGOClient returns a Clientset and a REST client for interacting with PostgreSQL Operator resources, along with the REST config used to create the clients

func PatchDeploymentStrategicMerge

func PatchDeploymentStrategicMerge(clientset *kubernetes.Clientset, deploymentName,
	namespace string, patch string) error

PatchDeploymentStrategicMerge is a helper function for performing a strategic merge patch to update a Deployment. The function is responsible for calling the patchDeployment function in order to perform the strategic merge, specifically ensuring that the proper patch type is set as required to perform a strategic merge.

func PatchServicePort

func PatchServicePort(clientset *kubernetes.Clientset, servicename, namespace, op, jsonpath string, portpatch ServicePortSpec)

PatchServicePort performs a JSON patch on a service to modify the ports defined for a given service As it performs a JSON patch, the supported operations should include: “add”, “remove”, “replace”, “move”, “copy” and “test”

func PatchServiceSelector

func PatchServiceSelector(clientset *kubernetes.Clientset, servicename, namespace, op, jsonpath string, selectorpatch ServiceSelectorSpec)

PatchServiceSelector replaces the selector section of a service definition with the selector patch provided. As it performs a JSON patch, the supported operations should include: “add”, “remove”, “replace”, “move”, “copy” and “test”

func PatchpgclusterStatus

func PatchpgclusterStatus(restclient *rest.RESTClient, state crv1.PgclusterState, message string, oldCrd *crv1.Pgcluster, namespace string) error

func PatchpgpolicyStatus

func PatchpgpolicyStatus(restclient *rest.RESTClient, state crv1.PgpolicyState, message string, oldCrd *crv1.Pgpolicy, namespace string) error

func PatchpgreplicaStatus

func PatchpgreplicaStatus(restclient *rest.RESTClient, state crv1.PgreplicaState, message string, oldCrd *crv1.Pgreplica, namespace string) error

func PatchpgtaskStatus

func PatchpgtaskStatus(restclient *rest.RESTClient, state crv1.PgtaskState, message string, oldCrd *crv1.Pgtask, namespace string) error

func PatchpgtaskWorkflowStatus

func PatchpgtaskWorkflowStatus(restclient *rest.RESTClient, oldCrd *crv1.Pgtask, namespace string) error

func ScaleDeployment

func ScaleDeployment(clientset *kubernetes.Clientset, deployment v1.Deployment,
	replicas int) error

ScaleDeployment provides the ability to scale a Kubernetes deployment. The deployment provided is scaled to the number of replicas specfied via the 'replicas' parameter.

func UpdateConfigMap

func UpdateConfigMap(clientset *kubernetes.Clientset, configMap *v1.ConfigMap, namespace string) error

UpdateConfigMap updates a configMap by name

func UpdateDeployment

func UpdateDeployment(clientset *kubernetes.Clientset, deployment *v1.Deployment) error

UpdateDeployment enables the update of a Kubernetes deployment. This expects to have the full manifest required for the udpate

func UpdateNamespace

func UpdateNamespace(clientset *kubernetes.Clientset, ns *v1.Namespace) error

func UpdateRole

func UpdateRole(clientset *kubernetes.Clientset, sec *v1.Role, namespace string) error

func UpdateRoleBinding

func UpdateRoleBinding(clientset *kubernetes.Clientset, sec *v1.RoleBinding, namespace string) error

func UpdateSecret

func UpdateSecret(clientset *kubernetes.Clientset, sec *v1.Secret, namespace string) error

func UpdateService

func UpdateService(clientset *kubernetes.Clientset, svc *v1.Service, namespace string) error

func UpdateServiceAccount

func UpdateServiceAccount(clientset *kubernetes.Clientset, sec *v1.ServiceAccount, namespace string) error

func Updatepgcluster

func Updatepgcluster(client *rest.RESTClient, cluster *crv1.Pgcluster, name, namespace string) error

Updatepgcluster updates a pgcluster

func Updatepgpolicy

func Updatepgpolicy(client *rest.RESTClient, task *crv1.Pgpolicy, name, namespace string) error

Updatepgpolicy

func Updatepgreplica

func Updatepgreplica(client *rest.RESTClient, replica *crv1.Pgreplica, name, namespace string) error

Updatepgreplica updates a pgreplica

func Updatepgtask

func Updatepgtask(client *rest.RESTClient, task *crv1.Pgtask, name, namespace string) error

Updatepgtask updates a pgtask

Types

type ControllerClients

type ControllerClients struct {
	Config        *rest.Config
	Kubeclientset *kubernetes.Clientset
	PGOClientset  *clientset.Clientset
	PGORestclient *rest.RESTClient
}

ControllerClients stores the various clients needed by a controller

func NewControllerClients

func NewControllerClients() (*ControllerClients, error)

NewControllerClients returns a ControllerClients struct containing the various clients needed for a controller. This includes a Kubernetes Clientset, along with a PGO Clientset with its associated RESTClient and its underlying configuration. The Clientset is configured with a higher than normal QPS and Burst limit.

type GetEndpointRequest

type GetEndpointRequest struct {
	Clientset *kubernetes.Clientset // Kubernetes Clientset that interfaces with the Kubernetes cluster
	Name      string                // Name of the endpoint that is being queried
	Namespace string                // Namespace the endpoint being queried resides in
}

GetEndpointRequest is used for the GetEndpoint function, which includes the current Kubernetes request context, as well as the namespace / endpoint name being requested

type GetEndpointResponse

type GetEndpointResponse struct {
	Endpoint  *v1.Endpoints // Kubernetes Endpoint object that specifics about the endpoint
	Name      string        // Name of the endpoint
	Namespace string        // Namespace that the endpoint is in
}

GetEndpointResponse contains the results from a successful request to the endpoint API, including the Kubernetes Endpoint as well as the original request data

func GetEndpoint

func GetEndpoint(request *GetEndpointRequest) (*GetEndpointResponse, error)

GetEndpoint tries to find an individual endpoint in a namespace. Returns the endpoint object if it can be IsNotFound If no endpoint can be found, then an error is returned

type ServicePortPatchSpec

type ServicePortPatchSpec struct {
	Op    string          `json:"op"`
	Path  string          `json:"path"`
	Value ServicePortSpec `json:"value"`
}

ServicePortPatchSpec holds the relevant information for making a JSON patch to add a port to a service

type ServicePortSpec

type ServicePortSpec struct {
	Name       string `json:"name"`
	Port       int    `json:"port"`
	Protocol   string `json:"protocol"`
	TargetPort int    `json:"targetPort"`
}

ServicePortSpec holds the specific port info needed when patching a service during a cluster upgrade and is part of the above ServicePortPatchSpec

func PortPatch

func PortPatch(name, protocol string, port, targetport int) []ServicePortSpec

PortPatch returns a struct to use when patching in a new port to a service.

type ServiceSelectorPatchSpec

type ServiceSelectorPatchSpec struct {
	Op    string              `json:"op"`
	Path  string              `json:"path"`
	Value ServiceSelectorSpec `json:"value"`
}

ServiceSelectorPatchSpec holds the relevant selector information used when making a JSON patch on a service

type ServiceSelectorSpec

type ServiceSelectorSpec struct {
	Pgcluster string `json:"pg-cluster"`
	Role      string `json:"role"`
}

ServiceSelectorSpec holds the information needed for selecting the appropriate service being used by a pgcluster that we want to patch

func SelectorPatches

func SelectorPatches(servicename, role string) []ServiceSelectorSpec

SelectorPatches returns the needed selector struct used when patching a pgcluster's service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL