From 3e4fef0ddd57089d90e9f1899df6f83628291afd Mon Sep 17 00:00:00 2001 From: Artyom Lukianov Date: Mon, 25 Mar 2019 11:30:55 +0200 Subject: [PATCH] Generate MachineDisruptionBudget via gen-crd --- hack/gen-crd.sh | 1 + ...erator_08_machinedisruptionbudget.crd.yaml | 115 ++++++++++++++++++ ...0000_30_machine-api-operator_09_rbac.yaml} | 0 ...0_machine-api-operator_10_deployment.yaml} | 0 ...hine-api-operator_11_clusteroperator.yaml} | 0 kustomization.yaml | 5 +- .../v1alpha1/machinedisruptionbudget_types.go | 4 + 7 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 install/0000_30_machine-api-operator_08_machinedisruptionbudget.crd.yaml rename install/{0000_30_machine-api-operator_08_rbac.yaml => 0000_30_machine-api-operator_09_rbac.yaml} (100%) rename install/{0000_30_machine-api-operator_09_deployment.yaml => 0000_30_machine-api-operator_10_deployment.yaml} (100%) rename install/{0000_30_machine-api-operator_10_clusteroperator.yaml => 0000_30_machine-api-operator_11_clusteroperator.yaml} (100%) diff --git a/hack/gen-crd.sh b/hack/gen-crd.sh index 691b96019c..a652940209 100755 --- a/hack/gen-crd.sh +++ b/hack/gen-crd.sh @@ -23,6 +23,7 @@ popd echo "Coping generated CRDs" cp $dir/src/github.com/openshift/machine-api-operator/config/crds/healthchecking_v1alpha1_machinehealthcheck.yaml install/0000_30_machine-api-operator_07_machinehealthcheck.crd.yaml +cp $dir/src/github.com/openshift/machine-api-operator/config/crds/healthchecking_v1alpha1_machinedisruptionbudget.yaml install/0000_30_machine-api-operator_08_machinedisruptionbudget.crd.yaml cp $dir/src/github.com/openshift/machine-api-operator/config/crds/machine_v1beta1_machineset.yaml install/0000_30_machine-api-operator_03_machineset.crd.yaml cp $dir/src/github.com/openshift/machine-api-operator/config/crds/machine_v1beta1_machine.yaml install/0000_30_machine-api-operator_02_machine.crd.yaml diff --git a/install/0000_30_machine-api-operator_08_machinedisruptionbudget.crd.yaml b/install/0000_30_machine-api-operator_08_machinedisruptionbudget.crd.yaml new file mode 100644 index 0000000000..df78abd733 --- /dev/null +++ b/install/0000_30_machine-api-operator_08_machinedisruptionbudget.crd.yaml @@ -0,0 +1,115 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + labels: + controller-tools.k8s.io: "1.0" + name: machinedisruptionbudgets.healthchecking.openshift.io +spec: + additionalPrinterColumns: + - JSONPath: .status.currentHealthy + description: The number of healthy machines + name: Healthy + type: integer + - JSONPath: .status.ExpectedMachines + description: The total number of machines + name: Total + type: integer + - JSONPath: .status.desiredHealthy + description: The desired number of healthy machines + name: Desired + type: integer + group: healthchecking.openshift.io + names: + kind: MachineDisruptionBudget + plural: machinedisruptionbudgets + scope: Namespaced + validation: + openAPIV3Schema: + 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/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/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Specification of the desired behavior of the MachineDisruptionBudget. + properties: + maxUnavailable: + description: An deletion is allowed if at most "maxUnavailable" machines + selected by "selector" are unavailable after the deletion. For example, + one can prevent all voluntary deletions by specifying 0. This is a + mutually exclusive setting with "minAvailable". + format: int32 + type: integer + minAvailable: + description: An deletion of the machine is allowed if at least "minAvailable" + machines selected by "selector" will still be available after the + deletion. So for example you can prevent all voluntary deletions by + specifying "100%". + format: int32 + type: integer + selector: + description: Label query over machines whose deletions are managed by + the disruption budget. + type: object + type: object + status: + description: Most recently observed status of the MachineDisruptionBudget. + properties: + DisruptedMachines: + description: DisruptedMachines contains information about machines whose + deletion was processed by the API server but has not yet been observed + by the MachineDisruptionBudget controller. A machine will be in this + map from the time when the API server processed the deletion request + to the time when the machine is seen by MDB controller as having been + marked for deletion (or after a timeout). The key in the map is the + name of the machine and the value is the time when the API server + processed the deletion request. If the deletion didn't occur and a + machine is still there it will be removed from the list automatically + by MachineDisruptionBudget controller after some time. If everything + goes smooth this map should be empty for the most of the time. Large + number of entries in the map may indicate problems with machines deletions. + type: object + ExpectedMachines: + description: total number of machines counted by this disruption budget + format: int32 + type: integer + currentHealthy: + description: current number of healthy machines + format: int32 + type: integer + desiredHealthy: + description: minimum desired number of healthy machines + format: int32 + type: integer + disruptionsAllowed: + description: Number of machines disruptions that are currently allowed. + format: int32 + type: integer + observedGeneration: + description: Most recent generation observed when updating this MDB + status. MachineDisruptionsAllowed and other status information is + valid only if observedGeneration equals to MDB's object generation. + format: int64 + type: integer + required: + - disruptionsAllowed + - currentHealthy + - desiredHealthy + - ExpectedMachines + type: object + version: v1alpha1 +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/install/0000_30_machine-api-operator_08_rbac.yaml b/install/0000_30_machine-api-operator_09_rbac.yaml similarity index 100% rename from install/0000_30_machine-api-operator_08_rbac.yaml rename to install/0000_30_machine-api-operator_09_rbac.yaml diff --git a/install/0000_30_machine-api-operator_09_deployment.yaml b/install/0000_30_machine-api-operator_10_deployment.yaml similarity index 100% rename from install/0000_30_machine-api-operator_09_deployment.yaml rename to install/0000_30_machine-api-operator_10_deployment.yaml diff --git a/install/0000_30_machine-api-operator_10_clusteroperator.yaml b/install/0000_30_machine-api-operator_11_clusteroperator.yaml similarity index 100% rename from install/0000_30_machine-api-operator_10_clusteroperator.yaml rename to install/0000_30_machine-api-operator_11_clusteroperator.yaml diff --git a/kustomization.yaml b/kustomization.yaml index 829017d4d6..2316193578 100644 --- a/kustomization.yaml +++ b/kustomization.yaml @@ -20,8 +20,9 @@ resources: - install/0000_30_machine-api-operator_02_machine.crd.yaml - install/0000_30_machine-api-operator_03_machineset.crd.yaml - install/0000_30_machine-api-operator_07_machinehealthcheck.crd.yaml -- install/0000_30_machine-api-operator_08_rbac.yaml -- install/0000_30_machine-api-operator_09_deployment.yaml +- install/0000_30_machine-api-operator_08_machinedisruptionbudget.crd.yaml +- install/0000_30_machine-api-operator_09_rbac.yaml +- install/0000_30_machine-api-operator_10_deployment.yaml patches: - config/machine-api-operator-patch.yaml diff --git a/pkg/apis/healthchecking/v1alpha1/machinedisruptionbudget_types.go b/pkg/apis/healthchecking/v1alpha1/machinedisruptionbudget_types.go index 9627956803..2aaab2a184 100644 --- a/pkg/apis/healthchecking/v1alpha1/machinedisruptionbudget_types.go +++ b/pkg/apis/healthchecking/v1alpha1/machinedisruptionbudget_types.go @@ -63,6 +63,10 @@ type MachineDisruptionBudgetStatus struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // MachineDisruptionBudget is an object to define the max disruption that a collection of machines can experience +// kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Healthy",type="integer",JSONPath=".status.currentHealthy",description="The number of healthy machines" +// +kubebuilder:printcolumn:name="Total",type="integer",JSONPath=".status.ExpectedMachines",description="The total number of machines" +// +kubebuilder:printcolumn:name="Desired",type="integer",JSONPath=".status.desiredHealthy",description="The desired number of healthy machines" type MachineDisruptionBudget struct { metav1.TypeMeta `json:",inline"` // +optional