Documentation ¶
Index ¶
- Constants
- Variables
- func Copy(dst *websocket.Conn, src *websocket.Conn) (int64, error)
- func CopyFrom(dst io.Writer, src *websocket.Conn) (written int64, err error)
- func CopyTo(dst *websocket.Conn, src io.Reader) (written int64, err error)
- func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig
- func Dial(address string, tlsConfig *tls.Config) (*websocket.Conn, *http.Response, error)
- func FlagSet() *flag.FlagSet
- func GetConfig() (*restclient.Config, error)deprecated
- func GetKubevirtClientConfig() (*rest.Config, error)
- func Init()
- func NewUpgrader() *websocket.Upgrader
- func NewWebsocketStreamer(conn *websocket.Conn, done chan struct{}) *wsStreamer
- func RegisterRestConfigHook(fn RestConfigHookFunc)
- func RequestFromConfig(config *rest.Config, resource, name, namespace, subresource string, ...) (*http.Request, error)
- type AsyncSubresourceError
- type ClusterProfiler
- type ExpandSpecInterface
- type GuestfsInfo
- type GuestfsVersion
- type KubeVirtInterface
- type KubevirtClient
- func GetKubevirtClient() (KubevirtClient, error)
- func GetKubevirtClientFromFlags(master string, kubeconfig string) (KubevirtClient, error)
- func GetKubevirtClientFromRESTConfig(config *rest.Config) (KubevirtClient, error)
- func GetKubevirtSubresourceClient() (KubevirtClient, error)
- func GetKubevirtSubresourceClientFromFlags(master string, kubeconfig string) (KubevirtClient, error)
- type ReplicaSetInterface
- type RestConfigHookFunc
- type RoundTripCallback
- type SerialConsoleOptions
- type ServerVersion
- type ServerVersionInterface
- type StreamInterface
- type StreamOptions
- type VirtHandlerClient
- type VirtHandlerConn
- type VirtualMachineInstanceInterface
- type VirtualMachineInstanceMigrationInterface
- type VirtualMachineInstancePresetInterface
- type VirtualMachineInterface
- type WebsocketRoundTripper
Constants ¶
const (
ApiGroupName = "/apis/" + v1.SubresourceGroupName
)
const (
WebsocketMessageBufferSize = 10240
)
Variables ¶
var ( SchemeBuilder runtime.SchemeBuilder Scheme *runtime.Scheme Codecs serializer.CodecFactory ParameterCodec runtime.ParameterCodec )
var GetKubevirtClientFromClientConfig = func(cmdConfig clientcmd.ClientConfig) (KubevirtClient, error) { config, err := cmdConfig.ClientConfig() if err != nil { return nil, err } return GetKubevirtClientFromRESTConfig(config) }
this function is defined as a closure so iut could be overwritten by unit tests
Functions ¶
func DefaultClientConfig ¶
func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig
DefaultClientConfig creates a clientcmd.ClientConfig with the following hierarchy:
Use the kubeconfig builder. The number of merges and overrides here gets a little crazy. Stay with me.
Merge the kubeconfig itself. This is done with the following hierarchy rules:
CommandLineLocation - this parsed from the command line, so it must be late bound. If you specify this, then no other kubeconfig files are merged. This file must exist.
If $KUBECONFIG is set, then it is treated as a list of files that should be merged.
HomeDirectoryLocation Empty filenames are ignored. Files with non-deserializable content produced errors. The first file to set a particular value or map key wins and the value or map key is never changed. This means that the first file to set CurrentContext will have its context preserved. It also means that if two files specify a "red-user", only values from the first file's red-user are used. Even non-conflicting entries from the second file's "red-user" are discarded.
Determine the context to use based on the first hit in this chain
command line argument - again, parsed from the command line, so it must be late bound
CurrentContext from the merged kubeconfig file
Empty is allowed at this stage
Determine the cluster info and auth info to use. At this point, we may or may not have a context. They are built based on the first hit in this chain. (run it twice, once for auth, once for cluster)
command line argument
If context is present, then use the context value
Empty is allowed
Determine the actual cluster info to use. At this point, we may or may not have a cluster info. Build each piece of the cluster info based on the chain:
command line argument
If cluster info is present and a value for the attribute is present, use it.
If you don't have a server location, bail.
Auth info is build using the same rules as cluster info, EXCEPT that you can only have one authentication technique per auth info. The following conditions result in an error:
If there are two conflicting techniques specified from the command line, fail.
If the command line does not specify one, and the auth info has conflicting techniques, fail.
If the command line specifies one and the auth info specifies another, honor the command line technique.
Use default values and potentially prompt for auth information
However, if it appears that we're running in a kubernetes cluster container environment, then run with the auth info kubernetes mounted for us. Specifically: The env vars KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT are set, and the file /var/run/secrets/kubernetes.io/serviceaccount/token exists and is not a directory.
Initially copied from https://github.com/kubernetes/kubernetes/blob/09f321c80bfc9bca63a5530b56d7a1a3ba80ba9b/pkg/kubectl/cmd/util/factory_client_access.go#L174
func GetConfig
deprecated
func GetConfig() (*restclient.Config, error)
Deprecated: Use GetKubevirtClientConfig instead
func GetKubevirtClientConfig ¶
func Init ¶
func Init()
Init adds the default `kubeconfig` and `master` flags. It is not added by default to allow integration into the different controller generators which normally add these flags too.
func NewUpgrader ¶
func NewWebsocketStreamer ¶
func RegisterRestConfigHook ¶
func RegisterRestConfigHook(fn RestConfigHookFunc)
Types ¶
type AsyncSubresourceError ¶
type AsyncSubresourceError struct { StatusCode int // contains filtered or unexported fields }
func (*AsyncSubresourceError) Error ¶
func (a *AsyncSubresourceError) Error() string
func (*AsyncSubresourceError) GetStatusCode ¶
func (a *AsyncSubresourceError) GetStatusCode() int
type ClusterProfiler ¶
type ClusterProfiler struct {
// contains filtered or unexported fields
}
func (*ClusterProfiler) Dump ¶
func (v *ClusterProfiler) Dump(cpRequest *v1.ClusterProfilerRequest) (*v1.ClusterProfilerResults, error)
Dump returns at most cpRequest.PageSize profiler results. To fetch results from all kubevirt pods Dump should be called with Continue fields set to Continue field value from the response to a previous request. This should be repeated until Continue or ComponentsResult field in ClusterProfilerResponse is empty.
func (*ClusterProfiler) Start ¶
func (v *ClusterProfiler) Start() error
func (*ClusterProfiler) Stop ¶
func (v *ClusterProfiler) Stop() error
type ExpandSpecInterface ¶
type ExpandSpecInterface interface {
ForVirtualMachine(vm *v1.VirtualMachine) (*v1.VirtualMachine, error)
}
type GuestfsInfo ¶
type GuestfsVersion ¶
type GuestfsVersion struct {
// contains filtered or unexported fields
}
func (*GuestfsVersion) Get ¶
func (v *GuestfsVersion) Get() (*GuestfsInfo, error)
type KubeVirtInterface ¶
type KubeVirtInterface interface { Get(name string, options *metav1.GetOptions) (*v1.KubeVirt, error) List(opts *metav1.ListOptions) (*v1.KubeVirtList, error) Create(instance *v1.KubeVirt) (*v1.KubeVirt, error) Update(*v1.KubeVirt) (*v1.KubeVirt, error) Delete(name string, options *metav1.DeleteOptions) error Patch(name string, pt types.PatchType, data []byte, patchOptions *metav1.PatchOptions, subresources ...string) (result *v1.KubeVirt, err error) UpdateStatus(*v1.KubeVirt) (*v1.KubeVirt, error) PatchStatus(name string, pt types.PatchType, data []byte, patchOptions *metav1.PatchOptions) (result *v1.KubeVirt, err error) }
type KubevirtClient ¶
type KubevirtClient interface { VirtualMachineInstance(namespace string) VirtualMachineInstanceInterface VirtualMachineInstanceMigration(namespace string) VirtualMachineInstanceMigrationInterface ReplicaSet(namespace string) ReplicaSetInterface VirtualMachinePool(namespace string) poolv1.VirtualMachinePoolInterface VirtualMachine(namespace string) VirtualMachineInterface KubeVirt(namespace string) KubeVirtInterface VirtualMachineInstancePreset(namespace string) VirtualMachineInstancePresetInterface VirtualMachineSnapshot(namespace string) vmsnapshotv1alpha1.VirtualMachineSnapshotInterface VirtualMachineSnapshotContent(namespace string) vmsnapshotv1alpha1.VirtualMachineSnapshotContentInterface VirtualMachineRestore(namespace string) vmsnapshotv1alpha1.VirtualMachineRestoreInterface VirtualMachineExport(namespace string) vmexportv1alpha1.VirtualMachineExportInterface VirtualMachineInstancetype(namespace string) instancetypev1beta1.VirtualMachineInstancetypeInterface VirtualMachineClusterInstancetype() instancetypev1beta1.VirtualMachineClusterInstancetypeInterface VirtualMachinePreference(namespace string) instancetypev1beta1.VirtualMachinePreferenceInterface VirtualMachineClusterPreference() instancetypev1beta1.VirtualMachineClusterPreferenceInterface MigrationPolicy() migrationsv1.MigrationPolicyInterface ExpandSpec(namespace string) ExpandSpecInterface ServerVersion() ServerVersionInterface VirtualMachineClone(namespace string) clonev1alpha1.VirtualMachineCloneInterface ClusterProfiler() *ClusterProfiler GuestfsVersion() *GuestfsVersion RestClient() *rest.RESTClient GeneratedKubeVirtClient() generatedclient.Interface CdiClient() cdiclient.Interface NetworkClient() networkclient.Interface ExtensionsClient() extclient.Interface SecClient() secv1.SecurityV1Interface RouteClient() routev1.RouteV1Interface DiscoveryClient() discovery.DiscoveryInterface PrometheusClient() promclient.Interface KubernetesSnapshotClient() k8ssnapshotclient.Interface DynamicClient() dynamic.Interface MigrationPolicyClient() *migrationsv1.MigrationsV1alpha1Client kubernetes.Interface Config() *rest.Config }
func GetKubevirtClient ¶
func GetKubevirtClient() (KubevirtClient, error)
func GetKubevirtClientFromFlags ¶
func GetKubevirtClientFromFlags(master string, kubeconfig string) (KubevirtClient, error)
func GetKubevirtClientFromRESTConfig ¶
func GetKubevirtClientFromRESTConfig(config *rest.Config) (KubevirtClient, error)
func GetKubevirtSubresourceClient ¶
func GetKubevirtSubresourceClient() (KubevirtClient, error)
func GetKubevirtSubresourceClientFromFlags ¶
func GetKubevirtSubresourceClientFromFlags(master string, kubeconfig string) (KubevirtClient, error)
type ReplicaSetInterface ¶
type ReplicaSetInterface interface { Get(name string, options metav1.GetOptions) (*v1.VirtualMachineInstanceReplicaSet, error) List(opts metav1.ListOptions) (*v1.VirtualMachineInstanceReplicaSetList, error) Create(*v1.VirtualMachineInstanceReplicaSet) (*v1.VirtualMachineInstanceReplicaSet, error) Update(*v1.VirtualMachineInstanceReplicaSet) (*v1.VirtualMachineInstanceReplicaSet, error) Delete(name string, options *metav1.DeleteOptions) error GetScale(replicaSetName string, options metav1.GetOptions) (*autov1.Scale, error) UpdateScale(replicaSetName string, scale *autov1.Scale) (*autov1.Scale, error) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.VirtualMachineInstanceReplicaSet, err error) UpdateStatus(*v1.VirtualMachineInstanceReplicaSet) (*v1.VirtualMachineInstanceReplicaSet, error) PatchStatus(name string, pt types.PatchType, data []byte) (result *v1.VirtualMachineInstanceReplicaSet, err error) }
type RestConfigHookFunc ¶
type RoundTripCallback ¶
type SerialConsoleOptions ¶
type ServerVersion ¶
type ServerVersion struct {
// contains filtered or unexported fields
}
type ServerVersionInterface ¶
type StreamInterface ¶
type StreamInterface interface { Stream(options StreamOptions) error AsConn() net.Conn }
type VirtHandlerClient ¶
type VirtHandlerClient interface { ForNode(nodeName string) VirtHandlerConn Port(port int) VirtHandlerClient Namespace(namespace string) VirtHandlerClient }
func NewVirtHandlerClient ¶
func NewVirtHandlerClient(virtCli KubevirtClient, httpCli *http.Client) VirtHandlerClient
type VirtHandlerConn ¶
type VirtHandlerConn interface { ConnectionDetails() (ip string, port int, err error) ConsoleURI(vmi *virtv1.VirtualMachineInstance) (string, error) USBRedirURI(vmi *virtv1.VirtualMachineInstance) (string, error) VNCURI(vmi *virtv1.VirtualMachineInstance) (string, error) VSOCKURI(vmi *virtv1.VirtualMachineInstance, port string, tls string) (string, error) PauseURI(vmi *virtv1.VirtualMachineInstance) (string, error) UnpauseURI(vmi *virtv1.VirtualMachineInstance) (string, error) FreezeURI(vmi *virtv1.VirtualMachineInstance) (string, error) UnfreezeURI(vmi *virtv1.VirtualMachineInstance) (string, error) SoftRebootURI(vmi *virtv1.VirtualMachineInstance) (string, error) SEVFetchCertChainURI(vmi *virtv1.VirtualMachineInstance) (string, error) SEVQueryLaunchMeasurementURI(vmi *virtv1.VirtualMachineInstance) (string, error) SEVInjectLaunchSecretURI(vmi *virtv1.VirtualMachineInstance) (string, error) Pod() (pod *v1.Pod, err error) Put(url string, body io.ReadCloser) error Get(url string) (string, error) GuestInfoURI(vmi *virtv1.VirtualMachineInstance) (string, error) UserListURI(vmi *virtv1.VirtualMachineInstance) (string, error) FilesystemListURI(vmi *virtv1.VirtualMachineInstance) (string, error) }
type VirtualMachineInstanceInterface ¶
type VirtualMachineInstanceInterface interface { Get(ctx context.Context, name string, options *metav1.GetOptions) (*v1.VirtualMachineInstance, error) List(ctx context.Context, opts *metav1.ListOptions) (*v1.VirtualMachineInstanceList, error) Create(ctx context.Context, instance *v1.VirtualMachineInstance) (*v1.VirtualMachineInstance, error) Update(ctx context.Context, instance *v1.VirtualMachineInstance) (*v1.VirtualMachineInstance, error) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) error Patch(ctx context.Context, name string, pt types.PatchType, data []byte, patchOptions *metav1.PatchOptions, subresources ...string) (result *v1.VirtualMachineInstance, err error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) SerialConsole(name string, options *SerialConsoleOptions) (StreamInterface, error) USBRedir(vmiName string) (StreamInterface, error) VNC(name string) (StreamInterface, error) Screenshot(ctx context.Context, name string, options *v1.ScreenshotOptions) ([]byte, error) PortForward(name string, port int, protocol string) (StreamInterface, error) Pause(ctx context.Context, name string, pauseOptions *v1.PauseOptions) error Unpause(ctx context.Context, name string, unpauseOptions *v1.UnpauseOptions) error Freeze(ctx context.Context, name string, unfreezeTimeout time.Duration) error Unfreeze(ctx context.Context, name string) error SoftReboot(ctx context.Context, name string) error GuestOsInfo(ctx context.Context, name string) (v1.VirtualMachineInstanceGuestAgentInfo, error) UserList(ctx context.Context, name string) (v1.VirtualMachineInstanceGuestOSUserList, error) FilesystemList(ctx context.Context, name string) (v1.VirtualMachineInstanceFileSystemList, error) AddVolume(ctx context.Context, name string, addVolumeOptions *v1.AddVolumeOptions) error RemoveVolume(ctx context.Context, name string, removeVolumeOptions *v1.RemoveVolumeOptions) error VSOCK(name string, options *v1.VSOCKOptions) (StreamInterface, error) SEVFetchCertChain(name string) (v1.SEVPlatformInfo, error) SEVQueryLaunchMeasurement(name string) (v1.SEVMeasurementInfo, error) SEVSetupSession(name string, sevSessionOptions *v1.SEVSessionOptions) error SEVInjectLaunchSecret(name string, sevSecretOptions *v1.SEVSecretOptions) error }
type VirtualMachineInstanceMigrationInterface ¶
type VirtualMachineInstanceMigrationInterface interface { Get(name string, options *metav1.GetOptions) (*v1.VirtualMachineInstanceMigration, error) List(opts *metav1.ListOptions) (*v1.VirtualMachineInstanceMigrationList, error) Create(migration *v1.VirtualMachineInstanceMigration, options *metav1.CreateOptions) (*v1.VirtualMachineInstanceMigration, error) Update(*v1.VirtualMachineInstanceMigration) (*v1.VirtualMachineInstanceMigration, error) Delete(name string, options *metav1.DeleteOptions) error Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.VirtualMachineInstanceMigration, err error) UpdateStatus(*v1.VirtualMachineInstanceMigration) (*v1.VirtualMachineInstanceMigration, error) PatchStatus(name string, pt types.PatchType, data []byte) (result *v1.VirtualMachineInstanceMigration, err error) }
type VirtualMachineInstancePresetInterface ¶
type VirtualMachineInstancePresetInterface interface { Get(name string, options metav1.GetOptions) (*v1.VirtualMachineInstancePreset, error) List(opts metav1.ListOptions) (*v1.VirtualMachineInstancePresetList, error) Create(*v1.VirtualMachineInstancePreset) (*v1.VirtualMachineInstancePreset, error) Update(*v1.VirtualMachineInstancePreset) (*v1.VirtualMachineInstancePreset, error) Delete(name string, options *metav1.DeleteOptions) error Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.VirtualMachineInstancePreset, err error) }
type VirtualMachineInterface ¶
type VirtualMachineInterface interface { Get(ctx context.Context, name string, options *metav1.GetOptions) (*v1.VirtualMachine, error) GetWithExpandedSpec(ctx context.Context, name string) (*v1.VirtualMachine, error) List(ctx context.Context, opts *metav1.ListOptions) (*v1.VirtualMachineList, error) Create(ctx context.Context, vm *v1.VirtualMachine) (*v1.VirtualMachine, error) Update(ctx context.Context, vm *v1.VirtualMachine) (*v1.VirtualMachine, error) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) error Patch(ctx context.Context, name string, pt types.PatchType, data []byte, patchOptions *metav1.PatchOptions, subresources ...string) (result *v1.VirtualMachine, err error) UpdateStatus(ctx context.Context, vm *v1.VirtualMachine) (*v1.VirtualMachine, error) PatchStatus(ctx context.Context, name string, pt types.PatchType, data []byte, patchOptions *metav1.PatchOptions) (result *v1.VirtualMachine, err error) Restart(ctx context.Context, name string, restartOptions *v1.RestartOptions) error ForceRestart(ctx context.Context, name string, restartOptions *v1.RestartOptions) error Start(ctx context.Context, name string, startOptions *v1.StartOptions) error Stop(ctx context.Context, name string, stopOptions *v1.StopOptions) error ForceStop(ctx context.Context, name string, stopOptions *v1.StopOptions) error Migrate(ctx context.Context, name string, migrateOptions *v1.MigrateOptions) error AddVolume(ctx context.Context, name string, addVolumeOptions *v1.AddVolumeOptions) error RemoveVolume(ctx context.Context, name string, removeVolumeOptions *v1.RemoveVolumeOptions) error PortForward(name string, port int, protocol string) (StreamInterface, error) MemoryDump(ctx context.Context, name string, memoryDumpRequest *v1.VirtualMachineMemoryDumpRequest) error RemoveMemoryDump(ctx context.Context, name string) error }
VirtualMachineInterface provides convenience methods to work with virtual machines inside the cluster
type WebsocketRoundTripper ¶
type WebsocketRoundTripper struct { Dialer *websocket.Dialer Do RoundTripCallback }