Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vi): add snapshot objectRef #617

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions api/core/v1alpha2/virtual_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type VirtualImageStatus struct {
UploadCommand string `json:"uploadCommand,omitempty"`
ImageUploadURLs *ImageUploadURLs `json:"imageUploadURLs,omitempty"`
Target VirtualImageStatusTarget `json:"target,omitempty"`
// UID of the source (VirtualImage, ClusterVirtualImage, or VirtualDisk) used when creating the virtual image.
// UID of the source (VirtualImage, ClusterVirtualImage, VirtualDisk or VirtualDiskSnapshot) used when creating the virtual image.
SourceUID *types.UID `json:"sourceUID,omitempty"`
// The latest available observations of an object's current state.
Conditions []metav1.Condition `json:"conditions,omitempty"`
Expand Down Expand Up @@ -139,21 +139,22 @@ type VirtualImageContainerImage struct {
CABundle []byte `json:"caBundle,omitempty"`
}

// Use an existing VirtualImage, ClusterVirtualImage, or VirtualDisk resource to create an image.
// Use an existing VirtualImage, ClusterVirtualImage, VirtualDisk or VirtualDiskSnapshot resource to create an image.
type VirtualImageObjectRef struct {
// Kind of an existing VirtualImage, ClusterVirtualImage, or VirtualDisk resource.
// Kind of an existing VirtualImage, ClusterVirtualImage, VirtualDisk or VirtualDiskSnapshot resource.
Kind VirtualImageObjectRefKind `json:"kind"`
// Name of an existing VirtualImage, ClusterVirtualImage, or VirtualDisk resource.
// Name of an existing VirtualImage, ClusterVirtualImage, VirtualDisk or VirtualDiskSnapshot resource.
Name string `json:"name"`
}

// +kubebuilder:validation:Enum:={ClusterVirtualImage,VirtualImage,VirtualDisk}
// +kubebuilder:validation:Enum:={ClusterVirtualImage,VirtualImage,VirtualDisk,VirtualDiskSnapshot}
type VirtualImageObjectRefKind string

const (
VirtualImageObjectRefKindVirtualImage VirtualImageObjectRefKind = "VirtualImage"
VirtualImageObjectRefKindClusterVirtualImage VirtualImageObjectRefKind = "ClusterVirtualImage"
VirtualImageObjectRefKindVirtualDisk VirtualImageObjectRefKind = "VirtualDisk"
VirtualImageObjectRefKindVirtualDiskSnapshot VirtualImageObjectRefKind = "VirtualDiskSnapshot"
)

// Storage type to keep the image for the current virtualization setup.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions base-images/deckhouse_image_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
REGISTRY_PATH: "registry.deckhouse.io/base_images/"

BASE_SCRATCH: "scratch@sha256:b054705fcc9f2205777d80a558d920c0b4209efdc3163c22b5bfcb5dda1db5fc"
BASE_ALT_DEV: "dev-alt:p10@sha256:76e6e163fa982f03468166203488b569e6d9fc10855d6a259c662706436cdcad"
danilrwx marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 4 additions & 4 deletions crds/doc-ru-virtualimages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ spec:
* xz.
objectRef:
description: |
Использование существующего ресурса VirtualImage, ClusterVirtualImage или VirtualDisk для создания образа.
Использование существующего ресурса VirtualImage, ClusterVirtualImage, VirtualDisk или VirtualDiskSnapshot для создания образа.
properties:
kind:
description: |
danilrwx marked this conversation as resolved.
Show resolved Hide resolved
Ссылка на существующий ресурс VirtualImage, ClusterVirtualImage или VirtualDisk.
Ссылка на существующий ресурс VirtualImage, ClusterVirtualImage, VirtualDisk или VirtualDiskSnapshot.
name:
description: |
Имя существующего ресурса VirtualImage, ClusterVirtualImage или VirtualDisk.
Имя существующего ресурса VirtualImage, ClusterVirtualImage, VirtualDisk или VirtualDiskSnapshot.
type:
description: |
Доступные типы источников для создания образа:
Expand Down Expand Up @@ -193,7 +193,7 @@ spec:
Команда для загрузки образа с использованием `Service` внутри кластера.
sourceUID:
description: |
UID источника (VirtualImage, ClusterVirtualImage или VirtualDisk), использованного при создании виртуального образа.
UID источника (VirtualImage, ClusterVirtualImage, VirtualDisk или VirtualDiskSnapshot), использованного при создании виртуального образа.
storageClassName:
description: |
Имя StorageClass, использованного для создания DataVolume, если в поле `storage` был выбран тип `Kubernetes`.
Expand Down
10 changes: 6 additions & 4 deletions crds/virtualimages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,22 @@ spec:
objectRef:
description:
Use an existing VirtualImage, ClusterVirtualImage,
or VirtualDisk resource to create an image.
VirtualDisk or VirtualDiskSnapshot resource to create an image.
properties:
kind:
description:
danilrwx marked this conversation as resolved.
Show resolved Hide resolved
Kind of an existing VirtualImage, ClusterVirtualImage,
or VirtualDisk resource.
VirtualDisk or VirtualDiskSnapshot resource.
enum:
- ClusterVirtualImage
- VirtualImage
- VirtualDisk
- VirtualDiskSnapshot
type: string
name:
description:
Name of an existing VirtualImage, ClusterVirtualImage,
or VirtualDisk resource.
VirtualDisk or VirtualDiskSnapshot resource.
type: string
required:
- kind
Expand Down Expand Up @@ -399,7 +400,8 @@ spec:
sourceUID:
description:
UID of the source (VirtualImage, ClusterVirtualImage,
or VirtualDisk) used when creating the virtual image.
VirtualDisk or VirtualDiskSnapshot) used when creating the virtual
image.
type: string
storageClassName:
description:
Expand Down
22 changes: 22 additions & 0 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,28 @@ spec:
EOF
```

### Creating an image from a disk snapshot

It is possible to create an image from [snapshot](#snapshots). This requires that the disk snapshot is in the ready phase.

Example of creating an image from a disk snapshot:

```yaml
d8 k apply -f - <<EOF
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualImage
metadata:
name: linux-vm-root
spec:
storage: ContainerRegistry
dataSource:
type: ObjectRef
objectRef:
kind: VirtualDiskSnapshot
name: linux-vm-root-snapshot
EOF
```

## Disks

Disks in virtual machines are necessary for writing and storing data, ensuring that applications and operating systems can fully function. Under the hood of these disks is the storage provided by the platform (PVC).
Expand Down
21 changes: 21 additions & 0 deletions docs/USER_GUIDE_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,27 @@ spec:
EOF
```

### Создание образа из снимка диска

Можно создать образ из [снимка](#снимки). Для этого необходимо чтобы снимок диска находился в фазе готовности.

Пример создания образа из моментального снимка диска:
```yaml
d8 k apply -f - <<EOF
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualImage
metadata:
name: linux-vm-root
spec:
storage: ContainerRegistry
dataSource:
type: ObjectRef
objectRef:
kind: VirtualDiskSnapshot
name: linux-vm-root-snapshot
EOF
```

## Диски

Диски в виртуальных машинах необходимы для записи и хранения данных, они обеспечивают полноценное функционирование приложений и операционных систем. Хранилище для этих дисков предоставляет платформа.
Expand Down
3 changes: 3 additions & 0 deletions images/bounder/werf.inc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
image: {{ $.ImageName }}
from: {{ $.Images.BASE_SCRATCH }}
danilrwx marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func main() {
}

viLogger := logger.NewControllerLogger(vi.ControllerName, logLevel, logOutput, logDebugVerbosity, logDebugControllerList)
if _, err = vi.NewController(ctx, mgr, viLogger, importSettings.ImporterImage, importSettings.UploaderImage, importSettings.Requirements, dvcrSettings, viStorageClassSettings); err != nil {
if _, err = vi.NewController(ctx, mgr, viLogger, importSettings.ImporterImage, importSettings.UploaderImage, importSettings.BounderImage, importSettings.Requirements, dvcrSettings, viStorageClassSettings); err != nil {
log.Error(err.Error())
os.Exit(1)
}
Expand Down
4 changes: 4 additions & 0 deletions images/virtualization-artifact/pkg/common/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
// OwnerUID provides the UID of the owner entity (either PVC or DV)
OwnerUID = "OWNER_UID"

// BounderContainerName provides a constant to use as a name for bounder Container
BounderContainerName = "bounder"
// ImporterContainerName provides a constant to use as a name for importer Container
ImporterContainerName = "importer"
// UploaderContainerName provides a constant to use as a name for uploader Container
Expand All @@ -34,6 +36,8 @@ const (
ImporterPodImageNameVar = "IMPORTER_IMAGE"
// UploaderPodImageNameVar is a name of variable with the image name for the uploader Pod
UploaderPodImageNameVar = "UPLOADER_IMAGE"
// BounderPodImageNameVar is a name of variable with the image name for the bounder Pod
BounderPodImageNameVar = "BOUNDER_IMAGE"
// ImporterCertDir is where the configmap containing certs will be mounted
ImporterCertDir = "/certs"
// ImporterProxyCertDir is where the configmap containing proxy certs will be mounted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
type ImportSettings struct {
ImporterImage string
UploaderImage string
BounderImage string
Requirements corev1.ResourceRequirements
}

Expand All @@ -50,6 +51,11 @@ func LoadImportSettingsFromEnv() (ImportSettings, error) {
return ImportSettings{}, err
}

settings.BounderImage, err = GetRequiredEnvVar(common.BounderPodImageNameVar)
if err != nil {
return ImportSettings{}, err
}

limits := os.Getenv(ProvisioningPodLimitsVar)
if limits != "" {
err = json.Unmarshal([]byte(limits), &settings.Requirements.Limits)
Expand Down
Loading
Loading