Documentation ¶
Index ¶
- Constants
- func AddLabels(kubeObject *unstructured.Unstructured, definitionName string, ...) (*unstructured.Unstructured, error)
- func CreateNamespaceWorkloadResourceInstance(namespaceName string, workloadInstanceID uint) (*v0.WorkloadResourceInstance, error)
- func CreateOrUpdateResource(kubeObject *unstructured.Unstructured, kubeClient dynamic.Interface, ...) (*unstructured.Unstructured, error)
- func CreateResource(kubeObject *unstructured.Unstructured, kubeClient dynamic.Interface, ...) (*unstructured.Unstructured, error)
- func DefaultKubeconfig() (string, error)
- func DeleteLabelledPodsInNamespace(namespace string, labels map[string]string, restConfig *rest.Config) error
- func DeletePod(kubeClient dynamic.Interface, mapper *meta.RESTMapper, name, namespace string) error
- func DeleteResource(kubeObject *unstructured.Unstructured, kubeClient dynamic.Interface, ...) error
- func GetAwsConfigFromAwsAccount(encryptionKey, region string, awsAccount *v0.AwsAccount) (*aws.Config, error)
- func GetClient(runtime *v0.KubernetesRuntimeInstance, threeportControlPlane bool, ...) (dynamic.Interface, *meta.RESTMapper, error)
- func GetDiscoveryClient(runtime *v0.KubernetesRuntimeInstance, threeportControlPlane bool, ...) (*discovery.DiscoveryClient, error)
- func GetInClusterKubeClient() (*kubernetes.Clientset, error)
- func GetJsonResourcesFromYamlDoc(yamlDoc string) ([][]byte, error)
- func GetKubeClientForGroupNameVersion(groupName string, groupVersion string) (*rest.RESTClient, error)
- func GetManagedNamespaceNames(kubeClient dynamic.Interface) ([]string, error)
- func GetPodAbstractionKinds() []string
- func GetResource(kubeAPIGroup string, kubeAPIVersion string, kubeKind string, namespace string, ...) (*unstructured.Unstructured, error)
- func GetRestConfig(runtime *v0.KubernetesRuntimeInstance, threeportControlPlane bool, ...) (*rest.Config, error)
- func IsNamespaced(jsonDef string, discoveryClient *discovery.DiscoveryClient) (bool, error)
- func SetNamespaces(workloadResourceInstances *[]v0.WorkloadResourceInstance, ...) (*[]v0.WorkloadResourceInstance, error)
- func UpdateResource(kubeObject *unstructured.Unstructured, kubeClient dynamic.Interface, ...) (*unstructured.Unstructured, error)
- type KubeConnectionInfo
Constants ¶
const ( KubeManagedByLabelValue = "threeport" ThreeportManagedByLabelKey = "control-plane.threeport.io/managed-by" ThreeportManagedByLabelValue = "threeport" )
Variables ¶
This section is empty.
Functions ¶
func AddLabels ¶
func AddLabels( kubeObject *unstructured.Unstructured, definitionName string, instanceName string, instanceId uint, instanceLabelKey string, ) (*unstructured.Unstructured, error)
AddLabels sets the labels used by threeport to identify managed resources in Kubernetes.
func CreateNamespaceWorkloadResourceInstance ¶ added in v0.5.0
func CreateNamespaceWorkloadResourceInstance( namespaceName string, workloadInstanceID uint, ) (*v0.WorkloadResourceInstance, error)
CreateNamespaceWorkloadResourceInstance returns a workload instance for a Kubernetes namespace resource with the desired name.
func CreateOrUpdateResource ¶
func CreateOrUpdateResource( kubeObject *unstructured.Unstructured, kubeClient dynamic.Interface, mapper meta.RESTMapper, ) (*unstructured.Unstructured, error)
CreateOrUpdateResource takes an unstructured object, dynamic client interface and rest mapper and creates the resource in the target Kubernetes cluster if it doesn't already exist. If the resource exists, it is updated.
func CreateResource ¶
func CreateResource( kubeObject *unstructured.Unstructured, kubeClient dynamic.Interface, mapper meta.RESTMapper, ) (*unstructured.Unstructured, error)
CreateResource takes an unstructured object, dynamic client interface and rest mapper and creates the resource in the target Kubernetes cluster. If the object already exists, it returns the object.
func DefaultKubeconfig ¶
DefaultKubeconfig returns the path to the user's default kubeconfig.
func DeleteLabelledPodsInNamespace ¶
func DeleteLabelledPodsInNamespace( namespace string, labels map[string]string, restConfig *rest.Config, ) error
DeleteLabelledPodsInNamespace takes a namespace, set of labels, kube client and mapper and deletes all the pods.
func DeletePod ¶ added in v0.4.0
func DeletePod( kubeClient dynamic.Interface, mapper *meta.RESTMapper, name, namespace string, ) error
DeletePod deletes a pod.
func DeleteResource ¶
func DeleteResource( kubeObject *unstructured.Unstructured, kubeClient dynamic.Interface, mapper meta.RESTMapper, ) error
DeleteResource takes an unstructured object, dynamic client interface and rest mapper and deletes the resource in the target Kubernetes cluster.
func GetAwsConfigFromAwsAccount ¶
func GetAwsConfigFromAwsAccount(encryptionKey, region string, awsAccount *v0.AwsAccount) (*aws.Config, error)
GetAwsConfigFromAwsAccount returns an aws config from an aws account.
func GetClient ¶
func GetClient( runtime *v0.KubernetesRuntimeInstance, threeportControlPlane bool, threeportAPIClient *http.Client, threeportAPIEndpoint string, encryptionKey string, ) (dynamic.Interface, *meta.RESTMapper, error)
GetClient creates a dynamic client interface and rest mapper from a kubernetes cluster instance.
func GetDiscoveryClient ¶
func GetDiscoveryClient( runtime *v0.KubernetesRuntimeInstance, threeportControlPlane bool, threeportAPIClient *http.Client, threeportAPIEndpoint string, encryptionKey string, ) (*discovery.DiscoveryClient, error)
GetDiscoveryClient returns a new discovery client for a kubernetes cluster instance.
func GetInClusterKubeClient ¶
func GetInClusterKubeClient() (*kubernetes.Clientset, error)
GetInClusterKubeClient creates a kubernetes clientset for an in cluster configuration
func GetJsonResourcesFromYamlDoc ¶ added in v0.4.0
GetJsonResourcesFromYamlDoc takes a YAML document with any number of Kubernetes resources defined and returns a slice of JSON objects as byte arrays.
func GetKubeClientForGroupNameVersion ¶
func GetKubeClientForGroupNameVersion(groupName string, groupVersion string) (*rest.RESTClient, error)
GetKubeClientForGroupNameVersion creates a kubernetes rest client for a given group name/version
func GetManagedNamespaceNames ¶
GetManagedNamespaceNames returns the names of the namespaces created and manged for the user by threeport.
func GetPodAbstractionKinds ¶
func GetPodAbstractionKinds() []string
GetPodAbstractionKinds returns the Kuberentes kinds that manaage pods with templates.
func GetResource ¶
func GetResource( kubeAPIGroup string, kubeAPIVersion string, kubeKind string, namespace string, resourceName string, kubeClient dynamic.Interface, mapper meta.RESTMapper, ) (*unstructured.Unstructured, error)
GetResource returns a specific Kubernetes resource. If an empty string for namespace is provided, this function will search for a non-namespaced resource. Namespaced resources must have the namespace provided, even if in the "default" namespace. Core resources should provide "core" or an empty string for kubeAPIGroup.
func GetRestConfig ¶
func GetRestConfig( runtime *v0.KubernetesRuntimeInstance, threeportControlPlane bool, threeportAPIClient *http.Client, threeportAPIEndpoint string, encryptionKey string, ) (*rest.Config, error)
GetRestConfig takes a kubernetes runtime instance and returns a REST config for the kubernetes API.
func IsNamespaced ¶ added in v0.5.0
func IsNamespaced( jsonDef string, discoveryClient *discovery.DiscoveryClient, ) (bool, error)
IsNamespaced returns true if a provided JSON definition represents a namespaced resource in Kubernetes.
func SetNamespaces ¶
func SetNamespaces( workloadResourceInstances *[]v0.WorkloadResourceInstance, workloadInstanceName *string, workloadInstanceID *uint, discoveryClient *discovery.DiscoveryClient, ) (*[]v0.WorkloadResourceInstance, error)
SetNamespaces adds the namespace resource and namespace assignment as needed to an array of workload resource instances.
func UpdateResource ¶
func UpdateResource( kubeObject *unstructured.Unstructured, kubeClient dynamic.Interface, mapper meta.RESTMapper, mapping *meta.RESTMapping, ) (*unstructured.Unstructured, error)
UpdateResource updates a Kubernetes resource.
Types ¶
type KubeConnectionInfo ¶
type KubeConnectionInfo struct { APIEndpoint string CACertificate string Certificate string Key string EKSToken string EKSTokenExpiration time.Time }
KubeConnectionInfo contains the necessary info to connect to a Kubernetes API.
func GetConnectionInfoFromKubeconfig ¶
func GetConnectionInfoFromKubeconfig(kubeconfig string) (*KubeConnectionInfo, error)
GetConnectionInfoFromKubeconfig extracts the Kubernetes API connection info from a kubeconfig.