diff --git a/Dockerfile.kbmc b/Dockerfile.kbmc index c02c30a..114f535 100644 --- a/Dockerfile.kbmc +++ b/Dockerfile.kbmc @@ -1,4 +1,4 @@ -# Build the kbmc binary +# Build the virt-bmc binary FROM golang:1.20 as builder ARG TARGETOS ARG TARGETARCH @@ -12,7 +12,7 @@ COPY go.sum go.sum RUN go mod download # Copy the go source -COPY cmd/kbmc/main.go cmd/kbmc/main.go +COPY cmd/virt-bmc/main.go cmd/virt-bmc/main.go COPY pkg/ pkg/ # Build @@ -20,13 +20,13 @@ COPY pkg/ pkg/ # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o kbmc cmd/kbmc/main.go +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o virt-bmc cmd/virt-bmc/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details FROM gcr.io/distroless/static:nonroot WORKDIR / -COPY --from=builder /workspace/kbmc . +COPY --from=builder /workspace/virt-bmc . USER 65532:65532 -ENTRYPOINT ["/kbmc"] +ENTRYPOINT ["/virt-bmc"] diff --git a/Makefile b/Makefile index b2891c6..2d0f5e8 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes .PHONY: build build: manifests generate fmt vet ## Build manager binary. go build -o bin/manager cmd/controller/main.go - go build -o bin/kbmc cmd/kbmc/main.go + go build -o bin/virt-bmc cmd/virt-bmc/main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. @@ -110,9 +110,9 @@ run: manifests generate fmt vet ## Run a controller from your host. docker-build: ## Build docker image with the manager. $(CONTAINER_TOOL) build -t ${IMG} . -.PHONY: docker-build-kbmc -docker-build-kbmc: ## Builder docker image with the kbmc binary. - $(CONTAINER_TOOL) build -t ${IMG} --build-arg TARGETARCH=amd64 -f Dockerfile.kbmc . +.PHONY: docker-build-virt-bmc +docker-build-virt-bmc: ## Builder docker image with the virt-bmc binary. + $(CONTAINER_TOOL) build -t ${IMG} --build-arg TARGETARCH=amd64 -f Dockerfile.virt-bmc . .PHONY: docker-push docker-push: ## Push docker image with the manager. diff --git a/README.md b/README.md index 7742a8c..7fa0e0c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# VirtualMachineBMC +# KubeVirtBMC -VirtualMachineBMC unleashes the power management for virtual machines on Kubernetes in a traditional way, i.e., [IPMI](https://www.intel.com.tw/content/www/tw/zh/products/docs/servers/ipmi/ipmi-second-gen-interface-spec-v2-rev1-1.html). This allows users to power on/off/reset and set the boot device for the VM. It was initially designed for [Tinkerbell](https://github.com/tinkerbell/tink)/[Seeder](https://github.com/harvester/seeder) to provision [KubeVirt](https://github.com/kubevirt/kubevirt) VMs, just like we did in the good old days. +KubeVirtBMC unleashes the power management for virtual machines on Kubernetes in a traditional way, i.e., [IPMI](https://www.intel.com.tw/content/www/tw/zh/products/docs/servers/ipmi/ipmi-second-gen-interface-spec-v2-rev1-1.html). This allows users to power on/off/reset and set the boot device for the VM. It was initially designed for [Tinkerbell](https://github.com/tinkerbell/tink)/[Seeder](https://github.com/harvester/seeder) to provision [KubeVirt](https://github.com/kubevirt/kubevirt) VMs, just like we did in the good old days. The project was born in [SUSE Hack Week 23](https://hackweek.opensuse.org/). ## Description -VirtualMachineBMC was inspired by [VirtualBMC](https://opendev.org/openstack/virtualbmc). The difference between them could be illustrated below: +KubeVirtBMC was inspired by [VirtualBMC](https://opendev.org/openstack/virtualbmc). The difference between them could be illustrated below: ```mermaid flowchart LR @@ -14,9 +14,9 @@ flowchart LR client2[Client] BMC1[BMC] VM[VM] - subgraph VirtualMachineBMC + subgraph KubeVirtBMC direction LR - client2-->|IPMI|kBMC-->|K8s API|VM + client2-->|IPMI|virtBMC-->|K8s API|VM end subgraph VirtualBMC direction LR @@ -34,25 +34,25 @@ flowchart LR - Providing BMC functionalities for bare-metal machines - Providing BMC accessibility outside of the cluster via LoadBalancer or NodePort type of Services -VirtualMachineBMC consists of two components: +KubeVirtBMC consists of two components: -- **virtualmachinebmc-controller**: A typical Kubernetes controller built with kubebuilder that reconciles on the VirtualMachineBMC, VirtualMachine, and Service objects -- **kbmc**: A BMC simulator for serving IPMI and translating the requests to native Kubernetes API requests +- **virt-bmc-controller**: A typical Kubernetes controller built with kubebuilder that reconciles on the VirtualMachineBMC, VirtualMachine, and Service objects +- **virt-bmc**: A BMC simulator for serving IPMI and translating the requests to native Kubernetes API requests -Below is the workflow of VirtualMachineBMC when a VirtualMachine was created and booted up: +Below is the workflow of KubeVirtBMC when a VirtualMachine was created and booted up: ```mermaid flowchart LR - controller["virtualmachinebmc-controller"] + controller["virt-bmc-controller"] cr["virtualmachinebmc CR"] - kbmc-pod["kbmc Pod"] - kbmc-svc["kbmc Service"] + virt-bmc-pod["virt-bmc Pod"] + virt-bmc-svc["virt-bmc Service"] controller-.->|watches|cr - cr-.->|owns|kbmc-svc - cr-.->|owns|kbmc-pod - client--->|IPMI|kbmc-svc - kbmc-svc-->kbmc-pod - kbmc-pod-->|HTTP|apiserver + cr-.->|owns|virt-bmc-svc + cr-.->|owns|virt-bmc-pod + client--->|IPMI|virt-bmc-svc + virt-bmc-svc-->virt-bmc-pod + virt-bmc-pod-->|HTTP|apiserver apiserver-->|modifies|vm vm-->|creates|vmi ``` @@ -100,8 +100,8 @@ type VirtualMachineBMCStatus struct { **Build and push the images to the location specified by `IMG`:** ```sh -make docker-build docker-push IMG=/virtualmachinebmc-controller: -make docker-build-kbmc docker-push IMG=/kbmc: +make docker-build docker-push IMG=/virt-bmc-controller: +make docker-build-virt-bmc docker-push IMG=/virt-bmc: ``` > **NOTE:** These images ought to be published in the personal registry you specified. And it is required to have access to pull the images from the working environment. Make sure you have the proper permission to the registry if the above commands don’t work. @@ -130,7 +130,7 @@ kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/ **Deploy the Manager to the cluster with the image specified by `IMG`:** ```sh -make deploy IMG=/virtualmachinebmc-controller: +make deploy IMG=/virt-bmc-controller: ``` > **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin privileges or be logged in as admin. @@ -143,12 +143,12 @@ Create the VirtualMachineBMC object in the cluster: kubectl apply -f config/samples/virtualmachine_v1_virtualmachinebmc.yaml ``` -Though you can create the VirtualMachineBMC object manually, the corresponding VirtualMachineBMC object should be created automatically when the VirtualMachine object exists. It will then scaffold the `*-kbmc` Pod and Service object. +Though you can create the VirtualMachineBMC object manually, the corresponding VirtualMachineBMC object should be created automatically when the VirtualMachine object exists. It will then scaffold the `*-virt-bmc` Pod and Service object. ```sh -$ kubectl -n virtualmachinebmc-system get svc +$ kubectl -n kubevirtbmc-system get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -default-test-vm-kbmc ClusterIP 10.53.106.65 623/UDP 3h13m +default-test-vm-virt-bmc ClusterIP 10.53.106.65 623/UDP 3h13m ``` To access the VM's BMC, you need to be in the cluster network. Run a Pod that comes with `ipmitool` built in: @@ -160,11 +160,11 @@ $ kubectl run -it --rm ipmitool --image=mikeynap/ipmitool --command -- /bin/sh Inside the Pod, you can for example turn on the VM via `ipmitool`: ```sh -$ ipmitool -I lan -U admin -P password -H default-test-vm-kbmc.virtualmachinebmc-system.svc.cluster.local power status +$ ipmitool -I lan -U admin -P password -H default-test-vm-virt-bmc.kubevirtbmc-system.svc.cluster.local power status Chassis Power is off -$ ipmitool -I lan -U admin -P password -H default-test-vm-kbmc.virtualmachinebmc-system.svc.cluster.local power on +$ ipmitool -I lan -U admin -P password -H default-test-vm-virt-bmc.kubevirtbmc-system.svc.cluster.local power on Chassis Power Control: Up/On -$ ipmitool -I lan -U admin -P password -H default-test-vm-kbmc.virtualmachinebmc-system.svc.cluster.local power status +$ ipmitool -I lan -U admin -P password -H default-test-vm-virt-bmc.kubevirtbmc-system.svc.cluster.local power status Chassis Power is on ``` diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 281f43e..c50c247 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -32,12 +32,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" - virtualmachinev1 "kubevirt.org/virtualmachinebmc/api/v1" - "kubevirt.org/virtualmachinebmc/internal/controller/service" - "kubevirt.org/virtualmachinebmc/internal/controller/virtualmachine" - "kubevirt.org/virtualmachinebmc/internal/controller/virtualmachinebmc" + virtualmachinev1 "kubevirt.org/kubevirtbmc/api/v1" + "kubevirt.org/kubevirtbmc/internal/controller/service" + "kubevirt.org/kubevirtbmc/internal/controller/virtualmachine" + "kubevirt.org/kubevirtbmc/internal/controller/virtualmachinebmc" - // clischeme "kubevirt.org/virtualmachinebmc/pkg/generated/clientset/versioned/scheme" + // clischeme "kubevirt.org/kubevirtbmc/pkg/generated/clientset/versioned/scheme" kubevirtv1 "kubevirt.io/api/core/v1" //+kubebuilder:scaffold:imports ) diff --git a/cmd/kbmc/main.go b/cmd/kbmc/main.go index 4ca0a86..9a89bc7 100644 --- a/cmd/kbmc/main.go +++ b/cmd/kbmc/main.go @@ -8,15 +8,14 @@ import ( "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" - - "kubevirt.org/virtualmachinebmc/pkg/kbmc" -) + "kubevirt.org/virtualmachinebmc/pkg/virt-bmc" + "kubevirt.org/kubevirtbmc/pkg/kbmc" func main() { - var options kbmc.Options + var options virt-bmc.Options app := &cli.App{ - Name: "kbmc", + Name: "virt-bmc", Usage: "receive ipmi requests and traslate them into native k8s api calls", Flags: []cli.Flag{ &cli.StringFlag{ @@ -53,8 +52,8 @@ func main() { } } -func run(ctx context.Context, options kbmc.Options) error { - logrus.Info("Starting kBMC") +func run(ctx context.Context, options virt-bmc.Options) error { + logrus.Info("Starting virt-bmc") // TODO: check kubeconfig flag instead // check whether we're in a cluster or not @@ -78,10 +77,10 @@ func run(ctx context.Context, options kbmc.Options) error { os.Exit(2) }() - kbmc, err := kbmc.NewKBMC(ctx, options, ok) + virt-bmc, err := virt-bmc.Newvirt-bmc(ctx, options, ok) if err != nil { - return fmt.Errorf("failed to create kbmc server: %v", err) + return fmt.Errorf("failed to create virt-bmc server: %v", err) } - return kbmc.Run() + return virt-bmc.Run() } diff --git a/config/certmanager/certificate.yaml b/config/certmanager/certificate.yaml index 917874b..ed3a5ff 100644 --- a/config/certmanager/certificate.yaml +++ b/config/certmanager/certificate.yaml @@ -8,8 +8,8 @@ metadata: app.kubernetes.io/name: certificate app.kubernetes.io/instance: serving-cert app.kubernetes.io/component: certificate - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: selfsigned-issuer namespace: system @@ -23,8 +23,8 @@ metadata: app.kubernetes.io/name: certificate app.kubernetes.io/instance: serving-cert app.kubernetes.io/component: certificate - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml namespace: system diff --git a/config/crd/patches/cainjection_in_kubebmcs.yaml b/config/crd/patches/cainjection_in_virtualmachinebmcs.yaml similarity index 100% rename from config/crd/patches/cainjection_in_kubebmcs.yaml rename to config/crd/patches/cainjection_in_virtualmachinebmcs.yaml diff --git a/config/crd/patches/webhook_in_kubebmcs.yaml b/config/crd/patches/webhook_in_virtualmachinebmcs.yaml similarity index 100% rename from config/crd/patches/webhook_in_kubebmcs.yaml rename to config/crd/patches/webhook_in_virtualmachinebmcs.yaml diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 76ea2d4..cab6306 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -1,12 +1,12 @@ # Adds namespace to all resources. -namespace: virtualmachinebmc-system +namespace: kubevirtbmc-system # Value of this field is prepended to the # names of all resources, e.g. a deployment named # "wordpress" becomes "alices-wordpress". # Note that it should also match with the prefix (text before '-') of the namespace # field above. -namePrefix: virtualmachinebmc- +namePrefix: kubevirtbmc- # Labels to add to all resources and selectors. #labels: @@ -18,7 +18,7 @@ resources: - ../crd - ../rbac - ../manager -- ../kbmc +- ../virt-bmc # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in # crd/kustomization.yaml - ../webhook diff --git a/config/default/webhookcainjection_patch.yaml b/config/default/webhookcainjection_patch.yaml index 7dfa178..8eedc64 100644 --- a/config/default/webhookcainjection_patch.yaml +++ b/config/default/webhookcainjection_patch.yaml @@ -7,8 +7,8 @@ metadata: app.kubernetes.io/name: mutatingwebhookconfiguration app.kubernetes.io/instance: mutating-webhook-configuration app.kubernetes.io/component: webhook - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: mutating-webhook-configuration annotations: @@ -21,8 +21,8 @@ metadata: app.kubernetes.io/name: validatingwebhookconfiguration app.kubernetes.io/instance: validating-webhook-configuration app.kubernetes.io/component: webhook - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: validating-webhook-configuration annotations: diff --git a/config/kbmc/service_account.yaml b/config/kbmc/service_account.yaml deleted file mode 100644 index 7975803..0000000 --- a/config/kbmc/service_account.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - app.kubernetes.io/name: serviceaccount - app.kubernetes.io/instance: kbmc-sa - app.kubernetes.io/component: kbmc-rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc - app.kubernetes.io/managed-by: kustomize - name: kbmc - namespace: system diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 353e518..bb4a4ec 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: starbops/virtualmachinebmc-controller + newName: starbops/virt-bmc-controller newTag: dev diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index f04f891..98e94e5 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: namespace app.kubernetes.io/instance: system app.kubernetes.io/component: manager - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: system --- @@ -21,8 +21,8 @@ metadata: app.kubernetes.io/name: deployment app.kubernetes.io/instance: controller-manager app.kubernetes.io/component: manager - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize spec: selector: diff --git a/config/prometheus/monitor.yaml b/config/prometheus/monitor.yaml index a904f5a..d6c6d56 100644 --- a/config/prometheus/monitor.yaml +++ b/config/prometheus/monitor.yaml @@ -7,8 +7,8 @@ metadata: app.kubernetes.io/name: servicemonitor app.kubernetes.io/instance: controller-manager-metrics-monitor app.kubernetes.io/component: metrics - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: controller-manager-metrics-monitor namespace: system diff --git a/config/rbac/auth_proxy_client_clusterrole.yaml b/config/rbac/auth_proxy_client_clusterrole.yaml index a2b73ad..dc6735f 100644 --- a/config/rbac/auth_proxy_client_clusterrole.yaml +++ b/config/rbac/auth_proxy_client_clusterrole.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: metrics-reader app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: metrics-reader rules: diff --git a/config/rbac/auth_proxy_role_binding.yaml b/config/rbac/auth_proxy_role_binding.yaml index 46fa5c7..3ce61ed 100644 --- a/config/rbac/auth_proxy_role_binding.yaml +++ b/config/rbac/auth_proxy_role_binding.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: clusterrolebinding app.kubernetes.io/instance: proxy-rolebinding app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: proxy-rolebinding roleRef: diff --git a/config/rbac/auth_proxy_service.yaml b/config/rbac/auth_proxy_service.yaml index 358f7fc..c305749 100644 --- a/config/rbac/auth_proxy_service.yaml +++ b/config/rbac/auth_proxy_service.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: service app.kubernetes.io/instance: controller-manager-metrics-service app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: controller-manager-metrics-service namespace: system diff --git a/config/rbac/kubebmc_editor_role.yaml b/config/rbac/kubebmc_editor_role.yaml index 5571e5d..4ddfa38 100644 --- a/config/rbac/kubebmc_editor_role.yaml +++ b/config/rbac/kubebmc_editor_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: virtualmachinebmc-editor-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: virtualmachinebmc-editor-role rules: diff --git a/config/rbac/leader_election_role.yaml b/config/rbac/leader_election_role.yaml index 0209bde..7dec992 100644 --- a/config/rbac/leader_election_role.yaml +++ b/config/rbac/leader_election_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: role app.kubernetes.io/instance: leader-election-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: leader-election-role rules: diff --git a/config/rbac/leader_election_role_binding.yaml b/config/rbac/leader_election_role_binding.yaml index 443070a..7d191ec 100644 --- a/config/rbac/leader_election_role_binding.yaml +++ b/config/rbac/leader_election_role_binding.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: rolebinding app.kubernetes.io/instance: leader-election-rolebinding app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: leader-election-rolebinding roleRef: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 5d9f68c..e7884b8 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -28,16 +28,6 @@ rules: - patch - update - watch -- apiGroups: - - kubevirt.io - resources: - - virtualmachines - verbs: - - get - - list - - patch - - update - - watch - apiGroups: - virtualmachine.kubevirt.org resources: diff --git a/config/rbac/role_binding.yaml b/config/rbac/role_binding.yaml index fbc220c..489df20 100644 --- a/config/rbac/role_binding.yaml +++ b/config/rbac/role_binding.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: clusterrolebinding app.kubernetes.io/instance: manager-rolebinding app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: manager-rolebinding roleRef: diff --git a/config/rbac/service_account.yaml b/config/rbac/service_account.yaml index 26a2251..49af6a3 100644 --- a/config/rbac/service_account.yaml +++ b/config/rbac/service_account.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: serviceaccount app.kubernetes.io/instance: controller-manager-sa app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: controller-manager namespace: system diff --git a/config/rbac/kubebmc_viewer_role.yaml b/config/rbac/virtualmachinebmc_viewer_role.yaml similarity index 85% rename from config/rbac/kubebmc_viewer_role.yaml rename to config/rbac/virtualmachinebmc_viewer_role.yaml index 82e52f6..3eb4b5e 100644 --- a/config/rbac/kubebmc_viewer_role.yaml +++ b/config/rbac/virtualmachinebmc_viewer_role.yaml @@ -6,8 +6,8 @@ metadata: app.kubernetes.io/name: clusterrole app.kubernetes.io/instance: virtualmachinebmc-viewer-role app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: virtualmachinebmc-viewer-role rules: diff --git a/config/samples/virtualmachine_v1_kubebmc.yaml b/config/samples/virtualmachine_v1_virtualmachinebmc.yaml similarity index 71% rename from config/samples/virtualmachine_v1_kubebmc.yaml rename to config/samples/virtualmachine_v1_virtualmachinebmc.yaml index 61ca418..d2fdf51 100644 --- a/config/samples/virtualmachine_v1_kubebmc.yaml +++ b/config/samples/virtualmachine_v1_virtualmachinebmc.yaml @@ -4,11 +4,11 @@ metadata: labels: app.kubernetes.io/name: virtualmachinebmc app.kubernetes.io/instance: virtualmachinebmc-sample - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc name: virtualmachinebmc-sample - namespace: virtualmachinebmc-system + namespace: kubevirtbmc-system spec: username: admin password: password diff --git a/config/kbmc/kustomization.yaml b/config/virt-bmc/kustomization.yaml similarity index 100% rename from config/kbmc/kustomization.yaml rename to config/virt-bmc/kustomization.yaml diff --git a/config/kbmc/role.yaml b/config/virt-bmc/role.yaml similarity index 66% rename from config/kbmc/role.yaml rename to config/virt-bmc/role.yaml index 9afdd9a..90d0473 100644 --- a/config/kbmc/role.yaml +++ b/config/virt-bmc/role.yaml @@ -3,12 +3,12 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: kbmc-role - app.kubernetes.io/component: kbmc-rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/instance: virt-bmc-role + app.kubernetes.io/component: virt-bmc-rbac + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize - name: kbmc-role + name: virt-bmc-role rules: - apiGroups: - kubevirt.io diff --git a/config/kbmc/role_binding.yaml b/config/virt-bmc/role_binding.yaml similarity index 53% rename from config/kbmc/role_binding.yaml rename to config/virt-bmc/role_binding.yaml index 283fb36..e88fc1f 100644 --- a/config/kbmc/role_binding.yaml +++ b/config/virt-bmc/role_binding.yaml @@ -3,17 +3,17 @@ kind: ClusterRoleBinding metadata: labels: app.kubernetes.io/name: clusterrolebinding - app.kubernetes.io/instance: kbmc-rolebinding - app.kubernetes.io/component: kbmc-rbac - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/instance: virt-bmc-rolebinding + app.kubernetes.io/component: virt-bmc-rbac + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize - name: kbmc-rolebinding + name: virt-bmc-rolebinding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: kbmc-role + name: virt-bmc-role subjects: - kind: ServiceAccount - name: kbmc + name: virt-bmc namespace: system diff --git a/config/virt-bmc/service_account.yaml b/config/virt-bmc/service_account.yaml new file mode 100644 index 0000000..fce40bd --- /dev/null +++ b/config/virt-bmc/service_account.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/name: serviceaccount + app.kubernetes.io/instance: virt-bmc-sa + app.kubernetes.io/component: virt-bmc-rbac + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc + app.kubernetes.io/managed-by: kustomize + name: virt-bmc + namespace: system diff --git a/config/webhook/service.yaml b/config/webhook/service.yaml index 38d0134..5d4f8c2 100644 --- a/config/webhook/service.yaml +++ b/config/webhook/service.yaml @@ -5,8 +5,8 @@ metadata: app.kubernetes.io/name: service app.kubernetes.io/instance: webhook-service app.kubernetes.io/component: webhook - app.kubernetes.io/created-by: virtualmachinebmc - app.kubernetes.io/part-of: virtualmachinebmc + app.kubernetes.io/created-by: kubevirtbmc + app.kubernetes.io/part-of: kubevirtbmc app.kubernetes.io/managed-by: kustomize name: webhook-service namespace: system diff --git a/go.mod b/go.mod index 3a238f2..ec07970 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module kubevirt.org/virtualmachinebmc +module kubevirt.org/kubevirtbmc go 1.20 diff --git a/internal/controller/service/controller.go b/internal/controller/service/controller.go index 2117d69..f4d61a1 100644 --- a/internal/controller/service/controller.go +++ b/internal/controller/service/controller.go @@ -25,9 +25,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - virtualmachinev1 "kubevirt.org/virtualmachinebmc/api/v1" - ctlvirtualmachinebmc "kubevirt.org/virtualmachinebmc/internal/controller/virtualmachinebmc" - ctrl "sigs.k8s.io/controller-runtime" + virtualmachinev1 "kubevirt.org/kubevirtbmc/api/v1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" ) @@ -57,13 +55,13 @@ func (s *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct if svc.Labels == nil { return ctrl.Result{}, nil } - kBMCName, ok := svc.Labels[ctlvirtualmachinebmc.KBMCNameLabel] + virt - bmcName, ok := svc.Labels[ctlvirtualmachinebmc.virt-bmcNameLabel] if !ok { return ctrl.Result{}, nil } knn := types.NamespacedName{ Namespace: req.Namespace, - Name: kBMCName, + Name: virt - bmcName, } var kubeBMC virtualmachinev1.VirtualMachineBMC diff --git a/internal/controller/virtualmachine/controller.go b/internal/controller/virtualmachine/controller.go index f0c6ed9..db51e42 100644 --- a/internal/controller/virtualmachine/controller.go +++ b/internal/controller/virtualmachine/controller.go @@ -25,8 +25,8 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" kubevirtv1 "kubevirt.io/api/core/v1" - virtualmachinev1 "kubevirt.org/virtualmachinebmc/api/v1" - ctlvirtualmachinebmc "kubevirt.org/virtualmachinebmc/internal/controller/virtualmachinebmc" + virtualmachinev1 "kubevirt.org/kubevirtbmc/api/v1" + ctlvirtualmachinebmc "kubevirt.org/kubevirtbmc/internal/controller/virtualmachinebmc" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" @@ -70,7 +70,7 @@ func (v *VirtualMachineReconciler) constructVirtualMachineBMCForVirtualMachine(v ObjectMeta: metav1.ObjectMeta{ Annotations: make(map[string]string), Labels: map[string]string{ - ctlvirtualmachinebmc.ManagedByLabel: "virtualmachinebmc-controller", + ctlvirtualmachinebmc.ManagedByLabel: "virt-bmc-controller", }, Name: name, Namespace: ctlvirtualmachinebmc.KBMCNamespace, @@ -127,18 +127,18 @@ func (v *VirtualMachineReconciler) Reconcile(ctx context.Context, req ctrl.Reque Namespace: ctlvirtualmachinebmc.KBMCNamespace, Name: fmt.Sprintf("%s-%s", vm.Namespace, vm.Name), } - var kbmc virtualmachinev1.VirtualMachineBMC - if err := v.Get(ctx, knn, &kbmc); err != nil { + var virt-bmc virtualmachinev1.VirtualMachineBMC + if err := v.Get(ctx, knn, &virt-bmc); err != nil { log.Error(err, "unable to fetch VirtualMachineBMC") return ctrl.Result{}, err } if !vm.ObjectMeta.DeletionTimestamp.IsZero() { - if err := v.Delete(ctx, &kbmc); err != nil { - log.Error(err, "unable to delete VirtualMachineBMC for VirtualMachine", "kbmc", kbmc) + if err := v.Delete(ctx, &virt-bmc); err != nil { + log.Error(err, "unable to delete VirtualMachineBMC for VirtualMachine", "virt-bmc", virt-bmc) return ctrl.Result{}, err } - log.V(1).Info("removed VirtualMachineBMC for VirtualMachine", "kbmc", kbmc) + log.V(1).Info("removed VirtualMachineBMC for VirtualMachine", "virt-bmc", virt-bmc) } return ctrl.Result{}, nil diff --git a/internal/controller/virtualmachinebmc/constant.go b/internal/controller/virtualmachinebmc/constant.go index 74636e8..8c5b7f5 100644 --- a/internal/controller/virtualmachinebmc/constant.go +++ b/internal/controller/virtualmachinebmc/constant.go @@ -3,8 +3,8 @@ package virtualmachinebmc const ( DefaultUsername = "admin" DefaultPassword = "password" - kbmcContainerName = "kbmc" - kbmcImageName = "starbops/kbmc" + kbmcContainerName = "virt-bmc" + kbmcImageName = "starbops/virt-bmc" kbmcImageTag = "dev" ipmiPort = 623 IPMISvcPort = 623 @@ -12,5 +12,5 @@ const ( ManagedByLabel = "app.kubernetes.io/managed-by" KBMCNameLabel = "kubevirt.org/virtualmachinebmc-name" VMNameLabel = "kubevirt.org/vm-name" - KBMCNamespace = "virtualmachinebmc-system" + KBMCNamespace = "kubevirtbmc-system" ) diff --git a/internal/controller/virtualmachinebmc/controller.go b/internal/controller/virtualmachinebmc/controller.go index e96f071..2c8c800 100644 --- a/internal/controller/virtualmachinebmc/controller.go +++ b/internal/controller/virtualmachinebmc/controller.go @@ -29,7 +29,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - virtualmachinev1 "kubevirt.org/virtualmachinebmc/api/v1" + virtualmachinev1 "kubevirt.org/kubevirtbmc/api/v1" ) // VirtualMachineBMCReconciler reconciles a VirtualMachineBMC object @@ -44,13 +44,13 @@ var ( ) func (r *VirtualMachineBMCReconciler) constructPodForVirtualMachineBMC(kubeBMC *virtualmachinev1.VirtualMachineBMC) (*corev1.Pod, error) { - name := fmt.Sprintf("%s-kbmc", kubeBMC.Name) + name := fmt.Sprintf("%s-virt-bmc", kubeBMC.Name) pod := &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Annotations: make(map[string]string), Labels: map[string]string{ - ManagedByLabel: "kbmc", + ManagedByLabel: "virt-bmc", KBMCNameLabel: kubeBMC.Name, VMNameLabel: kubeBMC.Spec.VirtualMachineName, }, @@ -79,7 +79,7 @@ func (r *VirtualMachineBMCReconciler) constructPodForVirtualMachineBMC(kubeBMC * }, }, }, - ServiceAccountName: "virtualmachinebmc-kbmc", + ServiceAccountName: "kubevirtbmc-virt-bmc", }, } @@ -87,13 +87,13 @@ func (r *VirtualMachineBMCReconciler) constructPodForVirtualMachineBMC(kubeBMC * } func (r *VirtualMachineBMCReconciler) constructServiceForVirtualMachineBMC(kubeBMC *virtualmachinev1.VirtualMachineBMC) (*corev1.Service, error) { - name := fmt.Sprintf("%s-kbmc", kubeBMC.Name) + name := fmt.Sprintf("%s-virt-bmc", kubeBMC.Name) svc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Annotations: make(map[string]string), Labels: map[string]string{ - ManagedByLabel: "kbmc", + ManagedByLabel: "virt-bmc", KBMCNameLabel: kubeBMC.Name, VMNameLabel: kubeBMC.Spec.VirtualMachineName, }, @@ -102,7 +102,7 @@ func (r *VirtualMachineBMCReconciler) constructServiceForVirtualMachineBMC(kubeB }, Spec: corev1.ServiceSpec{ Selector: map[string]string{ - ManagedByLabel: "kbmc", + ManagedByLabel: "virt-bmc", KBMCNameLabel: kubeBMC.Name, }, Ports: []corev1.ServicePort{ @@ -146,7 +146,7 @@ func (r *VirtualMachineBMCReconciler) Reconcile(ctx context.Context, req ctrl.Re return ctrl.Result{}, client.IgnoreNotFound(err) } - // Prepare the kbmc Pod + // Prepare the virt-bmc Pod pod, err := r.constructPodForVirtualMachineBMC(&kubeBMC) if err != nil { log.Error(err, "unable to construct pod from template") @@ -156,7 +156,7 @@ func (r *VirtualMachineBMCReconciler) Reconcile(ctx context.Context, req ctrl.Re return ctrl.Result{}, err } - // Create the kbmc Pod on the cluster + // Create the virt-bmc Pod on the cluster if err := r.Create(ctx, pod); err != nil && !apierrors.IsAlreadyExists(err) { log.Error(err, "unable to create Pod for VirtualMachineBMC", "pod", pod) return ctrl.Result{}, err @@ -164,7 +164,7 @@ func (r *VirtualMachineBMCReconciler) Reconcile(ctx context.Context, req ctrl.Re log.V(1).Info("created Pod for VirtualMachineBMC", "pod", pod) - // Prepare the kbmc Service + // Prepare the virt-bmc Service svc, err := r.constructServiceForVirtualMachineBMC(&kubeBMC) if err != nil { log.Error(err, "unable to construct svc from template") @@ -174,7 +174,7 @@ func (r *VirtualMachineBMCReconciler) Reconcile(ctx context.Context, req ctrl.Re return ctrl.Result{}, err } - // Create the kbmc Service on the cluster + // Create the virt-bmc Service on the cluster if err := r.Create(ctx, svc); err != nil && !apierrors.IsAlreadyExists(err) { log.Error(err, "unable to create Service for VirtualMachineBMC", "svc", svc) return ctrl.Result{}, err diff --git a/internal/controller/virtualmachinebmc/suite_test.go b/internal/controller/virtualmachinebmc/suite_test.go index a5c774d..27adb51 100644 --- a/internal/controller/virtualmachinebmc/suite_test.go +++ b/internal/controller/virtualmachinebmc/suite_test.go @@ -35,8 +35,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/metrics/server" - virtualmachinev1 "kubevirt.org/virtualmachinebmc/api/v1" - "kubevirt.org/virtualmachinebmc/internal/controller/virtualmachinebmc" + virtualmachinev1 "kubevirt.org/kubevirtbmc/api/v1" + "kubevirt.org/kubevirtbmc/internal/controller/virtualmachinebmc" //+kubebuilder:scaffold:imports ) diff --git a/pkg/kbmc/ipmi.go b/pkg/bmc/ipmi.go similarity index 100% rename from pkg/kbmc/ipmi.go rename to pkg/bmc/ipmi.go diff --git a/pkg/kbmc/k8s.go b/pkg/bmc/k8s.go similarity index 97% rename from pkg/kbmc/k8s.go rename to pkg/bmc/k8s.go index cdf81de..24190dd 100644 --- a/pkg/kbmc/k8s.go +++ b/pkg/bmc/k8s.go @@ -7,7 +7,7 @@ import ( "k8s.io/client-go/tools/clientcmd" kubevirtv1 "kubevirt.io/api/core/v1" - kubevirtv1type "kubevirt.org/virtualmachinebmc/pkg/generated/clientset/versioned/typed/core/v1" + kubevirtv1type "kubevirt.org/kubevirtbmc/pkg/generated/clientset/versioned/typed/core/v1" ) type BootDevice string diff --git a/pkg/kbmc/kbmc.go b/pkg/bmc/kbmc.go similarity index 94% rename from pkg/kbmc/kbmc.go rename to pkg/bmc/kbmc.go index efce4ac..24ae7d9 100644 --- a/pkg/kbmc/kbmc.go +++ b/pkg/bmc/kbmc.go @@ -7,7 +7,7 @@ import ( "github.com/sirupsen/logrus" ipmi "github.com/vmware/goipmi" - kubevirtv1 "kubevirt.org/virtualmachinebmc/pkg/generated/clientset/versioned/typed/core/v1" + kubevirtv1 "kubevirt.org/kubevirtbmc/pkg/generated/clientset/versioned/typed/core/v1" ) type Options struct {