Fedora 41
Sponsored Link

Kubernetes : KubeVirt स्थापित करें2024/11/06

 

Kubernetes क्लस्टर में पूर्णतः वर्चुअलाइज्ड वर्चुअल मशीन तैनात करने के लिए KubeVirt स्थापित करें।

यह उदाहरण निम्न प्रकार के वातावरण पर आधारित है।

-----------+---------------------------+--------------------------+------------
           |                           |                          |
       eth0|10.0.0.30              eth0|10.0.0.51             eth0|10.0.0.52
+----------+-----------+   +-----------+----------+   +-----------+----------+
|   [ dlp.srv.world ]  |   | [ node01.srv.world ] |   | [ node02.srv.world ] |
|     Control Plane    |   |      Worker Node     |   |      Worker Node     |
+----------------------+   +----------------------+   +----------------------+

[1] KubeVirt और virtctl कमांड स्थापित करें।
[root@dlp ~]#
export VERSION=$(curl https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt)

[root@dlp ~]#
wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml

[root@dlp ~]#
wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml

[root@dlp ~]#
wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-linux-amd64
[root@dlp ~]#
mv virtctl-${VERSION}-linux-amd64 /usr/local/bin/virtctl

[root@dlp ~]#
chmod 755 /usr/local/bin/virtctl
[root@dlp ~]#
kubectl apply -f kubevirt-operator.yaml

namespace/kubevirt created
customresourcedefinition.apiextensions.k8s.io/kubevirts.kubevirt.io created
priorityclass.scheduling.k8s.io/kubevirt-cluster-critical created
clusterrole.rbac.authorization.k8s.io/kubevirt.io:operator created
serviceaccount/kubevirt-operator created
role.rbac.authorization.k8s.io/kubevirt-operator created
rolebinding.rbac.authorization.k8s.io/kubevirt-operator-rolebinding created
clusterrole.rbac.authorization.k8s.io/kubevirt-operator created
clusterrolebinding.rbac.authorization.k8s.io/kubevirt-operator created
deployment.apps/virt-operator created

[root@dlp ~]#
kubectl apply -f kubevirt-cr.yaml

kubevirt.kubevirt.io/kubevirt created
# कुछ मिनटों के बाद, पॉड्स निम्नानुसार शुरू हो जाएंगे

[root@dlp ~]#
kubectl get pods -n kubevirt

NAME                               READY   STATUS    RESTARTS   AGE
virt-api-f97fbdff-4g7br            1/1     Running   0          80s
virt-api-f97fbdff-5gjfz            1/1     Running   0          80s
virt-controller-6bf9f4477f-5clbv   1/1     Running   0          45s
virt-controller-6bf9f4477f-c9qvl   1/1     Running   0          45s
virt-handler-66cb2                 0/1     Running   0          45s
virt-handler-qmctf                 0/1     Running   0          45s
virt-operator-59f5558dcd-5vl8f     1/1     Running   0          2m8s
virt-operator-59f5558dcd-ggn47     1/1     Running   0          2m8s
[2] एक परीक्षण VM बनाएं और सत्यापित करें कि यह सामान्य रूप से काम करता है।
[root@dlp ~]#
wget https://raw.githubusercontent.com/kubevirt/kubevirt.github.io/master/labs/manifests/vm.yaml

[root@dlp ~]#
kubectl apply -f vm.yaml

virtualmachine.kubevirt.io/testvm created
[root@dlp ~]#
kubectl get vms

NAME     AGE   STATUS    READY
testvm   4s    Stopped   False

# वीएम प्रारंभ करें

[root@dlp ~]#
virtctl start testvm

VM testvm was scheduled to start
[root@dlp ~]#
kubectl get vms

NAME     AGE   STATUS    READY
testvm   45s   Running   True

[root@dlp ~]#
kubectl get vmi

NAME     AGE   PHASE     IP               NODENAME           READY
testvm   36s   Running   192.168.40.202   node01.srv.world   True

# VM से कनेक्ट करें
# उपयोगकर्ता नाम 'cirros' है और पासवर्ड 'gocubsgo' है

[root@dlp ~]#
ssh cirros@192.168.40.202

The authenticity of host '192.168.40.202 (192.168.40.202)' can't be established.
ECDSA key fingerprint is SHA256:GbMaavSvi9L+kLBF5w2YcAJZc4+Za4+EaaFvOjg7CTw.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.40.202' (ECDSA) to the list of known hosts.
cirros@192.168.40.202's password:
$ 
$ uname -a
Linux testvm 4.4.0-28-generic #47-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016 x86_64 GNU/Linux
$ cat /etc/os-release
NAME=Buildroot
VERSION=2015.05-g31af4e3-dirty
ID=buildroot
VERSION_ID=2015.05
PRETTY_NAME="Buildroot 2015.05"
$ exit
Connection to 192.168.40.202 closed.

# VM के कंसोल से कनेक्ट करें

[root@dlp ~]#
virtctl console testvm

Successfully connected to testvm console. The escape sequence is ^]

login as 'cirros' user. default password: 'gocubsgo'. use 'sudo' for root.
testvm login: cirros
Password:
$ 
# होस्ट के कंसोल पर वापस जाने के लिए, Ctrl + ] कुंजी दबाएँ
# * virsh कमांड के समान ऑपरेशन
[root@dlp ~]#

# वीएम रोकें

[root@dlp ~]#
virtctl stop testvm

VM testvm was scheduled to stop
[root@dlp ~]#
kubectl get vms

NAME     AGE     STATUS    READY
testvm   4m30s   Stopped   False

# VM हटाएँ

[root@dlp ~]#
kubectl delete vm testvm

virtualmachine.kubevirt.io "testvm" deleted
[root@dlp ~]#
kubectl get vms

No resources found in default namespace.
मिलान सामग्री