Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
Add to import image from local
Browse files Browse the repository at this point in the history
- add localuploadproxy crd to import local image to pvc
- add local source to vmim
  • Loading branch information
hyoung-90 committed Aug 24, 2020
1 parent 1b64879 commit ca18dd3
Show file tree
Hide file tree
Showing 23 changed files with 966 additions and 21 deletions.
8 changes: 8 additions & 0 deletions dbox
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ da)
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumes_crd.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachinevolumeexport_cr.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumeexports_crd.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_localuploadproxy_cr.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_localuploadproxies_crd.yaml --ignore-not-found=true
;;
dcr)
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachineimage_cr.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachinevolume_cr.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachinevolumeexport_cr.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_localuploadproxy_cr.yaml --ignore-not-found=true
;;
dcrd)
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_virtualmachineimages_crd.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumes_crd.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumeexports_crd.yaml --ignore-not-found=true
kubectl delete -f deploy/crds/hypercloud.tmaxanc.com_localuploadproxies_crd.yaml --ignore-not-found=true
;;
do)
;;
Expand All @@ -36,16 +40,20 @@ aa)
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachinevolume_cr.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumeexports_crd.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachinevolumeexport_cr.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_localuploadproxies_crd.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_localuploadproxy_cr.yaml
;;
acr)
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachineimage_cr.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachinevolume_cr.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachinevolumeexport_cr.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_localuploadproxy_cr.yaml
;;
acrd)
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_virtualmachineimages_crd.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumes_crd.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumeexports_crd.yaml
kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_localuploadproxies_crd.yaml
;;
*)
echo " $0 [command]
Expand Down
230 changes: 230 additions & 0 deletions deploy/crds/hypercloud.tmaxanc.com_localuploadproxies_crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: localuploadproxies.hypercloud.tmaxanc.com
spec:
additionalPrinterColumns:
- JSONPath: .status.conditions[0].status
description: Current status of LocalUploadProxy
name: ReadyToUse
type: string
- JSONPath: .status.command
description: Command used for image upload
name: Command
type: string
group: hypercloud.tmaxanc.com
names:
kind: LocalUploadProxy
listKind: LocalUploadProxyList
plural: localuploadproxies
shortNames:
- lup
singular: localuploadproxy
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: LocalUploadProxy is the Schema for the localuploadproxies API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: LocalUploadProxySpec defines the desired state of LocalUploadProxy
properties:
pvc:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "operator-sdk generate k8s" to regenerate code after
modifying this file Add custom validation using kubebuilder tags:
https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html'
properties:
accessModes:
description: 'AccessModes contains the desired access modes the
volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1'
items:
type: string
type: array
dataSource:
description: This field requires the VolumeSnapshotDataSource alpha
feature gate to be enabled and currently VolumeSnapshot is the
only supported data source. If the provisioner can support VolumeSnapshot
data source, it will create a new volume and data will be restored
to the volume at the same time. If the provisioner does not support
VolumeSnapshot data source, volume will not be created and the
failure will be reported as an event. In the future, we plan to
support more data source types and the behavior of the provisioner
may change.
properties:
apiGroup:
description: APIGroup is the group for the resource being referenced.
If APIGroup is not specified, the specified Kind must be in
the core API group. For any other third-party types, APIGroup
is required.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
required:
- kind
- name
type: object
resources:
description: 'Resources represents the minimum resources the volume
should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources'
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute
resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
selector:
description: A label query over volumes to consider for binding.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the
key and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a
strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
storageClassName:
description: 'Name of the StorageClass required by the claim. More
info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1'
type: string
volumeMode:
description: volumeMode defines what type of volume is required
by the claim. Value of Filesystem is implied when not included
in claim spec. This is a beta feature.
type: string
volumeName:
description: VolumeName is the binding reference to the PersistentVolume
backing this claim.
type: string
type: object
required:
- pvc
type: object
status:
description: LocalUploadProxyStatus defines the observed state of LocalUploadProxy
properties:
command:
type: string
conditions:
description: Conditions indicate current conditions of LocalUploadProxy
items:
description: Condition indicates observed condition of an object
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed. If
that is not known, then using the time when the API field changed
is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
type: string
observedGeneration:
description: If set, this represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.condition[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
type: integer
reason:
description: The reason for the condition's last transition in
CamelCase. The specific API may choose whether or not this field
is considered a guaranteed API. This field may not be empty.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: hypercloud.tmaxanc.com/v1alpha1
kind: LocalUploadProxy
metadata:
name: myubuntu
spec:
pvc:
volumeMode: Block
accessModes:
- ReadWriteMany
resources:
requests:
storage: "3Gi"
storageClassName: rook-ceph-block
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: hypercloud.tmaxanc.com/v1alpha1
kind: VirtualMachineImage
metadata:
name: localvmim
spec:
source:
# The name of the localUploadProxy used when uploading the raw image
local: myubuntu
# The name of the snapshotClass to be used for provisioning snapshots
snapshotClassName: csi-rbdplugin-snapclass
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ spec:
properties:
http:
type: string
required:
- http
local:
type: string
type: object
required:
- pvc
- snapshotClassName
- source
type: object
Expand Down Expand Up @@ -227,6 +226,8 @@ spec:
- type
type: object
type: array
pvcName:
type: string
state:
description: State is the current state of VirtualMachineImage
type: string
Expand Down
1 change: 1 addition & 0 deletions deploy/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ rules:
- '*'
- virtualmachinevolumes
- virtualmachinevolumeexports
- localuploadproxies
verbs:
- create
- delete
Expand Down
28 changes: 27 additions & 1 deletion docs/USERGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ $ git checkout v1.0.0
$ kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_virtualmachineimages_crd.yaml
$ kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumes_crd.yaml
$ kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_virtualmachinevolumeexports_crd.yaml
$ kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_localuploadproxies_crd.yaml

# Deploy operator
$ kubectl apply -f deploy/role.yaml
Expand All @@ -57,7 +58,9 @@ kubevirt-image-service 3/3 3 3 23s

# Use Kubevirt-Image-Service

## Import image from HTTP source
## Import image

### 1. Import image from HTTP source

vmim is the shortname for `VirtualMachineImage`.

Expand All @@ -71,6 +74,29 @@ NAME STATE
myubuntu Available
```

### 2. Import image from Local source

```shell
# Deploy local upload proxy CR.
$ kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_localuploadproxy_cr.yaml

# Wait until local upload proxy is ready to use and the command is not null
$ kubectl get lup
NAME READYTOUSE COMMAND
myubuntu True < /filePath/file.name kubectl exec -i myubuntu-upload-pod -n default -- dd of=/dev/block-volume

# Change the `/filePath/file.name` in the command string and execute the command to upload the raw type image
$ < image.raw kubectl exec -i myubuntu-upload-pod -n default -- dd of=/dev/block-volume

# Deploy image CR.
$ kubectl apply -f deploy/crds/hypercloud.tmaxanc.com_v1alpha1_virtualmachineimage_local_cr.yaml

# Wait until image state is ready to use
$ kubectl get vmim
NAME STATE
localvmim Available
```

## Create volume from image

vmv is the shortname for `VirtualMachineVolume`.
Expand Down
Loading

0 comments on commit ca18dd3

Please sign in to comment.