Skip to content

Commit

Permalink
Merge pull request #2932 from fabriziopandini/improve-vm-operator-target
Browse files Browse the repository at this point in the history
🌱 Improve vm operator target + use config/wcp
  • Loading branch information
k8s-ci-robot authored May 2, 2024
2 parents 33f4258 + ca8e2e7 commit c71d43d
Show file tree
Hide file tree
Showing 20 changed files with 1,018 additions and 324 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ test/e2e/data/infrastructure-vsphere-supervisor/main/**/cluster-template*.yaml
test/e2e/data/infrastructure-vsphere-supervisor/*/cluster-template*.yaml
test/e2e/data/infrastructure-vsphere-supervisor/*/clusterclass-quick-start-supervisor.yaml

# vm-operator related
test/infrastructure/vm-operator/vm-operator.yaml

# env vars file used in getting-started.md and manifests generation
envvars.txt

Expand Down
48 changes: 27 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ VCSIM_CONTROLLER_IMG ?= $(REGISTRY)/$(VCSIM_IMAGE_NAME)
VM_OPERATOR_IMAGE_NAME ?= extra/vm-operator
VM_OPERATOR_CONTROLLER_IMG ?= $(STAGING_REGISTRY)/$(VM_OPERATOR_IMAGE_NAME)
VM_OPERATOR_DIR := test/infrastructure/vm-operator
VM_OPERATOR_TMP_DIR ?= vm-operator.tmp
VM_OPERATOR_TMP_DIR ?= $(VM_OPERATOR_DIR)/vm-operator.tmp
# note: this is the commit from 1.8.6 tag
VM_OPERATOR_COMMIT ?= de75746a9505ef3161172d99b735d6593c54f0c5
VM_OPERATOR_VERSION ?= v1.8.6-0-gde75746a
Expand Down Expand Up @@ -799,10 +799,13 @@ set-manifest-image:
##@ vm-operator:

.PHONY: release-vm-operator
release-vm-operator: docker-vm-operator-build-all vm-operator-manifest-build docker-vm-operator-push-all ## Build and push the vm-operator image and manifest for usage in CI
release-vm-operator: docker-build-all-vm-operator generate-manifests-vm-operator docker-push-all-vm-operator clean-vm-operator ## Build and push the vm-operator image and manifest for usage in CI

.PHONY: vm-operator-checkout
vm-operator-checkout:
.PHONY: release-vm-operator-local
release-vm-operator-local: docker-build-all-vm-operator generate-manifests-vm-operator clean-vm-operator ## Build the vm-operator image and manifest for local usage only

.PHONY: checkout-vm-operator
checkout-vm-operator:
@if [ -z "${VM_OPERATOR_VERSION}" ]; then echo "VM_OPERATOR_VERSION is not set"; exit 1; fi
@if [ -d "$(VM_OPERATOR_TMP_DIR)" ]; then \
echo "$(VM_OPERATOR_TMP_DIR) exists, skipping clone"; \
Expand All @@ -817,44 +820,47 @@ vm-operator-checkout:
exit 1; \
fi

.PHONY: vm-operator-manifest-build
vm-operator-manifest-build: $(RELEASE_DIR) $(KUSTOMIZE) vm-operator-checkout ## Build the vm-operator manifest yaml file
kustomize build --load-restrictor LoadRestrictionsNone "$(VM_OPERATOR_TMP_DIR)/config/local" > "$(VM_OPERATOR_DIR)/vm-operator.yaml"
sed -i'' -e 's@image: vmoperator.*@image: '"$(VM_OPERATOR_CONTROLLER_IMG):$(VM_OPERATOR_VERSION)"'@' "$(VM_OPERATOR_DIR)/vm-operator.yaml"
kustomize build "$(VM_OPERATOR_DIR)" > "$(VM_OPERATOR_DIR)/vm-operator-$(VM_OPERATOR_VERSION).yaml"

.PHONY: generate-manifests-vm-operator
generate-manifests-vm-operator: $(RELEASE_DIR) $(KUSTOMIZE) checkout-vm-operator ## Build the vm-operator manifest yaml file
kustomize build --load-restrictor LoadRestrictionsNone "$(VM_OPERATOR_TMP_DIR)/config/wcp" > "$(VM_OPERATOR_DIR)/config/vm-operator.yaml"
sed -i'' -e 's@image: vmoperator.*@image: '"$(VM_OPERATOR_CONTROLLER_IMG):$(VM_OPERATOR_VERSION)"'@' "$(VM_OPERATOR_DIR)/config/vm-operator.yaml"
kustomize build "$(VM_OPERATOR_DIR)/config" > "$(VM_OPERATOR_DIR)/vm-operator-$(VM_OPERATOR_VERSION).yaml"

.PHONY: docker-vm-operator-build-all
docker-vm-operator-build-all: $(addprefix docker-vm-operator-build-,$(VM_OPERATOR_ALL_ARCH)) ## Build docker images for all architectures
.PHONY: docker-build-all-vm-operator
docker-build-all-vm-operator: $(addprefix docker-vm-operator-build-,$(VM_OPERATOR_ALL_ARCH)) ## Build docker images for all architectures

docker-vm-operator-build-%:
$(MAKE) ARCH=$* docker-build-vm-operator

.PHONY: docker-build-vm-operator
docker-build-vm-operator: vm-operator-checkout
docker-build-vm-operator: checkout-vm-operator
@if [ -z "${VM_OPERATOR_VERSION}" ]; then echo "VM_OPERATOR_VERSION is not set"; exit 1; fi
cd $(VM_OPERATOR_TMP_DIR) && \
$(MAKE) IMAGE=$(VM_OPERATOR_CONTROLLER_IMG)-$(ARCH) IMAGE_TAG=$(VM_OPERATOR_VERSION) GOARCH=$(ARCH) docker-build

.PHONY: docker-vm-operator-push-all
docker-vm-operator-push-all: $(addprefix docker-vm-operator-push-,$(VM_OPERATOR_ALL_ARCH)) ## Push the docker images to be included in the release for all architectures + related multiarch manifests
$(MAKE) docker-vm-operator-push-manifest
.PHONY: docker-push-all-vm-operator
docker-push-all-vm-operator: $(addprefix docker-vm-operator-push-,$(VM_OPERATOR_ALL_ARCH)) ## Push the docker images to be included in the release for all architectures + related multiarch manifests
$(MAKE) docker-push-manifest-vm-operator

docker-vm-operator-push-%:
$(MAKE) ARCH=$* docker-vm-operator-push
$(MAKE) ARCH=$* docker-push-vm-operator

.PHONY: docker-vm-operator-push
docker-vm-operator-push:
.PHONY: docker-push-vm-operator
docker-push-vm-operator:
@if [ -z "${VM_OPERATOR_VERSION}" ]; then echo "VM_OPERATOR_VERSION is not set"; exit 1; fi
docker push $(VM_OPERATOR_CONTROLLER_IMG)-$(ARCH):$(VM_OPERATOR_VERSION)

.PHONY: docker-vm-operator-push-manifest
docker-vm-operator-push-manifest:
.PHONY: docker-push-manifest-vm-operator
docker-push-manifest-vm-operator:
@if [ -z "${VM_OPERATOR_VERSION}" ]; then echo "VM_OPERATOR_VERSION is not set"; exit 1; fi
docker manifest create --amend $(VM_OPERATOR_CONTROLLER_IMG):$(VM_OPERATOR_VERSION) $(shell echo $(VM_OPERATOR_ALL_ARCH) | sed -e "s~[^ ]*~$(VM_OPERATOR_CONTROLLER_IMG)\-&:$(VM_OPERATOR_VERSION)~g")
@for arch in $(VM_OPERATOR_ALL_ARCH); do docker manifest annotate --arch $${arch} ${VM_OPERATOR_CONTROLLER_IMG}:${VM_OPERATOR_VERSION} ${VM_OPERATOR_CONTROLLER_IMG}-$${arch}:${VM_OPERATOR_VERSION}; done
docker manifest push --purge $(VM_OPERATOR_CONTROLLER_IMG):$(VM_OPERATOR_VERSION)

.PHONY: clean-vm-operator
clean-vm-operator:
rm -fr $(VM_OPERATOR_TMP_DIR)

## --------------------------------------
## Cleanup
## --------------------------------------
Expand Down
1 change: 1 addition & 0 deletions test/infrastructure/vm-operator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vm-operator.tmp
1 change: 1 addition & 0 deletions test/infrastructure/vm-operator/config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vm-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.2
name: cnsnodevmattachments.cns.vmware.com
spec:
conversion:
strategy: None
group: cns.vmware.com
names:
kind: CnsNodeVmAttachment
listKind: CnsNodeVmAttachmentList
plural: cnsnodevmattachments
singular: cnsnodevmattachment
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: CnsNodeVmAttachment is the Schema for the cnsnodevmattachments
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: CnsNodeVmAttachmentSpec defines the desired state of CnsNodeVmAttachment
properties:
nodeuuid:
description: NodeUUID indicates the UUID of the node where the volume
needs to be attached to. Here NodeUUID is the bios UUID of the node.
type: string
volumename:
description: VolumeName indicates the name of the volume on the supervisor
Cluster. This is guaranteed to be unique in Supervisor cluster.
type: string
required:
- nodeuuid
- volumename
type: object
status:
description: CnsNodeVmAttachmentStatus defines the observed state of CnsNodeVmAttachment
properties:
attached:
description: Indicates the volume is successfully attached. This field
must only be set by the entity completing the attach operation,
i.e. the CNS Operator.
type: boolean
error:
description: The last error encountered during attach/detach operation,
if any. This field must only be set by the entity completing the
attach operation, i.e. the CNS Operator.
type: string
metadata:
additionalProperties:
type: string
description: Before successful attach, this field is populated with
CNS volume ID. Upon successful attach, this field is populated with
any information returned by the attach operation. This field must
only be set by the entity completing the attach operation, i.e.
the CNS Operator
type: object
required:
- attached
type: object
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit c71d43d

Please sign in to comment.