Skip to content

Commit 69fa929

Browse files
committed
Bump IPAM types to v1beta1 and install IPAM CRDs.
1 parent 8d0f4a1 commit 69fa929

27 files changed

+1609
-56
lines changed

Makefile

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,32 @@ ifeq ($(DBG),1)
1818
GOGCFLAGS ?= -gcflags=all="-N -l"
1919
endif
2020

21-
TOOLS_DIR=./tools
21+
#
22+
# Directories.
23+
#
24+
CLUSTER_API_DIR := third_party/cluster-api
25+
EXP_DIR := ${CLUSTER_API_DIR}/exp
26+
TOOLS_DIR=$(abspath ./tools)
2227
BIN_DIR=bin
2328
TOOLS_BIN_DIR := $(TOOLS_DIR)/$(BIN_DIR)
24-
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/controller-gen)
29+
GO_INSTALL := ./scripts/go_install.sh
30+
31+
# Helper function to get dependency version from go.mod
32+
get_go_version = $(shell go list -m $1 | awk '{print $$2}')
33+
34+
#
35+
# Binaries.
36+
#
37+
# Note: Need to use abspath so we can invoke these from subdirectories
38+
CONTROLLER_GEN_VER := v0.12.0
39+
CONTROLLER_GEN_BIN := controller-gen
40+
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))
41+
CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
42+
43+
YQ_VER := v4.35.2
44+
YQ_BIN := yq
45+
YQ := $(abspath $(TOOLS_BIN_DIR)/$(YQ_BIN)-$(YQ_VER))
46+
YQ_PKG := github.com/mikefarah/yq/v4
2547

2648
.PHONY: all
2749
all: check build test
@@ -55,9 +77,6 @@ ENVTEST = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-runtime/tools/setu
5577
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5678
ENVTEST_K8S_VERSION = 1.29
5779

58-
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
59-
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
60-
6180
.PHONY: vendor
6281
vendor:
6382
$(DOCKER_CMD) ./hack/go-mod.sh
@@ -138,9 +157,12 @@ vet: ## Apply go vet to all go files
138157

139158
.PHONY: generate-third-party-deepcopy
140159
generate-third-party-deepcopy: $(CONTROLLER_GEN)
160+
$(MAKE) clean-generated-yaml SRC_DIRS="${CLUSTER_API_DIR}/crd"
141161
$(CONTROLLER_GEN) object paths="./third_party/cluster-api/..."
142-
$(CONTROLLER_GEN) crd paths="./third_party/cluster-api/..." output\:crd\:artifacts\:config=./third_party/cluster-api/crd
143-
162+
$(CONTROLLER_GEN) \
163+
paths=./$(CLUSTER_API_DIR)/... \
164+
crd:crdVersions=v1 \
165+
output:crd:dir=./${CLUSTER_API_DIR}/crd
144166

145167
.PHONY: crds-sync
146168
crds-sync: ## Sync crds in install with the ones in the vendored oc/api
@@ -154,6 +176,43 @@ verify-crds-sync: ## Verify that the crds in install and the ones in vendored oc
154176
help:
155177
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
156178

179+
## --------------------------------------
180+
## Cleanup / Verification
181+
## --------------------------------------
182+
183+
##@ clean:
184+
185+
.PHONY: clean
186+
clean: ## Remove generated binaries, GitBook files, Helm charts, and Tilt build files
187+
$(MAKE) clean-bin
188+
189+
.PHONY: clean-bin
190+
clean-bin: ## Remove all generated binaries
191+
rm -rf $(BIN_DIR)
192+
rm -rf $(TOOLS_BIN_DIR)
193+
194+
.PHONY: clean-generated-yaml
195+
clean-generated-yaml: ## Remove files generated by conversion-gen from the mentioned dirs. Example SRC_DIRS="./api/v1alpha4"
196+
(IFS=','; for i in $(SRC_DIRS); do find $$i -type f -name '*.yaml' -exec rm -f {} \;; done)
197+
198+
## --------------------------------------
199+
## Hack / Tools
200+
## --------------------------------------
201+
202+
##@ hack/tools:
203+
204+
.PHONY: $(CONTROLLER_GEN_BIN)
205+
$(CONTROLLER_GEN_BIN): $(CONTROLLER_GEN) ## Build a local copy of controller-gen.
206+
207+
.PHONY: $(YQ_BIN)
208+
$(YQ_BIN): $(YQ) ## Build a local copy of yq
209+
210+
$(CONTROLLER_GEN): # Build controller-gen from tools folder.
211+
GOBIN=$(TOOLS_BIN_DIR) GOFLAGS= $(GO_INSTALL) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)
212+
213+
$(YQ):
214+
GOBIN=$(TOOLS_BIN_DIR) GOFLAGS= $(GO_INSTALL) $(YQ_PKG) $(YQ_BIN) ${YQ_VER}
215+
157216
define ensure-home
158217
@ export HOME=$${HOME:=/tmp/kubebuilder-testing}; \
159218
if [ $${HOME} == "/" ]; then \

cmd/vsphere/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/openshift/machine-api-operator/pkg/metrics"
2121
"github.com/openshift/machine-api-operator/pkg/util"
2222
"github.com/openshift/machine-api-operator/pkg/version"
23-
ipamv1alpha1 "github.com/openshift/machine-api-operator/third_party/cluster-api/exp/ipam/api/v1alpha1"
23+
ipamv1beta1 "github.com/openshift/machine-api-operator/third_party/cluster-api/exp/ipam/api/v1beta1"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/klog/v2"
2626
"k8s.io/klog/v2/textlogger"
@@ -196,8 +196,8 @@ func main() {
196196
klog.Fatal(err)
197197
}
198198

199-
if err := ipamv1alpha1.AddToScheme(mgr.GetScheme()); err != nil {
200-
klog.Fatalf("unable to add ipamv1alpha1 to scheme: %v", err)
199+
if err := ipamv1beta1.AddToScheme(mgr.GetScheme()); err != nil {
200+
klog.Fatalf("unable to add ipamv1beta1 to scheme: %v", err)
201201
}
202202

203203
if err := capimachine.AddWithActuator(mgr, machineActuator); err != nil {

hack/crds-sync.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22

33
set -euo pipefail
44

5+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
6+
7+
YQ_BIN=yq
8+
YQ_PATH=tools/bin/${YQ_BIN}
9+
10+
cd "${REPO_ROOT}" && make ${YQ_BIN} >/dev/null
11+
512
# map names of CRD files between the vendored openshift/api repository and the ./install directory
6-
CRDS_MAPPING=( "v1beta1/0000_10_machine.crd.yaml:0000_30_machine-api-operator_02_machine.crd.yaml"
7-
"v1beta1/0000_10_machineset.crd.yaml:0000_30_machine-api-operator_03_machineset.crd.yaml"
8-
"v1beta1/0000_10_machinehealthcheck.yaml:0000_30_machine-api-operator_07_machinehealthcheck.crd.yaml")
13+
CRDS_MAPPING=( "vendor/github.com/openshift/api/machine/v1beta1/0000_10_machine.crd.yaml:0000_30_machine-api-operator_02_machine.crd.yaml"
14+
"vendor/github.com/openshift/api/machine/v1beta1/0000_10_machineset.crd.yaml:0000_30_machine-api-operator_03_machineset.crd.yaml"
15+
"vendor/github.com/openshift/api/machine/v1beta1/0000_10_machinehealthcheck.yaml:0000_30_machine-api-operator_07_machinehealthcheck.crd.yaml"
16+
"third_party/cluster-api/crd/ipam.cluster.x-k8s.io_ipaddressclaims.yaml:0000_30_machine-api-operator_03_ipaddressclaims.crd.yaml"
17+
"third_party/cluster-api/crd/ipam.cluster.x-k8s.io_ipaddresses.yaml:0000_30_machine-api-operator_03_ipaddresses.crd.yaml")
918

1019
for crd in "${CRDS_MAPPING[@]}" ; do
1120
SRC="${crd%%:*}"
1221
DES="${crd##*:}"
13-
cp "vendor/github.com/openshift/api/machine/$SRC" "install/$DES"
22+
cp "$SRC" "install/$DES"
23+
# Inject needed annotation if not found
24+
${YQ_PATH} -i -N '.metadata.annotations."exclude.release.openshift.io/internal-openshift-hosted" |= "true"' "install/$DES"
25+
${YQ_PATH} -i -N '.metadata.annotations."include.release.openshift.io/self-managed-high-availability" |= "true"' "install/$DES"
26+
${YQ_PATH} -i -N '.metadata.annotations."include.release.openshift.io/single-node-developer" |= "true"' "install/$DES"
1427
done
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
controller-gen.kubebuilder.io/version: v0.12.0
6+
exclude.release.openshift.io/internal-openshift-hosted: "true"
7+
include.release.openshift.io/self-managed-high-availability: "true"
8+
include.release.openshift.io/single-node-developer: "true"
9+
name: ipaddressclaims.ipam.cluster.x-k8s.io
10+
spec:
11+
group: ipam.cluster.x-k8s.io
12+
names:
13+
categories:
14+
- cluster-api
15+
kind: IPAddressClaim
16+
listKind: IPAddressClaimList
17+
plural: ipaddressclaims
18+
singular: ipaddressclaim
19+
scope: Namespaced
20+
versions:
21+
- additionalPrinterColumns:
22+
- description: Name of the pool to allocate an address from
23+
jsonPath: .spec.poolRef.name
24+
name: Pool Name
25+
type: string
26+
- description: Kind of the pool to allocate an address from
27+
jsonPath: .spec.poolRef.kind
28+
name: Pool Kind
29+
type: string
30+
- description: Time duration since creation of IPAdressClaim
31+
jsonPath: .metadata.creationTimestamp
32+
name: Age
33+
type: date
34+
name: v1alpha1
35+
schema:
36+
openAPIV3Schema:
37+
description: IPAddressClaim is the Schema for the ipaddressclaim API.
38+
properties:
39+
apiVersion:
40+
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'
41+
type: string
42+
kind:
43+
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'
44+
type: string
45+
metadata:
46+
type: object
47+
spec:
48+
description: IPAddressClaimSpec is the desired state of an IPAddressClaim.
49+
properties:
50+
poolRef:
51+
description: PoolRef is a reference to the pool from which an IP address should be created.
52+
properties:
53+
apiGroup:
54+
description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.
55+
type: string
56+
kind:
57+
description: Kind is the type of resource being referenced
58+
type: string
59+
name:
60+
description: Name is the name of resource being referenced
61+
type: string
62+
required:
63+
- kind
64+
- name
65+
type: object
66+
x-kubernetes-map-type: atomic
67+
required:
68+
- poolRef
69+
type: object
70+
status:
71+
description: IPAddressClaimStatus is the observed status of a IPAddressClaim.
72+
properties:
73+
addressRef:
74+
description: AddressRef is a reference to the address that was created for this claim.
75+
properties:
76+
name:
77+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?'
78+
type: string
79+
type: object
80+
x-kubernetes-map-type: atomic
81+
conditions:
82+
description: Conditions summarises the current state of the IPAddressClaim
83+
items:
84+
description: Condition defines an observation of a Cluster API resource operational state.
85+
properties:
86+
lastTransitionTime:
87+
description: Last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
88+
format: date-time
89+
type: string
90+
message:
91+
description: A human readable message indicating details about the transition. This field may be empty.
92+
type: string
93+
reason:
94+
description: The reason for the condition's last transition in CamelCase. The specific API may choose whether or not this field is considered a guaranteed API. This field may not be empty.
95+
type: string
96+
severity:
97+
description: Severity provides an explicit classification of Reason code, so the users or machines can immediately understand the current situation and act accordingly. The Severity field MUST be set only when Status=False.
98+
type: string
99+
status:
100+
description: Status of the condition, one of True, False, Unknown.
101+
type: string
102+
type:
103+
description: Type of condition in CamelCase or in foo.example.com/CamelCase. Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important.
104+
type: string
105+
required:
106+
- lastTransitionTime
107+
- status
108+
- type
109+
type: object
110+
type: array
111+
type: object
112+
type: object
113+
served: true
114+
storage: false
115+
subresources:
116+
status: {}
117+
- additionalPrinterColumns:
118+
- description: Name of the pool to allocate an address from
119+
jsonPath: .spec.poolRef.name
120+
name: Pool Name
121+
type: string
122+
- description: Kind of the pool to allocate an address from
123+
jsonPath: .spec.poolRef.kind
124+
name: Pool Kind
125+
type: string
126+
- description: Time duration since creation of IPAdressClaim
127+
jsonPath: .metadata.creationTimestamp
128+
name: Age
129+
type: date
130+
name: v1beta1
131+
schema:
132+
openAPIV3Schema:
133+
description: IPAddressClaim is the Schema for the ipaddressclaim API.
134+
properties:
135+
apiVersion:
136+
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'
137+
type: string
138+
kind:
139+
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'
140+
type: string
141+
metadata:
142+
type: object
143+
spec:
144+
description: IPAddressClaimSpec is the desired state of an IPAddressClaim.
145+
properties:
146+
poolRef:
147+
description: PoolRef is a reference to the pool from which an IP address should be created.
148+
properties:
149+
apiGroup:
150+
description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.
151+
type: string
152+
kind:
153+
description: Kind is the type of resource being referenced
154+
type: string
155+
name:
156+
description: Name is the name of resource being referenced
157+
type: string
158+
required:
159+
- kind
160+
- name
161+
type: object
162+
x-kubernetes-map-type: atomic
163+
required:
164+
- poolRef
165+
type: object
166+
status:
167+
description: IPAddressClaimStatus is the observed status of a IPAddressClaim.
168+
properties:
169+
addressRef:
170+
description: AddressRef is a reference to the address that was created for this claim.
171+
properties:
172+
name:
173+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?'
174+
type: string
175+
type: object
176+
x-kubernetes-map-type: atomic
177+
conditions:
178+
description: Conditions summarises the current state of the IPAddressClaim
179+
items:
180+
description: Condition defines an observation of a Cluster API resource operational state.
181+
properties:
182+
lastTransitionTime:
183+
description: Last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
184+
format: date-time
185+
type: string
186+
message:
187+
description: A human readable message indicating details about the transition. This field may be empty.
188+
type: string
189+
reason:
190+
description: The reason for the condition's last transition in CamelCase. The specific API may choose whether or not this field is considered a guaranteed API. This field may not be empty.
191+
type: string
192+
severity:
193+
description: Severity provides an explicit classification of Reason code, so the users or machines can immediately understand the current situation and act accordingly. The Severity field MUST be set only when Status=False.
194+
type: string
195+
status:
196+
description: Status of the condition, one of True, False, Unknown.
197+
type: string
198+
type:
199+
description: Type of condition in CamelCase or in foo.example.com/CamelCase. Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important.
200+
type: string
201+
required:
202+
- lastTransitionTime
203+
- status
204+
- type
205+
type: object
206+
type: array
207+
type: object
208+
type: object
209+
served: true
210+
storage: true
211+
subresources:
212+
status: {}

0 commit comments

Comments
 (0)