Skip to content

Commit a1984c7

Browse files
authored
api: Generate CRDs from APIs (#456)
* api: Generate CRDs from APIs * api: Update API documentation * api: Remove clusterScheduling and dispatchingWindow fields * api: Regen deepcopy * Convert types according to CRD fields * api: Remove list metadata from AppWrapperResourceList
1 parent a4d16e1 commit a1984c7

27 files changed

+920
-1111
lines changed

Makefile

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ GIT_BRANCH:=$(shell git symbolic-ref --short HEAD 2>&1 | grep -v fatal)
66
#define the GO_BUILD_ARGS if you need to pass additional arguments to the go build
77
GO_BUILD_ARGS?=
88

9+
## Location to install dependencies to
10+
LOCALBIN ?= $(shell pwd)/bin
11+
$(LOCALBIN):
12+
mkdir -p $(LOCALBIN)
13+
14+
## Tool Versions
15+
CONTROLLER_TOOLS_VERSION ?= v0.9.2
16+
17+
## Tool Binaries
18+
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
19+
920
# Reset branch name if this a Travis CI environment
1021
ifneq ($(strip $(TRAVIS_BRANCH)),)
1122
GIT_BRANCH:=${TRAVIS_BRANCH}
@@ -28,7 +39,7 @@ endif
2839

2940
.PHONY: print-global-variables
3041

31-
# Build the controler executable for use in docker image build
42+
# Build the controller executable for use in docker image build
3243
mcad-controller: init generate-code
3344
ifeq ($(strip $(GO_BUILD_ARGS)),)
3445
$(info Compiling controller)
@@ -60,6 +71,15 @@ verify-tag-name: print-global-variables
6071
# Check for invalid tag name
6172
t=${TAG} && [ $${#t} -le 128 ] || { echo "Target name $$t has 128 or more chars"; false; }
6273

74+
.PHONY: controller-gen
75+
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
76+
$(CONTROLLER_GEN): $(LOCALBIN)
77+
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
78+
79+
.PHONY: manifests
80+
manifests: controller-gen ## Generate CustomResourceDefinition objects.
81+
$(CONTROLLER_GEN) crd:allowDangerousTypes=true paths="./pkg/apis/..." output:crd:artifacts:config=config/crd/bases
82+
6383
generate-code: pkg/apis/controller/v1beta1/zz_generated.deepcopy.go
6484

6585
pkg/apis/controller/v1beta1/zz_generated.deepcopy.go: ${BIN_DIR}/deepcopy-gen
@@ -139,18 +159,17 @@ clean:
139159
#CRD file maintenance rules
140160
DEPLOYMENT_CRD_DIR=deployment/mcad-controller/crds
141161
CRD_BASE_DIR=config/crd/bases
142-
MCAD_CRDS= ${DEPLOYMENT_CRD_DIR}/ibm.com_quotasubtree-v1.yaml \
162+
MCAD_CRDS= ${DEPLOYMENT_CRD_DIR}/ibm.com_quotasubtrees.yaml \
143163
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_appwrappers.yaml \
144164
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_queuejobs.yaml \
145165
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_schedulingspecs.yaml
146166

147167
update-deployment-crds: ${MCAD_CRDS}
148168

149-
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_schedulingspecs.yaml : ${CRD_BASE_DIR}/mcad.ibm.com_schedulingspecs.yaml
169+
${DEPLOYMENT_CRD_DIR}/ibm.com_quotasubtrees.yaml : ${CRD_BASE_DIR}/ibm.com_quotasubtrees.yaml
150170
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_appwrappers.yaml : ${CRD_BASE_DIR}/mcad.ibm.com_appwrappers.yaml
151171
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_queuejobs.yaml : ${CRD_BASE_DIR}/mcad.ibm.com_queuejobs.yaml
152172
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_schedulingspecs.yaml : ${CRD_BASE_DIR}/mcad.ibm.com_schedulingspecs.yaml
153173

154-
155174
$(DEPLOYMENT_CRD_DIR)/%: ${CRD_BASE_DIR}/%
156-
cp $< $@
175+
cp $< $@

config/crd/bases/ibm.com_quotasubtree-v1.yaml

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.9.2
7+
creationTimestamp: null
8+
name: quotasubtrees.ibm.com
9+
spec:
10+
group: ibm.com
11+
names:
12+
kind: QuotaSubtree
13+
listKind: QuotaSubtreeList
14+
plural: quotasubtrees
15+
singular: quotasubtree
16+
scope: Namespaced
17+
versions:
18+
- name: v1
19+
schema:
20+
openAPIV3Schema:
21+
description: QuotaSubtree is a specification for a quota subtree resource
22+
properties:
23+
apiVersion:
24+
description: 'APIVersion defines the versioned schema of this representation
25+
of an object. Servers should convert recognized schemas to the latest
26+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
27+
type: string
28+
kind:
29+
description: 'Kind is a string value representing the REST resource this
30+
object represents. Servers may infer this from the endpoint the client
31+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
32+
type: string
33+
metadata:
34+
type: object
35+
spec:
36+
description: QuotaSubtreeSpec is the spec for a resource plan
37+
properties:
38+
children:
39+
items:
40+
description: Child is the spec for a QuotaSubtree resource
41+
properties:
42+
name:
43+
type: string
44+
namespace:
45+
type: string
46+
path:
47+
type: string
48+
quotas:
49+
description: Quota is the spec for a QuotaSubtree resource
50+
properties:
51+
disabled:
52+
type: boolean
53+
hardLimit:
54+
type: boolean
55+
requests:
56+
additionalProperties:
57+
anyOf:
58+
- type: integer
59+
- type: string
60+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
61+
x-kubernetes-int-or-string: true
62+
type: object
63+
type: object
64+
type: object
65+
type: array
66+
parent:
67+
type: string
68+
parentNamespace:
69+
type: string
70+
type: object
71+
status:
72+
description: QuotaSubtreeStatus is the status for a QuotaSubtree resource
73+
properties:
74+
children:
75+
items:
76+
description: ResourceAllocation is the spec for the child status
77+
properties:
78+
allocated:
79+
description: ResourceAllocationStatus is the spec for the child
80+
resource usage
81+
properties:
82+
requests:
83+
additionalProperties:
84+
type: string
85+
type: object
86+
type: object
87+
name:
88+
type: string
89+
namespace:
90+
type: string
91+
path:
92+
type: string
93+
type: object
94+
type: array
95+
totalAllocation:
96+
description: ResourceAllocation is the spec for the child status
97+
properties:
98+
allocated:
99+
description: ResourceAllocationStatus is the spec for the child
100+
resource usage
101+
properties:
102+
requests:
103+
additionalProperties:
104+
type: string
105+
type: object
106+
type: object
107+
name:
108+
type: string
109+
namespace:
110+
type: string
111+
path:
112+
type: string
113+
type: object
114+
required:
115+
- children
116+
- totalAllocation
117+
type: object
118+
required:
119+
- spec
120+
type: object
121+
served: true
122+
storage: true

0 commit comments

Comments
 (0)