Skip to content

Commit

Permalink
update code to create soft links of crds
Browse files Browse the repository at this point in the history
  • Loading branch information
pravarag committed Sep 9, 2021
1 parent dd93249 commit 1391ed6
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -109,6 +109,7 @@ update-vendor:
.PHONY: unit-test
unit-test: autogen
hack/unit-test.sh
hack/verify-crdgen.sh

.PHONY: install-etcd
install-etcd:
Expand All @@ -125,7 +126,6 @@ integration-test: install-etcd autogen
.PHONY: verify-gofmt
verify-gofmt:
hack/verify-gofmt.sh
hack/verify-crdgen.sh

.PHONY: clean
clean:
Expand Down
27 changes: 10 additions & 17 deletions hack/verify-crdgen.sh 100644 → 100755
Expand Up @@ -18,35 +18,28 @@ set -o errexit
set -o nounset
set -o pipefail

SCHED_PLUGIN_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${SCHED_PLUGIN_ROOT}/hack/lib/init.sh"

kube::golang::verify_go_version
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${SCRIPT_ROOT}/hack/lib/init.sh"

cd "${SCHED_PLUGIN_ROOT}"
kube::golang::verify_go_version

CRD_OPTIONS="crd:trivialVersions=true,preserveUnknownFields=false"

# Download controller-gen locally
CONTROLLER_GEN="$(shell pwd)/bin/controller-gen"
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen)
CONTROLLER_GEN="${GOPATH}/bin/controller-gen"
go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest

# Create a temp directory
_tmpdir="$(mktemp -d "${SCHED_PLUGIN_ROOT}/_tmp")"
# Generate CRD
pushd "${_tmpdir}" &> /dev/null
$(CONTROLLER_GEN) ${CRD_OPTIONS} path="./..." output:crd:artifacts:config=${_tmpdir}/crd/bases
api_paths="./pkg/apis/scheduling/v1alpha1/...;./vendor/github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/..."

popd &> /dev/null
${CONTROLLER_GEN} ${CRD_OPTIONS} paths="${api_paths}" output:dir="./manifests/crds"

pushd "${SCHED_PLUGIN_ROOT}" > /dev/null 2>&1
if ! _out="$(diff -Naupr manifests/coscheduling/ "${_crdtmp}/crd/bases/}")"; then
echo "Generated output differs:" >&2
if ! _out="$(git --no-pager diff -I"edited\smanually" --exit-code)"; then
echo "Generated output differs" >&2
echo "${_out}" >&2
echo "Verification failed."
echo "Verification for CRD generators failed."
exit 1
fi
popd &> /dev/null

rm -r ./_tmpdir
echo "Controllers Gen for CRD verified."
119 changes: 76 additions & 43 deletions manifests/capacityscheduling/crd.yaml
@@ -1,54 +1,87 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: elasticquotas.scheduling.sigs.k8s.io
annotations:
"api-approved.kubernetes.io": "https://github.com/kubernetes-sigs/scheduler-plugins/pull/52"
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/scheduler-plugins/pull/52 # edited manually
controller-gen.kubebuilder.io/version: v0.6.2
creationTimestamp: null
name: elasticquotas.scheduling.sigs.k8s.io
spec:
group: scheduling.sigs.k8s.io
names:
kind: ElasticQuota
listKind: ElasticQuotaList
plural: elasticquotas
singular: elasticquota
kind: ElasticQuota
shortNames:
- eq
- eqs
shortNames: # edited manually
- eq # edited manually
- eqs # edited manually
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
min:
type: object
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
max:
type: object
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
status:
type: object
properties:
used:
type: object
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
- name: v1alpha1
schema:
openAPIV3Schema:
description: ElasticQuota sets elastic quota restrictions per namespace
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: ElasticQuotaSpec defines the Min and Max for Quota.
properties:
max:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Max is the set of desired max limits for each named resource.
The usage of max is based on the resource configurations of successfully
scheduled pods.
type: object
min:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Min is the set of desired guaranteed limits for each
named resource.
type: object
type: object
status:
description: ElasticQuotaStatus defines the observed use.
properties:
used:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Used is the current observed total usage of the resource
in the namespace.
type: object
type: object
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
105 changes: 76 additions & 29 deletions manifests/coscheduling/crd.yaml
@@ -1,59 +1,106 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: podgroups.scheduling.sigs.k8s.io
annotations:
"api-approved.kubernetes.io": "https://github.com/kubernetes-sigs/scheduler-plugins/pull/50"
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/scheduler-plugins/pull/50 # edited manually
controller-gen.kubebuilder.io/version: v0.6.2
creationTimestamp: null
name: podgroups.scheduling.sigs.k8s.io
spec:
group: scheduling.sigs.k8s.io
names:
kind: PodGroup
listKind: PodGroupList
plural: podgroups
singular: podgroup
shortNames:
- pg
- pgs
shortNames: # edited manually
- pg # edited manually
- pgs # edited manually
scope: Namespaced
versions:
- name: "v1alpha1"
served: true
storage: true
- name: v1alpha1
schema:
openAPIV3Schema:
type: object
description: PodGroup is a collection of Pod; used for batch workload.
properties:
spec:
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: Specification of the desired behavior of the pod group.
properties:
minMember:
type: integer
minimum: 1
scheduleTimeoutSeconds:
description: MinMember defines the minimal number of members/tasks
to run the pod group; if there's not enough resources to start all
tasks, the scheduler will not start anyone.
format: int32
type: integer
minResources:
type: object
additionalProperties:
type: string
status:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: MinResources defines the minimal resource of members/tasks
to run the pod group; if there's not enough resources to start all
tasks, the scheduler will not start anyone.
type: object
scheduleTimeoutSeconds:
description: ScheduleTimeoutSeconds defines the maximal time of members/tasks
to wait before run the pod group;
format: int32
type: integer
type: object
status:
description: Status represents the current information about a pod group.
This data may not be up to date.
properties:
failed:
description: The number of pods which reached phase Failed.
format: int32
type: integer
occupiedBy:
description: OccupiedBy marks the workload (e.g., deployment, statefulset)
UID that occupy the podgroup. It is empty if not initialized.
type: string
phase:
description: Current phase of PodGroup.
type: string
occupiedBy:
running:
description: The number of actively running pods.
format: int32
type: integer
scheduleStartTime:
description: ScheduleStartTime of the group
format: date-time
type: string
scheduled:
description: The number of actively running pods.
format: int32
type: integer
default: 0
running:
type: integer
default: 0
succeeded:
description: The number of pods which reached phase Succeeded.
format: int32
type: integer
default: 0
failed:
type: integer
default: 0
scheduleStartTime:
type: string
format: date-time

type: object
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
1 change: 1 addition & 0 deletions manifests/crds/scheduling.sigs.k8s.io_elasticquotas.yaml
1 change: 1 addition & 0 deletions manifests/crds/scheduling.sigs.k8s.io_podgroups.yaml
7 changes: 4 additions & 3 deletions manifests/noderesourcetopology/crd.yaml
@@ -1,12 +1,13 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes/enhancements/pull/1870
controller-gen.kubebuilder.io/version: v0.6.0
api-approved.kubernetes.io: https://github.com/kubernetes/enhancements/pull/1870 # edited manually
controller-gen.kubebuilder.io/version: v0.6.2
creationTimestamp: null
name: noderesourcetopologies.topology.node.k8s.io
namespace: ""
spec:
group: topology.node.k8s.io
names:
Expand Down

0 comments on commit 1391ed6

Please sign in to comment.