文章目录
- 准备条件
- 下载介质
- 部署
- 查看
- 安装 virtctl
前天,kubevirt 更新了,尝鲜。
准备条件
- 二进制 Deploy Kubernetes v1.23.17
下载介质
export VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- '-rc' | sort -r | head -1 | awk -F': ' '{print $2}' | sed 's/,//' | xargs)
echo $VERSION
wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
下载镜像入库
#!/bin/bash
# kubevirt组件版本
version='v1.1.0-alpha.0'
# 私有镜像仓库
registry='harbor.ghostwritten.com'
# 私有镜像仓库的namespace
namespace=kubevirt
kubevirtRegistry="quay.io/kubevirt"
readonly APPLIST=(
virt-operator
virt-api
virt-controller
virt-launcher
virt-handler
)
for app in "${APPLIST[@]}"; do
# 拉取镜像
docker pull ${kubevirtRegistry}/${app}:${version}
# 重命名
docker tag ${kubevirtRegistry}/${app}:${version} ${registry}/${namespace}/${app}:${version}
# 推送镜像
docker push ${registry}/${namespace}/${app}:${version}
done
##. 修改 kubevirt-operator.yaml
env:
- name: VIRT_OPERATOR_IMAGE
value: harbor.ghostwritten.com/kubevirt/virt-operator:v1.1.0-alpha.0
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.annotations['olm.targetNamespaces']
- name: KUBEVIRT_VERSION
value: v1.1.0-alpha.0
image: harbor.ghostwritten.com/kubevirt/virt-operator:v1.1.0-alpha.0
部署
kubectl apply -f kubevirt-operator.yaml
kubectl -n kubevirt patch kubevirt kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true}}}}'
kubectl apply -f kubevirt-cr.yaml
查看
$ kubectl get all -n kubevirt
Warning: kubevirt.io/v1 VirtualMachineInstancePresets is now deprecated and will be removed in v2.
NAME READY STATUS RESTARTS AGE
pod/virt-api-6bfc8548cf-tvb88 1/1 Running 0 9m24s
pod/virt-api-6bfc8548cf-w7bsd 1/1 Running 0 9m24s
pod/virt-controller-864d658788-6fsm4 1/1 Running 0 8m53s
pod/virt-controller-864d658788-h8n9j 1/1 Running 0 8m53s
pod/virt-handler-7gkwm 1/1 Running 0 8m52s
pod/virt-handler-ptzzs 1/1 Running 0 8m52s
pod/virt-handler-zwqsf 1/1 Running 0 8m52s
pod/virt-operator-56bfbd6756-d9jww 1/1 Running 0 12m
pod/virt-operator-56bfbd6756-kf852 1/1 Running 0 12m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubevirt-operator-webhook ClusterIP 10.255.26.53 <none> 443/TCP 9m28s
service/kubevirt-prometheus-metrics ClusterIP None <none> 443/TCP 9m28s
service/virt-api ClusterIP 10.255.48.169 <none> 443/TCP 9m28s
service/virt-exportproxy ClusterIP 10.255.100.157 <none> 443/TCP 9m28s
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/virt-handler 3 3 3 3 3 kubernetes.io/os=linux 8m53s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/virt-api 2/2 2 2 9m25s
deployment.apps/virt-controller 2/2 2 2 8m53s
deployment.apps/virt-operator 2/2 2 2 12m
NAME DESIRED CURRENT READY AGE
replicaset.apps/virt-api-6bfc8548cf 2 2 2 9m25s
replicaset.apps/virt-controller-864d658788 2 2 2 8m53s
replicaset.apps/virt-operator-56bfbd6756 2 2 2 12m
NAME AGE PHASE
kubevirt.kubevirt.io/kubevirt 10m Deployed
安装 virtctl
下载 virctl
VERSION=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.observedKubeVirtVersion}")
ARCH=$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/') || windows-amd64.exe
echo ${ARCH}
wget https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-${ARCH}
chmod +x virtctl
sudo install virtctl /usr/local/bin
- 安装为 Krew 插件
kubectl krew install virt
输出:
Updated the local copy of plugin index.
Installing plugin: virt
Installed plugin: virt
\
| Use this plugin:
| kubectl virt
| Documentation:
| https://github.com/kubevirt/kubectl-virt-plugin
| Caveats:
| \
| | virt plugin is a wrapper for virtctl originating from the KubeVirt project. In order to use virtctl you will
| | need to have KubeVirt installed on your Kubernetes cluster to use it. See https://kubevirt.io/ for details
| |
| | See
| |
| | https://kubevirt.io/user-guide/docs/latest/using-virtual-machines/graphical-and-console-access.html
| |
| | for a usage example
| /
/
WARNING: You installed plugin "virt" from the krew-index plugin repository.
These plugins are not audited for security by the Krew maintainers.
Run them at your own risk.