Deckhouse Virtualization Platform for bare metal

Create a project and a project administrator (in the example, the project test-project and the user test-user@deckhouse.io are used, change them if necessary):

d8 k create -f - <<EOF
---
apiVersion: deckhouse.io/v1alpha2
kind: Project
metadata:
  name: test-project
spec:
  description: test-project
  projectTemplateName: default
  parameters:
    # Project quotas.
    resourceQuota:
      requests:
        cpu: 20
        memory: 20Gi
      limits:
        cpu: 20
        memory: 20Gi
    # Project administrators.
    administrators:
      - subject: User
        name: test-user
---
apiVersion: deckhouse.io/v1
kind: User
metadata:
  name: test-user
spec:
  # User e-mail.
  email: test-user@deckhouse.io
  # this is a hash of the password <GENERATED_PASSWORD>, generated  now
  # generate your own or use it at your own risk (for testing purposes)
  # echo "<GENERATED_PASSWORD>" | htpasswd -BinC 10 "" | cut -d: -f2 | base64 -w0
  # you might consider changing this
  password: <GENERATED_PASSWORD_HASH>
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  namespace: test-project
  name: admin
subjects:
  - kind: User
    name: test-user@deckhouse.io
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: ClusterRole
  # User role.
  name: d8:use:role:admin
  apiGroup: rbac.authorization.k8s.io
EOF
d8 k create -f - <<EOF --- apiVersion: deckhouse.io/v1alpha2 kind: Project metadata: name: test-project spec: description: test-project projectTemplateName: default parameters: # Project quotas. resourceQuota: requests: cpu: 20 memory: 20Gi limits: cpu: 20 memory: 20Gi # Project administrators. administrators: - subject: User name: test-user --- apiVersion: deckhouse.io/v1 kind: User metadata: name: test-user spec: # User e-mail. email: test-user@deckhouse.io # this is a hash of the password <GENERATED_PASSWORD>, generated now # generate your own or use it at your own risk (for testing purposes) # echo "<GENERATED_PASSWORD>" | htpasswd -BinC 10 "" | cut -d: -f2 | base64 -w0 # you might consider changing this password: <GENERATED_PASSWORD_HASH> --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: namespace: test-project name: admin subjects: - kind: User name: test-user@deckhouse.io apiGroup: rbac.authorization.k8s.io roleRef: kind: ClusterRole # User role. name: d8:use:role:admin apiGroup: rbac.authorization.k8s.io EOF

Open the web interface for generating the kubeconfig file for remote access to the API server. The address of the web interface is formed according to the DNS name template specified in the global parameter publicDomainTemplate. For example, if publicDomainTemplate: %s.kube.my, then the web interface will be available at the address kubeconfig.kube.my.

Enter the login (in the example — test-user@deckhouse.io) and the password of the created user to obtain the configuration file for access to the cluster:

On a computer with network access to the deployed cluster, create a file ~/.kube/config (for Linux/MacOS) or %USERPROFILE%\.kube\config (for Windows) and paste the kubectl configuration provided in the Raw Config tab.

You have configured kubectl on this computer to manage the cluster. Execute the further commands on this computer.

Create a virtual machine:

kubectl create -f - <<EOF
---
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualImage
metadata:
  name: ubuntu-2204
  namespace: test-project
spec:
  storage: ContainerRegistry
  dataSource:
    type: HTTP
    http:
      url: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
---
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualDisk
metadata:
  name: disk
  namespace: test-project
spec:
  dataSource:
    objectRef:
      kind: VirtualImage
      name: ubuntu-2204
    type: ObjectRef
  persistentVolumeClaim:
    size: 4G
---
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualMachine
metadata:
  name: vm
  namespace: test-project
spec:
  virtualMachineClassName: generic
  runPolicy: AlwaysOn
  blockDeviceRefs:
  - kind: VirtualDisk
    name: disk
  cpu:
    cores: 1
  memory:
    size: 1Gi
EOF
kubectl create -f - <<EOF --- apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualImage metadata: name: ubuntu-2204 namespace: test-project spec: storage: ContainerRegistry dataSource: type: HTTP http: url: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img --- apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualDisk metadata: name: disk namespace: test-project spec: dataSource: objectRef: kind: VirtualImage name: ubuntu-2204 type: ObjectRef persistentVolumeClaim: size: 4G --- apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualMachine metadata: name: vm namespace: test-project spec: virtualMachineClassName: generic runPolicy: AlwaysOn blockDeviceRefs: - kind: VirtualDisk name: disk cpu: cores: 1 memory: size: 1Gi EOF

Display the list of virtual machines to get their status:

kubectl get vm -o wide
kubectl get vm -o wide

After a successful start, the virtual machine should change to the Running status.

Example of the output:

$ kubectl get vm -o wide
NAME   PHASE     CORES   COREFRACTION   MEMORY   NEED RESTART   AGENT   MIGRATABLE   NODE           IPADDRESS     AGE
vm     Running   1       100%           1Gi      False          False   True         virtlab-pt-1   10.66.10.19   6m18s

Connect to the virtual machine, enter the login (in the example — test-user@deckhouse.io) and the password:

d8 v console -n test-project vm
d8 v console -n test-project vm

Congratulations! You have created a virtual machine and connected to it.