Basic VirtualMachineInstance operations can be performed with the stock kubectl utility. However, the virtctl binary utility is required to use advanced features such as:
Serial and graphical console access
It also provides convenience commands for:
Starting and stopping VirtualMachineInstances
Live migrating VirtualMachineInstances
Uploading virtual machine disk images
There are two ways to get it:
the most recent version of the tool can be retrieved from the official release page
it can be installed as a kubectl plugin using krew
$ ./virtctl -h
virtctl controls virtual machine related operations on your kubernetes cluster.
Available Commands:
addvolume add a volume to a running VM
console Connect to a console of a virtual machine instance.
expose Expose a virtual machine instance, virtual machine, or virtual machine instance replica set as a new service.
fslist Return full list of filesystems available on the guest machine.
guestfs Start a shell into the libguestfs pod
guestosinfo Return guest agent info about operating system.
help Help about any command
image-upload Upload a VM image to a DataVolume/PersistentVolumeClaim.
migrate Migrate a virtual machine.
pause Pause a virtual machine
permitted-devices List the permitted devices for vmis.
port-forward Forward local ports to a virtualmachine or virtualmachineinstance.
removevolume remove a volume from a running VM
restart Restart a virtual machine.
soft-reboot Soft reboot a virtual machine instance
ssh Open a SSH connection to a virtual machine instance.
start Start a virtual machine.
stop Stop a virtual machine.
unpause Unpause a virtual machine
usbredir Redirect a usb device to a virtual machine instance.
userlist Return full list of logged in users on the guest machine.
version Print the client and server version information.
vnc Open a vnc connection to a virtual machine instance.
Use "virtctl <command> --help" for more information about a given command.
Use "virtctl options" for a list of global command-line options (applies to all commands).
$ ./virtctl console vm1
[root@vm1 output]# hostname
vm1
Получаем список доступных версий kubectl... Выберите версию kubectl для скачивания: 1) v1.30.4
2) v1.29.8
#? 1
Вы выбрали версию v1.30.4
Загружается kubectl версия v1.30.4 ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 49.0M 100 49.0M 0 0 10.0M 0 0:00:04 0:00:04 --:--:-- 11.7M
kubectl версия v1.30.4 успешно установлена! Получаем список доступных версий Helm...
Доступные версии Helm:
1) v3.16.2
2) v3.16.1
3) v3.16.0
4) v3.16.0
5) v3.15.4
6) v3.15.3
7) v3.15.2
8) v3.15.1
9) v3.15.0
10) v3.15.0
#? 1
Скачиваем и устанавливаем Helm версии v3.16.2...
Downloading https://get.helm.sh/helm-v3.16.2-linux-amd64.tar.gz
Verifying checksum... Done.
Preparing to install helm into /usr/local/bin
helm installed into /usr/local/bin/helm
Helm версии v3.16.2 успешно установлен!
version.BuildInfo{Version:"v3.16.2", GitCommit:"13654a52f7c70a143b1dd51416d633e1071faffb", GitTreeState:"clean", GoVersion:"go1.22.7"}
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 4912 100 4912 0 0 5225 0 --:--:-- --:--:-- --:--:-- 768k
Получаем список доступных версий talm
Доступные версии:
1) v0.6.4 3) v0.6.2 5) v0.6.0 7) v0.5.11 9) v0.5.8 11) v0.5.6 13) v0.5.4 15) v0.5.2 17) v0.5.0 19) v0.3.1 21) v0.2.2 23) v0.2.0 25) v0.1.0
2) v0.6.3 4) v0.6.1 6) v0.5.12 8) v0.5.10 10) v0.5.7 12) v0.5.5 14) v0.5.3 16) v0.5.1 18) v0.4.0 20) v0.3.0 22) v0.2.1 24) v0.1.1
#? 1
Скачиваем talm версии v0.6.4...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 97.9M 100 97.9M 0 0 10.3M 0 0:00:09 0:00:09 --:--:-- 13.3M
Проверка установки...
talm version 0.6.4
talm успешно установлен!
Укажите название директории для конфигурационных файлов,
директория будет располагаться в каталоге /opt/. По умолчанию: /opt/cozystack
Введите название директории: % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 21727 100 21727 0 0 23555 0 --:--:-- --:--:-- --:--:-- 23555
yq v4.44.2 from Mike Farah (mikefarah) installed
Укажите IP-сеть для etcd и kubelet По умолчанию: 192.168.100.0/24 IP-сеть (network/mask): 172.16.79.0/24
grep: : No such file or directory
net.ipv4.ip_forward = 1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libwpe-1.0-1 libwpebackend-fdo-1.0-1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
netfilter-persistent
The following NEW packages will be installed:
iptables-persistent netfilter-persistent
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 13,9 kB of archives.
After this operation, 93,2 kB of additional disk space will be used.
Get:1 http://id.archive.ubuntu.com/ubuntu jammy/universe amd64 netfilter-persistent all 1.0.16 [7.440 B]
Get:2 http://id.archive.ubuntu.com/ubuntu jammy/universe amd64 iptables-persistent all 1.0.16 [6.488 B]
Fetched 13,9 kB in 1s (21,9 kB/s) Preconfiguring packages ...
Selecting previously unselected package netfilter-persistent.
(Reading database ... 167872 files and directories currently installed.)
Preparing to unpack .../netfilter-persistent_1.0.16_all.deb ...
Unpacking netfilter-persistent (1.0.16) ...
Selecting previously unselected package iptables-persistent.
Preparing to unpack .../iptables-persistent_1.0.16_all.deb ...
Unpacking iptables-persistent (1.0.16) ...
Setting up netfilter-persistent (1.0.16) ...
Created symlink /etc/systemd/system/multi-user.target.wants/netfilter-persistent.service → /lib/systemd/system/netfilter-persistent.service.
Setting up iptables-persistent (1.0.16) ...
update-alternatives: using /lib/systemd/system/netfilter-persistent.service to provide /lib/systemd/system/iptables.service (iptables.service) in auto mode
Processing triggers for man-db (2.10.2-1) ...
>>> Welcome toWebi!- modern tools, instant installs. <<<
We expect your experience to be absolutely perfect!
Success? Star it! https://github.com/webinstall/webi-installers Problem? Report it: https://github.com/webinstall/webi-installers/issues (your system isGNU/Linux/x86_64withlibc&curl+wget)
BootstrappingWebi Downloading https://webinstall.dev/packages/webi/webi.sh to ~/.local/bin/webi Running ~/.local/bin/webi k9s@stable
Installingk9s... Found ~/.local/bin Initializing ~/.config/envman/
Edit ~/.profile to source ~/.config/envman/load.sh Edit ~/.bashrc to source ~/.config/envman/load.sh Downloading k9s from
https://github.com/derailed/k9s/releases/download/v0.32.5/k9s_Linux_amd64.tar.gz Saved as~/Downloads/webi/k9s/0.32.5/k9s_Linux_amd64.tar.gz Extracting ~/Downloads/webi/k9s/0.32.5/k9s_Linux_amd64.tar.gz Installing to ~/.local/opt/k9s-v0.32.5/bin/k9s
Installed 'k9s v0.32.5' as ~/.local/bin/k9s
Edit ~/.config/envman/PATH.env to add:
~/.local/bin
>>> ACTION REQUIRED <<<
Copy, paste & run the following command:
source ~/.config/envman/PATH.env (newly opened terminal windows will update automatically)
talm in folder /usr/local/bin/talm
cp: cannot stat 'kubeconfig': No such file or directory
cp: cannot stat 'talosconfig': No such file or directory
========== Installed binary =========== helm in folder /usr/local/bin/helm
yq in folder /snap/bin/yq
kubectl in folder /usr/local/bin/kubectl
docker in folder /usr/bin/docker
talosctl in folder /usr/local/bin/talosctl
dialog in folder /usr/bin/dialog
nmap in folder /usr/bin/nmap
talm in folder /usr/local/bin/talm
k9s in folder /root/.local/bin/k9s
node_shell in folder /usr/local/bin/kubectl-node_shell
========== services runing =========== DNS Bind9 active NTP active ========== ADD Iptables Rule =========== -A FORWARD -s 172.16.79.0/24 -m comment --comment cozystack -j ACCEPT
-A FORWARD -d 172.16.79.0/24 -m state --state RELATED,ESTABLISHED -m comment --comment cozystack -j ACCEPT
-A POSTROUTING -s 172.16.79.0/24 -m comment --comment cozystack -j MASQUERADE
!!! Please change the catalog to work with talos-bootstrap !!! cd /opt/cozystack root@ubuntu-virtual-machine:~/cozystack# cd /opt/cozystack/
root@ubuntu-virtual-machine:/opt/cozystack# ls
patch-controlplane.yaml patch.yaml talos-bootstrap root@ubuntu-virtual-machine:/opt/cozystack# . talos-bootstrap install
awk: line 1: regular expression compile failed (missing operand)
*"$
generating PKI and tokens
Created /opt/cozystack/controlplane.yaml
Created /opt/cozystack/worker.yaml
Created /opt/cozystack/talosconfig
Dry run summary:
Node is running in maintenance mode and does not have a config yet.
root@ubuntu-virtual-machine:/opt/cozystack# . talos-bootstrap install
awk: line 1: regular expression compile failed (missing operand)
*"$
generating PKI and tokens
Created /opt/cozystack/controlplane.yaml
Created /opt/cozystack/worker.yaml
Created /opt/cozystack/talosconfig
Dry run summary:
Node is running in maintenance mode and does not have a config yet.
root@ubuntu-virtual-machine:/opt/cozystack# . talos-bootstrap install
awk: line 1: regular expression compile failed (missing operand)
*"$
generating PKI and tokens
Created /opt/cozystack/controlplane.yaml
Created /opt/cozystack/worker.yaml
Created /opt/cozystack/talosconfig
Dry run summary:
Node is running in maintenance mode and does not have a config yet.
root@ubuntu-virtual-machine:/opt/cozystack#
Artikel ini akan menjelaskan cara menyediakan kluster OKD 4 pada satu mesin bare metal. Mesin tersebut akan menggunakan KVM untuk hypervisor dan IdM untuk server DNS. Untuk penyeimbang beban, kami akan menggunakan server Haproxy, untuk server web kami akan menggunakan httpd. Keduanya akan berjalan dalam kontainer podman lokal.
Lingkungan ini akan terdiri dari 3 master dan 3 pekerja yang menjalankan Fedora CoreOS. Server DNS akan menggunakan IdM dan RHEl 7.8 sebagai OS. Sistem dasar yang mengelola host KVM akan menjalankan Red Hat Enterprise Linux (RHEL 8).
Persyaratan Perangkat Keras
Persyaratan perangkat keras dapat ditemukan di sini .
setup — pastikan nama pengguna Anda diatur untuk sudoers
rhsm — pastikan sistem rhel Anda terdaftar di Red Hat
ansible — pastikan sistem rhel Anda diatur untuk berfungsi sebagai pengontrol ansible
host — pastikan sistem rhel Anda diatur sebagai host KVM
5. Perintah di bawah ini akan digunakan untuk menyebarkan server IdM Anda untuk digunakan sebagai DNS
$ ./qubinode-installer -p idm
6. Salin file vars OKD4 ke direktori vars
$ cp sampel/okd4_baremetal.yml buku pedoman/vars/okd4_baremetal.yml
Untuk detail lebih lanjut tentang okd4_baremetal.yml klik tautan ini .
7. Untuk menginstal OKD 4
$ ansible-playbook playbook/deploy_okd4.yml
Sekarang kita bisa mendapatkan info login sehingga kita bisa login ke cluster OKD kita
$ openshift-install --dir "okd4/" wait-for install-complete INFO Menunggu hingga 30 menit untuk klaster di https://api.qbn.cloud.qubinode-lab.com:6443 untuk menginisialisasi... INFO Menunggu hingga 10 menit untuk rute openshift-console dibuat... INFO Instalasi selesai! INFO Untuk mengakses klaster sebagai pengguna system:admin saat menggunakan 'oc', jalankan 'export KUBECONFIG=/home/admin/qubinode-installer/okd4/auth/kubeconfig' INFO Akses konsol web OpenShift di sini: https://console-openshift-console.apps.qbn.cloud.example-lab.com INFO Masuk ke konsol dengan pengguna: kubeadmin, kata sandi: mZqM9-xxyzQ-Gr3xP-wj45z
Berikut adalah langkah-langkah verifikasi yang dapat dilakukan.
Dapatkan status node
$ oc dapatkan node NAMA STATUS PERAN USIA VERSI compute-0 Pekerja siap 11m v1.17.1 compute-1 Pekerja siap 14m v1.17.1 compute-2 Pekerja siap 15m v1.17.1 master-0 Master siap 29m v1.17.1 master-1 Master siap 28m v1.17.1 master-2 Master siap 29m v1.17.1
Dapatkan Status Operator Cluster
$ oc get co NAMA VERSI TERSEDIA BERKEMBANG MENURUN SEJAK authentication 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 8m29s cloud-credential 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 32m cluster-autoscaler 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m console 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 6m53s csi-snapshot-controller Bahasa Indonesia: 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 13m dns 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m etcd 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m image-registry 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m ingress 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 14m insights 4.4.0-0.okd-2020-05-23-055148-beta5 Bahasa Indonesia: Benar Salah Salah 18m kube-apiserver 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m kube-controller-manager 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m kube-scheduler 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m kube-storage-version-migrator 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 14m machine-api 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m machine-config Bahasa Indonesia: 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 22m pasar 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m pemantauan 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 7m59d jaringan 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m penyetelan-simpul 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 25m openshift-apiserver 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m Bahasa Indonesia: openshift-controller-manager 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m openshift-samples 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 15m operator-lifecycle-manager 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m operator-lifecycle-manager-catalog 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 24m operator-lifecycle-manager-packageserver 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 19m Bahasa Indonesia: layanan-ca 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 25m layanan-katalog-apiserver 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 25m layanan-katalog-pengontrol-manajer 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 25m penyimpanan 4.4.0-0.okd-2020-05-23-055148-beta5 Benar Salah Salah 18m
Berikut ini adalah beberapa langkah untuk terhubung ke kluster OKD. Kita harus mengarahkan ke server DNS agar dapat mengakses kluster.
Opsi 1
Perbarui /etc/resolv.conf pada mesin Linux Anda dengan menjalankan skrip di bawah ini.
Jika router rumah Anda dibangun pada openwrt atau menggunakan dnsmasq untuk DNS, Anda dapat meneruskannya semua entri dns untuk domain OKD Anda ke server IdM.
server=/lab.contoh/192.168.1.10
Ganti lab.example dan 192.168.1.10 dengan domain dan IP server IdM Anda. Ini akan meneruskan semua permintaan yang masuk ke lab.example ke server IdM 192.168.1.10. Pfsense juga menyediakan perilaku serupa saat Anda menggunakan resolver sebagai penyedia DNS.