《OpenShift / RHEL / DevSecOps 汇总目录》
说明:本文初始是在 OpenShift 4.12 + OpenShift Virtualization 4.12 + ACM 2.8 或 MCE 2.3 的环境中验证,目前已经在 OpenShift 4.15 + OpenShift Virtualization 4.15 + ACM 2.10 或 MCE 2.5 的环境中验证
利用 OpenShift Virtualization 运行 OpenShift Hosted Cluster 即托管集群的架构如下图,该模式就是在 OpenShift 管理集群中的由 OpenShift Virtualization 提供的 VM 中运行托管集群的 Worker 节点。

$ oc patch mce multiclusterengine --type=merge -p '{"spec":{"overrides":{"components":[{"name":"hypershift-preview","enabled":true}]}}}'
$ oc get ManagedClusterAddOn hypershift-addon -n local-cluster
NAME AVAILABLE DEGRADED PROGRESSING
hypershift-addon True False
$ oc get deployment -n hypershift
NAME READY UP-TO-DATE AVAILABLE AGE
operator 2/2 2 2 6m6s
$ oc get pod -n hypershift
NAME READY STATUS RESTARTS AGE
operator-7fdc8d998b-8s7pl 1/1 Running 0 9h
operator-7fdc8d998b-l9xpd 1/1 Running 0 9h
apiVersion: metallb.io/v1beta1
kind: MetalLB
metadata:
name: metallb
namespace: metallb-system
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: ip-addresspool
namespace: metallb-system
spec:
addresses:
- 10.39.127.20-10.39.127.26
autoAssign: true
avoidBuggyIPs: false
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: l2-adv
namespace: metallb-system
spec:
ipAddressPools:
- ip-addresspool
$ oc patch ingresscontroller -n openshift-ingress-operator default --type=json -p '[{ "op": "add", "path": "/spec/routeAdmission", "value": {wildcardPolicy: "WildcardsAllowed"}}]'
$ oc new-project clusters





$ curl -L $(oc get consoleclidownload hcp-cli-download -o json | jq -r '.spec.links[] | select(.text=="Download hcp CLI for Linux for x86_64").href') | tar xvz ./
$ export PULL_SECRET="$HOME/pull-secret"
$ export MEM="6Gi"
$ export CPU="2"
$ export WORKER_COUNT="2"
$ export CLUSTER_NAME=my-cluster-1
$ export OCP_VERSION=4.14.19
$ hcp create cluster kubevirt \
--name $CLUSTER_NAME \
--release-image quay.io/openshift-release-dev/ocp-release:$OCP_VERSION-x86_64 \
--node-pool-replicas $WORKER_COUNT \
--pull-secret $PULL_SECRET \
--memory $MEM \
--cores $CPU

$ hcp destroy cluster kubevirt --name my-cluster-1
2023-09-06T11:59:18Z INFO Found hosted cluster {"namespace": "clusters", "name": "my-cluster-1"}
2023-09-06T11:59:19Z INFO Updated finalizer for hosted cluster {"namespace": "clusters", "name": "my-cluster-1"}
2023-09-06T11:59:19Z INFO Deleting hosted cluster {"namespace": "clusters", "name": "my-cluster-1"}
2023-09-06T12:01:41Z INFO Deleting Secrets {"namespace": "clusters"}
2023-09-06T12:01:41Z INFO Deleted CLI generated secrets
2023-09-06T12:01:41Z INFO Finalized hosted cluster {"namespace": "clusters", "name": "my-cluster-1"}
2023-09-06T12:01:41Z INFO Successfully destroyed cluster and infrastructure {"namespace": "clusters", "name": "my-cluster-1d", "infraID": "my-cluster-1-zkrvf"}
https://medium.com/@ben.swinney_ce/hypershift-with-kubevirt-564bd1f850ce
https://cloud.redhat.com/blog/effortlessly-and-efficiently-provision-openshift-clusters-with-openshift-virtualization