Documentation
¶
Index ¶
- Constants
- func CreateDeploymentManifest(public *models.DeploymentPublic) *appsv1.Deployment
- func CreateHpaManifest(public *models.HpaPublic) *autoscalingv2.HorizontalPodAutoscaler
- func CreateIngressManifest(public *models.IngressPublic) *networkingv1.Ingress
- func CreateJobManifest(public *models.JobPublic) *v1.Job
- func CreateNamespaceManifest(public *models.NamespacePublic) *apiv1.Namespace
- func CreateNetworkPolicyManifest(public *models.NetworkPolicyPublic) *networkingv1.NetworkPolicy
- func CreatePvManifest(public *models.PvPublic) *apiv1.PersistentVolume
- func CreatePvcManifest(public *models.PvcPublic) *apiv1.PersistentVolumeClaim
- func CreateSecretManifest(public *models.SecretPublic) *apiv1.Secret
- func CreateServiceManifest(public *models.ServicePublic) *apiv1.Service
- func CreateVmManifest(public *models.VmPublic, resourceVersion ...string) *kubevirtv1.VirtualMachine
- func CreateVmSnapshotManifest(public *models.VmSnapshotPublic) *snapshotalpha1.VirtualMachineSnapshot
- func GetLabel(labels map[string]string, key string) string
- func IsHasBeenModifiedErr(err error) bool
- func IsImmutabilityErr(err error) bool
- func IsNotFoundErr(err error) bool
- type Client
- func (client *Client) CountPods() (int, error)
- func (client *Client) CreateDeployment(public *models.DeploymentPublic) (*models.DeploymentPublic, error)
- func (client *Client) CreateHPA(public *models.HpaPublic) (*models.HpaPublic, error)
- func (client *Client) CreateIngress(public *models.IngressPublic) (*models.IngressPublic, error)
- func (client *Client) CreateJob(public *models.JobPublic) (*models.JobPublic, error)
- func (client *Client) CreateNamespace(public *models.NamespacePublic) (*models.NamespacePublic, error)
- func (client *Client) CreateNetworkPolicy(public *models.NetworkPolicyPublic) (*models.NetworkPolicyPublic, error)
- func (client *Client) CreateOneShotJob(public *models.JobPublic) error
- func (client *Client) CreatePV(public *models.PvPublic) (*models.PvPublic, error)
- func (client *Client) CreatePVC(public *models.PvcPublic) (*models.PvcPublic, error)
- func (client *Client) CreateSecret(public *models.SecretPublic) (*models.SecretPublic, error)
- func (client *Client) CreateService(public *models.ServicePublic) (*models.ServicePublic, error)
- func (client *Client) CreateVM(public *models.VmPublic) (*models.VmPublic, error)
- func (client *Client) CreateVmSnapshot(public *models.VmSnapshotPublic) (*models.VmSnapshotPublic, error)
- func (client *Client) DeleteDeployment(name string) error
- func (client *Client) DeleteHPA(name string) error
- func (client *Client) DeleteIngress(name string) error
- func (client *Client) DeleteJob(name string) error
- func (client *Client) DeleteNamespace(name string) error
- func (client *Client) DeleteNamespaceIfEmpty(name string) error
- func (client *Client) DeleteNetworkPolicy(name string) error
- func (client *Client) DeletePV(name string) error
- func (client *Client) DeletePVC(name string) error
- func (client *Client) DeleteSecret(name string) error
- func (client *Client) DeleteService(name string) error
- func (client *Client) DeleteVM(id string) error
- func (client *Client) DeleteVMIs(vmID string) error
- func (client *Client) DeleteVmSnapshot(id string) error
- func (client *Client) ListDeploymentStatus() ([]*models.DeploymentStatus, error)
- func (client *Client) ListNodes() ([]models.NodePublic, error)
- func (client *Client) ListPods() ([]models.PodPublic, error)
- func (client *Client) ListVmStatus() ([]*models.VmStatus, error)
- func (client *Client) ListVmiStatus() ([]*models.VmiStatus, error)
- func (client *Client) PodExists(podName string) (bool, error)
- func (client *Client) ReadAllNamespaces(prefix *string) ([]models.NamespacePublic, error)
- func (client *Client) ReadDeployment(name string) (*models.DeploymentPublic, error)
- func (client *Client) ReadHPA(name string) (*models.HpaPublic, error)
- func (client *Client) ReadIngress(name string) (*models.IngressPublic, error)
- func (client *Client) ReadJob(name string) (*models.JobPublic, error)
- func (client *Client) ReadNamespace(name string) (*models.NamespacePublic, error)
- func (client *Client) ReadNetworkPolicy(name string) (*models.NetworkPolicyPublic, error)
- func (client *Client) ReadNode(name string) (*models.NodePublic, error)
- func (client *Client) ReadPV(name string) (*models.PvPublic, error)
- func (client *Client) ReadPVC(name string) (*models.PvcPublic, error)
- func (client *Client) ReadSecret(name string) (*models.SecretPublic, error)
- func (client *Client) ReadService(name string) (*models.ServicePublic, error)
- func (client *Client) ReadVM(id string) (*models.VmPublic, error)
- func (client *Client) ReadVmSnapshot(id string) (*models.VmSnapshotPublic, error)
- func (client *Client) ReadVmSnapshots(vmID string) ([]*models.VmSnapshotPublic, error)
- func (client *Client) RestartDeployment(name string) error
- func (client *Client) SetPermittedHostDevices(devices models.PermittedHostDevices) error
- func (client *Client) SetupPodLogStream(ctx context.Context, podName string, from time.Time, ...) error
- func (client *Client) SetupPodWatcher(ctx context.Context, callback func(podName, event string)) error
- func (client *Client) SetupStatusWatcher(ctx context.Context, resourceType string, handler func(string, interface{}), ...) error
- func (client *Client) UpdateDeployment(public *models.DeploymentPublic) (*models.DeploymentPublic, error)
- func (client *Client) UpdateHPA(public *models.HpaPublic) (*models.HpaPublic, error)
- func (client *Client) UpdateIngress(public *models.IngressPublic) (*models.IngressPublic, error)
- func (client *Client) UpdateNamespace(public *models.NamespacePublic) (*models.NamespacePublic, error)
- func (client *Client) UpdateNetworkPolicy(public *models.NetworkPolicyPublic) (*models.NetworkPolicyPublic, error)
- func (client *Client) UpdateSecret(public *models.SecretPublic) (*models.SecretPublic, error)
- func (client *Client) UpdateService(public *models.ServicePublic) (*models.ServicePublic, error)
- func (client *Client) UpdateVM(public *models.VmPublic) (*models.VmPublic, error)
- type ClientConf
Constants ¶
const ( // PodEventAdded is emitted when a pod is added PodEventAdded = "added" // PodEventDeleted is emitted when a pod is deleted PodEventDeleted = "deleted" // PodEventUpdated is emitted when a pod is updated PodEventUpdated = "updated" )
Variables ¶
This section is empty.
Functions ¶
func CreateDeploymentManifest ¶
func CreateDeploymentManifest(public *models.DeploymentPublic) *appsv1.Deployment
CreateDeploymentManifest creates a Kubernetes Deployment manifest from a models.DeploymentPublic.
func CreateHpaManifest ¶
func CreateHpaManifest(public *models.HpaPublic) *autoscalingv2.HorizontalPodAutoscaler
CreateHpaManifest creates a Kubernetes HorizontalPodAutoscaler manifest from a models.HpaPublic.
func CreateIngressManifest ¶
func CreateIngressManifest(public *models.IngressPublic) *networkingv1.Ingress
CreateIngressManifest creates a Kubernetes Ingress manifest from a models.IngressPublic.
func CreateJobManifest ¶
CreateJobManifest creates a Kubernetes Job manifest from a models.JobPublic.
func CreateNamespaceManifest ¶
func CreateNamespaceManifest(public *models.NamespacePublic) *apiv1.Namespace
CreateNamespaceManifest creates a Kubernetes Namespace manifest from a models.NamespacePublic.
func CreateNetworkPolicyManifest ¶
func CreateNetworkPolicyManifest(public *models.NetworkPolicyPublic) *networkingv1.NetworkPolicy
CreateNetworkPolicyManifest creates a Kubernetes NetworkPolicy manifest from a models.NetworkPolicyPublic.
func CreatePvManifest ¶
func CreatePvManifest(public *models.PvPublic) *apiv1.PersistentVolume
CreatePvManifest creates a Kubernetes PersistentVolume manifest from a models.PvPublic.
func CreatePvcManifest ¶
func CreatePvcManifest(public *models.PvcPublic) *apiv1.PersistentVolumeClaim
CreatePvcManifest creates a Kubernetes PersistentVolumeClaim manifest from a models.PvcPublic.
func CreateSecretManifest ¶
func CreateSecretManifest(public *models.SecretPublic) *apiv1.Secret
CreateSecretManifest creates a Kubernetes Secret manifest from a models.SecretPublic.
func CreateServiceManifest ¶
func CreateServiceManifest(public *models.ServicePublic) *apiv1.Service
CreateServiceManifest creates a Kubernetes Service manifest from a models.ServicePublic.
func CreateVmManifest ¶
func CreateVmManifest(public *models.VmPublic, resourceVersion ...string) *kubevirtv1.VirtualMachine
CreateVmManifest creates a Kubernetes VirtualMachine manifest from a models.VmPublic.
func CreateVmSnapshotManifest ¶
func CreateVmSnapshotManifest(public *models.VmSnapshotPublic) *snapshotalpha1.VirtualMachineSnapshot
CreateVmSnapshotManifest creates a Kubernetes VirtualMachineSnapshot manifest from a models.VmSnapshotPublic.
func GetLabel ¶
GetLabel returns the value of a label from a map. If the label does not exist, an empty string is returned.
func IsHasBeenModifiedErr ¶
IsHasBeenModifiedErr returns true if the error is a Kubernetes HasBeenModified error.
func IsImmutabilityErr ¶
IsImmutabilityErr returns true if the error is a Kubernetes Immutability error.
func IsNotFoundErr ¶
IsNotFoundErr returns true if the error is a Kubernetes NotFound error.
Types ¶
type Client ¶
type Client struct { K8sClient *kubernetes.Clientset KubeVirtK8sClient *kubevirt.Clientset Namespace string }
Client is a wrapper around the Kubernetes client.
func (*Client) CreateDeployment ¶
func (client *Client) CreateDeployment(public *models.DeploymentPublic) (*models.DeploymentPublic, error)
CreateDeployment creates a deployment in Kubernetes.
func (*Client) CreateIngress ¶
func (client *Client) CreateIngress(public *models.IngressPublic) (*models.IngressPublic, error)
CreateIngress creates a Ingress in Kubernetes.
func (*Client) CreateNamespace ¶
func (client *Client) CreateNamespace(public *models.NamespacePublic) (*models.NamespacePublic, error)
CreateNamespace creates a Namespace in Kubernetes.
func (*Client) CreateNetworkPolicy ¶
func (client *Client) CreateNetworkPolicy(public *models.NetworkPolicyPublic) (*models.NetworkPolicyPublic, error)
func (*Client) CreateOneShotJob ¶
CreateOneShotJob creates a Job in Kubernetes that runs once and then deletes itself.
This is useful for running tasks, such as creating NFS PVs, that should only be run once.
This function is blocking.
func (*Client) CreateSecret ¶
func (client *Client) CreateSecret(public *models.SecretPublic) (*models.SecretPublic, error)
CreateSecret creates a Secret in Kubernetes.
func (*Client) CreateService ¶
func (client *Client) CreateService(public *models.ServicePublic) (*models.ServicePublic, error)
CreateService creates a Service in Kubernetes.
func (*Client) CreateVmSnapshot ¶
func (client *Client) CreateVmSnapshot(public *models.VmSnapshotPublic) (*models.VmSnapshotPublic, error)
func (*Client) DeleteDeployment ¶
DeleteDeployment deletes a deployment in Kubernetes.
func (*Client) DeleteIngress ¶
DeleteIngress deletes a Ingress in Kubernetes.
func (*Client) DeleteNamespace ¶
DeleteNamespace deletes a Namespace in Kubernetes.
func (*Client) DeleteNamespaceIfEmpty ¶
DeleteNamespaceIfEmpty deletes a Namespace in Kubernetes if it is empty.
func (*Client) DeleteNetworkPolicy ¶
func (*Client) DeleteSecret ¶
DeleteSecret deletes a Secret in Kubernetes.
func (*Client) DeleteService ¶
DeleteService deletes a Service in Kubernetes.
func (*Client) DeleteVMIs ¶
DeleteVMIs deletes all VMIs for a VM.
It assumes that the VirtualMachine parent has the same name as the VMIs.
func (*Client) DeleteVmSnapshot ¶
func (*Client) ListDeploymentStatus ¶
func (client *Client) ListDeploymentStatus() ([]*models.DeploymentStatus, error)
ListDeploymentStatus returns a list of deployment statuses in Kubernetes.
func (*Client) ListVmStatus ¶
ListVmStatus returns the statuses of all VMs.
func (*Client) ListVmiStatus ¶
ListVmiStatus returns the statuses of all VMIs.
func (*Client) ReadAllNamespaces ¶
func (client *Client) ReadAllNamespaces(prefix *string) ([]models.NamespacePublic, error)
ReadAllNamespaces reads all namespaces from Kubernetes. If prefix is supplied, only namespaces with that prefix will be returned.
func (*Client) ReadDeployment ¶
func (client *Client) ReadDeployment(name string) (*models.DeploymentPublic, error)
ReadDeployment reads a deployment from Kubernetes.
func (*Client) ReadIngress ¶
func (client *Client) ReadIngress(name string) (*models.IngressPublic, error)
ReadIngress reads a Ingress from Kubernetes.
func (*Client) ReadNamespace ¶
func (client *Client) ReadNamespace(name string) (*models.NamespacePublic, error)
ReadNamespace reads a Namespace from Kubernetes.
func (*Client) ReadNetworkPolicy ¶
func (client *Client) ReadNetworkPolicy(name string) (*models.NetworkPolicyPublic, error)
func (*Client) ReadNode ¶
func (client *Client) ReadNode(name string) (*models.NodePublic, error)
ReadNode returns the node with the given name
func (*Client) ReadSecret ¶
func (client *Client) ReadSecret(name string) (*models.SecretPublic, error)
ReadSecret reads a Secret from Kubernetes.
func (*Client) ReadService ¶
func (client *Client) ReadService(name string) (*models.ServicePublic, error)
ReadService reads a Service from Kubernetes.
func (*Client) ReadVmSnapshot ¶
func (client *Client) ReadVmSnapshot(id string) (*models.VmSnapshotPublic, error)
func (*Client) ReadVmSnapshots ¶
func (client *Client) ReadVmSnapshots(vmID string) ([]*models.VmSnapshotPublic, error)
func (*Client) RestartDeployment ¶
RestartDeployment restarts a deployment in Kubernetes. This is done by updating the deployment's annotation `kubectl.kubernetes.io/restartedAt` to the current time.
func (*Client) SetPermittedHostDevices ¶
func (client *Client) SetPermittedHostDevices(devices models.PermittedHostDevices) error
func (*Client) SetupPodLogStream ¶
func (client *Client) SetupPodLogStream(ctx context.Context, podName string, from time.Time, onLog func(deploymentName string, lines []models.LogLine)) error
SetupPodLogStream reads logs from a pod and sends them to the callback function
func (*Client) SetupPodWatcher ¶
func (client *Client) SetupPodWatcher(ctx context.Context, callback func(podName, event string)) error
SetupPodWatcher is a function that sets up a pod watcher with a callback. It triggers the callback when a pod event occurs.
func (*Client) SetupStatusWatcher ¶
func (client *Client) SetupStatusWatcher(ctx context.Context, resourceType string, handler func(string, interface{}), opts ...opts.WatcherOpts) error
SetupStatusWatcher sets up a status watcher for a given resource type in a namespace
This should only be called once per cluster
func (*Client) UpdateDeployment ¶
func (client *Client) UpdateDeployment(public *models.DeploymentPublic) (*models.DeploymentPublic, error)
UpdateDeployment updates a deployment in Kubernetes.
func (*Client) UpdateIngress ¶
func (client *Client) UpdateIngress(public *models.IngressPublic) (*models.IngressPublic, error)
UpdateIngress updates a Ingress in Kubernetes.
func (*Client) UpdateNamespace ¶
func (client *Client) UpdateNamespace(public *models.NamespacePublic) (*models.NamespacePublic, error)
UpdateNamespace updates a Namespace in Kubernetes.
func (*Client) UpdateNetworkPolicy ¶
func (client *Client) UpdateNetworkPolicy(public *models.NetworkPolicyPublic) (*models.NetworkPolicyPublic, error)
func (*Client) UpdateSecret ¶
func (client *Client) UpdateSecret(public *models.SecretPublic) (*models.SecretPublic, error)
UpdateSecret updates a Secret in Kubernetes.
func (*Client) UpdateService ¶
func (client *Client) UpdateService(public *models.ServicePublic) (*models.ServicePublic, error)
UpdateService updates a Service in Kubernetes.
type ClientConf ¶
type ClientConf struct { K8sClient *kubernetes.Clientset KubeVirtK8sClient *kubevirt.Clientset Namespace string }
ClientConf is the configuration for the Kubernetes wrapper client.