添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

从官网下载 iso。
Dockerfile内容:

FROM scratch
ADD --chown=107:107 ubuntu-18.04.5-desktop-amd64.iso /disk/
docker build -t udesk:18.04.5 .

try ubuntu

仅试用,不安装。
udesk-c.yaml

metadata:
  name: udesk-c
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachineInstance
spec:
  domain:
    resources:
      requests:
        memory: 4096M
        cpu: 4
    devices:
      blockMultiQueue: true
      inputs:
        - type: tablet
          bus: usb
          name: tablet1
      disks:
      - name: containerdisk
        bootOrder: 1        
        disk:
          bus: virtio
      interfaces:
        - name: default
          masquerade: {}
  networks:
  - name: default
    pod: {}
  volumes:
    - name: containerdisk
      containerDisk:
        image: udesk:18.04.5

install ubuntu

从容器镜像启动,安装到 hostDisk。
udesk-c-install.yaml

metadata:
  name: udesk-c-2
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachineInstance
spec:
  domain:
    resources:
      requests:
        memory: 4096M
        cpu: 4
    devices:
      blockMultiQueue: true
      #networkInterfaceMultiqueue: true
      inputs:
        - type: tablet
          bus: usb
          name: tablet1
      disks:
      - name: rootdisk
        bootOrder: 1
        disk:
          bus: virtio
      - name: containerdisk
        bootOrder: 2        
        cdrom:
          bus: sata
      interfaces:
        - name: default
          masquerade: {}
  networks:
  - name: default
    pod: {}
  volumes:
    - name: containerdisk
      containerDisk:
        image: udesk:18.04.5
    - name: rootdisk
      hostDisk:
        capacity: 30Gi
        path: /media/sf_bigshare/vm/udesk01/disk.img
        type: DiskOrCreate

2.云镜像 ubuntu-20.04-cloud-kvm

如果使用嵌套虚拟化,需要使用 kvm版本。否则 kubectl describe vmi ucloud-c 看到如下错误:

server error. command SyncVMI failed: "LibvirtError(Code=1, Domain=10, Message='internal error: unable to execute QEMU command 'cont': Resetting the Virtual Machine is required')"

构建包含 iso 的 docker镜像

从官网下载 iso: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-disk-kvm.img
Dockerfile内容:

FROM scratch
ADD --chown=107:107 focal-server-cloudimg-amd64-disk-kvm.img /disk/
docker build -t ucloud-kvm:20.04 .

使用 containerDisk 形式1

ucloud-c.yaml, 其中初始化脚本,采用base64编码。

apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachineInstance
metadata:
  name: ucloud-c
  labels:
    kubevirt.io/domain: ucloud-c
spec:
  domain:
    resources:
      requests:
        memory: 4096M
        cpu: 4
    devices:
      blockMultiQueue: true
      disks:
      - name: containerdisk
        bootOrder: 1        
        disk:
          bus: virtio
      - name: cloudinit
        bootOrder: 2
        disk:
          bus: virtio
      interfaces:
        - name: default
          masquerade: {}
  networks:
  - name: default
    pod: {}
  volumes:
    - name: containerdisk
      containerDisk:
        image: ucloud-kvm:20.04
    - name: cloudinit
      cloudInitNoCloud:
        userDataBase64: IyEvYmluL2Jhc2gKc3VkbyBlY2hvIHJvb3Q6MTIzNDU2fGNocGFzc3dkCmV4cG9ydCBORVdfVVNFUj0iZm9vIgpleHBvcnQgU1NIX1BVQl9LRVk9InNzaC1yc2EgQUFBQUIzTnphQzF5YzJFQUFBQURBUUFCQUFBQkFRQzZ6ZGdGaUxyMXVBSzdQZGNjaERkK0xzZUE1ZkVPY3hDQ3Q3VExscjdNeDZoOGpVZytHKzhMOUpCTlp1RHpUWlNGMGRSN3F3emRCQlFqb3JBblpUbVkzQmhzS2NGcjhHdDRLTUdyUzZyM0RObUdydVA4R09SdmVnZFdadVhnQVNLVnBYZUk3bkNJalJKd0FhSzF4K2VHSHdBV085WjhvaGNib0hiTHlmZk9vU1pEU0l1azJrUkljNDcrRU5SamcwVDZ4MlZSc3FYMjdnNmo0RGZQS1FaR2swenZYa1phWXRyMWUydFpncVRCV3FaVWxvTUpLOG1pUXE2TWt0Q0tBUzRWdFBrMGs3dGVRWDU3T0d3RDZEN3VvNGIrQ2w4YVlBQXdobjBoYzBDMlVTZmJ1VkhncTg4RVNvMi8rTndWNFNRY2wzc3hDVzIxeUdJakFHdDRIeTdKIEBsb2NhbGhvc3QubG9jYWxkb21haW4iCgpzdWRvIGFkZHVzZXIgLVUgLW0gCmVjaG8gIjphdG9taWMiIHwgY2hwYXNzd2QKc3VkbyBta2RpciAvaG9tZS8vLnNzaApzdWRvIGVjaG8gIiIgPiAvaG9tZS8vLnNzaC9hdXRob3JpemVkX2tleXMKc3VkbyBjaG93biAtUiA6IC9ob21lLy8uc3NoCgo=

使用 containerDisk 形式2

ucloud-c-2.yaml, 其中初始化脚本,直接使用 shell。

apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachineInstance
metadata:
  name: ucloud-c
  labels:
    kubevirt.io/domain: ucloud-c
spec:
  domain:
    resources:
      requests:
        memory: 4096M
        cpu: 4
    devices:
      blockMultiQueue: true
      disks:
      - name: containerdisk
        bootOrder: 1        
        disk:
          bus: virtio
      - name: cloudinit
        bootOrder: 2
        disk:
          bus: virtio
      interfaces:
        - name: default
          masquerade: {}
  networks:
  - name: default
    pod: {}
  volumes:
    - name: containerdisk
      containerDisk:
        image: ucloud-kvm:20.04
    - name: cloudinit
      cloudInitNoCloud:
        userData: |
          #!/bin/bash
          sudo echo root:123456|chpasswd
          export NEW_USER="foo"
          export SSH_PUB_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6zdgFiLr1uAK7PdcchDd+LseA5fEOcxCCt7TLlr7Mx6h8jUg+G+8L9JBNZuDzTZSF0dR7qwzdBBQjorAnZTmY3BhsKcFr8Gt4KMGrS6r3DNmGruP8GORvegdWZuXgASKVpXeI7nCIjRJwAaK1x+eGHwAWO9Z8ohcboHbLyffOoSZDSIuk2kRIc47+ENRjg0T6x2VRsqX27g6j4DfPKQZGk0zvXkZaYtr1e2tZgqTBWqZUloMJK8miQq6MktCKAS4VtPk0k7teQX57OGwD6D7uo4b+Cl8aYAAwhn0hc0C2USfbuVHgq88ESo2/+NwV4SQcl3sxCW21yGIjAGt4Hy7J @localhost.localdomain"
          sudo adduser -U -m
          echo ":atomic" | chpasswd
          sudo mkdir /home//.ssh
          sudo echo "" > /home//.ssh/authorized_keys
          sudo chown -R : /home//.ssh

使用 pvc

先创建上传镜像 nodePort 服务
cdi-proxy-service.yml

apiVersion: v1
kind: Service
metadata:
  namespace: cdi
  name: cdi-uploadproxy-node
spec:
  type: NodePort
  selector:
    cdi.kubevirt.io: cdi-uploadproxy
  ports:
    - protocol: TCP
      port: 443
      targetPort: 8443
      nodePort: 30000

上传命令:

在这里插入代码片

pvc.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: u2004cloudkvm
  namespace: default
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: u2004cloudkvm
  labels:
    type: local
    app: ubuntu
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /media/sf_bigshare/vm/u2004cloudkvm01
  persistentVolumeReclaimPolicy: Recycle

pv-scratch.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: u2004cloudkvm-scratch
  labels:
    type: local
    app: ubuntu
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /media/sf_bigshare/vm/u2004cloudkvm02
  persistentVolumeReclaimPolicy: Delete

ucloud-pvc.yaml

metadata:
  name: ucloud-pvc
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachineInstance
spec:
  domain:
    resources:
      requests:
        memory: 4096M
        cpu: 4
    devices:
      blockMultiQueue: true
      disks:
      - name: pvcdisk
        bootOrder: 1        
        disk:
          bus: virtio
      - name: cloudinit
        bootOrder: 2
        disk:
          bus: virtio
      interfaces:
        - name: default
          masquerade: {}
  networks:
  - name: default
    pod: {}
  volumes:
    - name: pvcdisk
      persistentVolumeClaim:
        claimName: u2004cloudkvm
    - name: cloudinit
      cloudInitNoCloud:
        userDataBase64: IyEvYmluL2Jhc2gKc3VkbyBlY2hvIHJvb3Q6MTIzNDU2fGNocGFzc3dkCmV4cG9ydCBORVdfVVNFUj0iZm9vIgpleHBvcnQgU1NIX1BVQl9LRVk9InNzaC1yc2EgQUFBQUIzTnphQzF5YzJFQUFBQURBUUFCQUFBQkFRQzZ6ZGdGaUxyMXVBSzdQZGNjaERkK0xzZUE1ZkVPY3hDQ3Q3VExscjdNeDZoOGpVZytHKzhMOUpCTlp1RHpUWlNGMGRSN3F3emRCQlFqb3JBblpUbVkzQmhzS2NGcjhHdDRLTUdyUzZyM0RObUdydVA4R09SdmVnZFdadVhnQVNLVnBYZUk3bkNJalJKd0FhSzF4K2VHSHdBV085WjhvaGNib0hiTHlmZk9vU1pEU0l1azJrUkljNDcrRU5SamcwVDZ4MlZSc3FYMjdnNmo0RGZQS1FaR2swenZYa1phWXRyMWUydFpncVRCV3FaVWxvTUpLOG1pUXE2TWt0Q0tBUzRWdFBrMGs3dGVRWDU3T0d3RDZEN3VvNGIrQ2w4YVlBQXdobjBoYzBDMlVTZmJ1VkhncTg4RVNvMi8rTndWNFNRY2wzc3hDVzIxeUdJakFHdDRIeTdKIEBsb2NhbGhvc3QubG9jYWxkb21haW4iCgpzdWRvIGFkZHVzZXIgLVUgLW0gCmVjaG8gIjphdG9taWMiIHwgY2hwYXNzd2QKc3VkbyBta2RpciAvaG9tZS8vLnNzaApzdWRvIGVjaG8gIiIgPiAvaG9tZS8vLnNzaC9hdXRob3JpemVkX2tleXMKc3VkbyBjaG93biAtUiA6IC9ob21lLy8uc3NoCgo=

2. ubuntu-20.04.5-desktop

构建包含 iso 的 docker镜像

从官网下载 iso。
Dockerfile内容:

FROM scratch
ADD --chown=107:107 ubuntu-20.04.5-desktop-amd64.iso /disk/
docker build -t ubuntu-desktop:20.04.5 .

install ubuntu 20.04.5

从容器镜像启动,安装到 hostDisk。
u-desc-c.yaml

apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachineInstance
metadata:
  name: udesk-c
  labels:
    kubevirt.io/domain: ucloud-c
spec:
  domain:
    resources:
      requests:
        memory: 4096M
        cpu: 4
    devices:
      blockMultiQueue: true
      #networkInterfaceMultiqueue: true
      inputs:
      - type: tablet
        bus: usb
        name: tablet1
      disks:
      - name: rootdisk
        bootOrder: 1
        disk:
          bus: virtio
      - name: containerdisk
        bootOrder: 2
        cdrom:
          bus: sata
      interfaces:
      - name: default
        masquerade: {}
  networks:
  - name: default
    pod: {}
  volumes:
  - name: rootdisk
    hostDisk:
      capacity: 30Gi
      path: /data/vm/instance/ubuntu-desktop-20045.img
      type: DiskOrCreate
  - name: containerdisk
    containerDisk:
      image: ubuntu-desktop:20.04.5

启动后,virtctl vnc udesk-c 安装系统。

从硬盘启动 ubuntu-20.04.5

安装好系统后,直接从硬盘启动。
u-desc-h.yaml

apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachineInstance
metadata:
  name: udesk-c
  labels:
    kubevirt.io/domain: ucloud-c
spec:
  domain:
    resources:
      requests:
        memory: 4096M
        cpu: 4
    devices:
      blockMultiQueue: true
      #networkInterfaceMultiqueue: true
      inputs:
      - type: tablet
        bus: usb
        name: tablet1
      disks:
      - name: rootdisk
        bootOrder: 1
        disk:
          bus: virtio
      interfaces:
      - name: default
        masquerade: {}
  networks:
  - name: default
    pod: {}
  volumes:
  - name: rootdisk
    hostDisk:
      capacity: 30Gi
      path: /data/vm/instance/ubuntu-desktop-20045.img
      type: DiskOrCreate
                    1. try ubuntu仅试用,不安装。Dockerfile从官网下载 iso, 构建 docker 镜像。Dockerfile内容:FROM scratchADD --chown=107:107 ubuntu-18.04.5-desktop-amd64.iso /disk/命令:docker build -t udesk:18.04.5 .vmi-c.yaml此方案把 iso 文件放在 docker镜像里。metadata:  name: udesk-capiVersion
在 kubernetes 集群下运行
kuebevirt 只是 kubernetes 中的一个插件, 用于支持 VM 运行
可以在 kubernetes 下使用传统 pod, pvc 等各种资源
无法使用 windows pod
pod 一般以无状态方式运行, pod 销毁, 所有数据无法保存
需要使用 PV, PVC 方式保存永久性数据
可以在 kubernetes...
k8s node节点: ubuntu 18.04.5 desktop,  k8s 1.18.20。
Dockerfile
进入 windows7下载目录(此目录应当只有一个iso)构建镜像
cd /media/sf_backup/dev/os/windows10-20h2
cat <<EOF | sudo tee Dockerfile
FROM scratch
ADD --chown=107:107 cn_windows_10_business_
				
Kubernetes(k8s)是一种开源的容器集群管理系统,它负责自动化容器的部署、扩展和管理。在使用 Kubernetes 的过程中,其中一种安装方式是使用二进制文件进行安装,下面将简要介绍 k8s v1.23.9 的二进制安装步骤。 首先,下载 Kubernetes v1.23.9 的二进制文件到相关机器上。可以在 Kubernetes 的 Github Release 页面中选择对应的版本下载,或者通过工具下载命令进行下载: $ curl -LO "https://dl.k8s.io/v1.23.9/kubernetes-server-linux-amd64.tar.gz" 接着,解压缩 Kubernetes 的二进制文件: $ tar -xvf kubernetes-server-linux-amd64.tar.gz 进入解压缩后的目录,拷贝 kubelet、kubeadm 和 kubectl 这三个二进制文件到 /usr/local/bin 目录中,以确保这些命令可以在任何目录下直接执行: $ cd kubernetes $ sudo cp kubelet kubeadm kubectl /usr/local/bin/ 为了使用 kubeadm 进行 Kubernetes 的初始化,需要在其中一台机器上创建一个初始化的配置文件 kubeadm.yaml。这个配置文件中需要指定 Kubernetes 的服务 IP 段,DNS 服务 IP、Kubernetes 集群的每个节点的 IP 等信息。根据需求进行配置后,可以通过以下命令初始化 Kubernetes 集群: $ sudo kubeadm init --config=kubeadm.yaml 安装完成后,可以通过以下命令检查集群状态: $ sudo kubectl cluster-info 以上是 Kubernetes v1.23.9 的二进制安装过程,需要注意的是,二进制安装需要手动管理 Kubernetes 组件的版本更新和升级,因此不适合大规模的生产环境使用。
江南小野花OK(ゝω・´★): Connecting to mirrors.bfsu.edu.cn (mirrors.bfsu.edu.cn)|39.155.141.16|:443... connected. HTTP request sent, awaiting response... 404 Not Found 2023-06-08 13:48:49 ERROR 404: Not Found. k8s 1.18.20 kubevirt v0.47.1 创建 windows10 虚拟机 压倒骆驼的最后一根稻草: 大佬 应达文件人工选择语言问题解决了吗 node 保留资源 天已青色等烟雨来: 把node上报信息都停了,自动调度瞎了 kubeadm 在virtualbox ubuntu18.04上安装kubernetes 1.18.20 AgeChanger: 第一次弄成功了,在CentOS上老是报错直接被搞崩溃了 ubuntu 20.04 安装 virtualbox 6.1.20 Tisfy: 真棒!就像:此生此夜不长好,明月明年何处看。