Skip to content

Commit

Permalink
ROKS: remove machine related CRDs from cluster
Browse files Browse the repository at this point in the history
In a ROKS cluster, the console UI should not show machine related views since
machine management is done outside the cluster. The UI will remove the
views as long as the CRDs are not present.
  • Loading branch information
csrwng committed Mar 3, 2020
1 parent 9b0170a commit 5971a67
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 59 deletions.
15 changes: 11 additions & 4 deletions hack/gen-crd.sh
Expand Up @@ -2,6 +2,13 @@

set -eu

function annotate_crd() {
input="${1}"
output="${2}"
script='import sys,yaml; doc = yaml.safe_load(sys.stdin); doc["metadata"]["annotations"] = { "exclude.release.openshift.io/internal-openshift-hosted": "true" }; yaml.dump(doc, sys.stdout)'
cat ${input} | python -c "${script}" > ${output}
}

echo "Building controller-gen tool..."
go build -o bin/controller-gen github.com/openshift/machine-api-operator/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen

Expand All @@ -23,9 +30,9 @@ GOPATH=$dir ${cwd}/bin/controller-gen crd \
#${cwd}/bin/controller-gen crd paths=$dir/src/github.com/openshift/machine-api-operator/pkg/apis/... output:crd:dir=$dir/src/github.com/openshift/machine-api-operator/config/crds/
popd

echo "Coping generated CRDs"
cp $dir/src/github.com/openshift/machine-api-operator/config/crds/machine.openshift.io_machinehealthchecks.yaml install/0000_30_machine-api-operator_07_machinehealthcheck.crd.yaml
cp $dir/src/github.com/openshift/machine-api-operator/config/crds/machine.openshift.io_machinesets.yaml install/0000_30_machine-api-operator_03_machineset.crd.yaml
cp $dir/src/github.com/openshift/machine-api-operator/config/crds/machine.openshift.io_machines.yaml install/0000_30_machine-api-operator_02_machine.crd.yaml
echo "Copying and patching generated CRDs"
annotate_crd $dir/src/github.com/openshift/machine-api-operator/config/crds/machine.openshift.io_machinehealthchecks.yaml install/0000_30_machine-api-operator_07_machinehealthcheck.crd.yaml
annotate_crd $dir/src/github.com/openshift/machine-api-operator/config/crds/machine.openshift.io_machinesets.yaml install/0000_30_machine-api-operator_03_machineset.crd.yaml
annotate_crd $dir/src/github.com/openshift/machine-api-operator/config/crds/machine.openshift.io_machines.yaml install/0000_30_machine-api-operator_02_machine.crd.yaml

rm -rf $dir
62 changes: 31 additions & 31 deletions install/0000_30_machine-api-operator_02_machine.crd.yaml
@@ -1,8 +1,8 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
exclude.release.openshift.io/internal-openshift-hosted: 'true'
creationTimestamp: null
name: machines.machine.openshift.io
spec:
Expand Down Expand Up @@ -48,7 +48,7 @@ spec:
listKind: MachineList
plural: machines
singular: machine
scope: ""
scope: ''
subresources:
status: {}
validation:
Expand Down Expand Up @@ -159,34 +159,34 @@ spec:
type: object
type: array
errorMessage:
description: "ErrorMessage will be set in the event that there is a
terminal problem reconciling the Machine and will contain a more verbose
string suitable for logging and human consumption. \n This field should
not be set for transitive errors that a controller faces that are
expected to be fixed automatically over time (like service outages),
but instead indicate that something is fundamentally wrong with the
Machine's spec or the configuration of the controller, and that manual
intervention is required. Examples of terminal errors would be invalid
combinations of settings in the spec, values that are unsupported
by the controller, or the responsible controller itself being critically
misconfigured. \n Any transient errors that occur during the reconciliation
of Machines can be added as events to the Machine object and/or logged
in the controller's output."
description: "ErrorMessage will be set in the event that there is a\
\ terminal problem reconciling the Machine and will contain a more\
\ verbose string suitable for logging and human consumption. \n This\
\ field should not be set for transitive errors that a controller\
\ faces that are expected to be fixed automatically over time (like\
\ service outages), but instead indicate that something is fundamentally\
\ wrong with the Machine's spec or the configuration of the controller,\
\ and that manual intervention is required. Examples of terminal errors\
\ would be invalid combinations of settings in the spec, values that\
\ are unsupported by the controller, or the responsible controller\
\ itself being critically misconfigured. \n Any transient errors that\
\ occur during the reconciliation of Machines can be added as events\
\ to the Machine object and/or logged in the controller's output."
type: string
errorReason:
description: "ErrorReason will be set in the event that there is a terminal
problem reconciling the Machine and will contain a succinct value
suitable for machine interpretation. \n This field should not be set
for transitive errors that a controller faces that are expected to
be fixed automatically over time (like service outages), but instead
indicate that something is fundamentally wrong with the Machine's
spec or the configuration of the controller, and that manual intervention
is required. Examples of terminal errors would be invalid combinations
of settings in the spec, values that are unsupported by the controller,
or the responsible controller itself being critically misconfigured.
\n Any transient errors that occur during the reconciliation of Machines
can be added as events to the Machine object and/or logged in the
controller's output."
description: "ErrorReason will be set in the event that there is a terminal\
\ problem reconciling the Machine and will contain a succinct value\
\ suitable for machine interpretation. \n This field should not be\
\ set for transitive errors that a controller faces that are expected\
\ to be fixed automatically over time (like service outages), but\
\ instead indicate that something is fundamentally wrong with the\
\ Machine's spec or the configuration of the controller, and that\
\ manual intervention is required. Examples of terminal errors would\
\ be invalid combinations of settings in the spec, values that are\
\ unsupported by the controller, or the responsible controller itself\
\ being critically misconfigured. \n Any transient errors that occur\
\ during the reconciliation of Machines can be added as events to\
\ the Machine object and/or logged in the controller's output."
type: string
lastOperation:
description: LastOperation describes the last-operation performed by
Expand Down Expand Up @@ -271,7 +271,7 @@ spec:
storage: true
status:
acceptedNames:
kind: ""
plural: ""
kind: ''
plural: ''
conditions: []
storedVersions: []
41 changes: 21 additions & 20 deletions install/0000_30_machine-api-operator_03_machineset.crd.yaml
@@ -1,8 +1,8 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
exclude.release.openshift.io/internal-openshift-hosted: 'true'
creationTimestamp: null
name: machinesets.machine.openshift.io
spec:
Expand Down Expand Up @@ -33,7 +33,7 @@ spec:
listKind: MachineSetList
plural: machinesets
singular: machineset
scope: ""
scope: ''
subresources:
scale:
labelSelectorPath: .status.labelSelector
Expand Down Expand Up @@ -226,21 +226,22 @@ spec:
errorMessage:
type: string
errorReason:
description: "In the event that there is a terminal problem reconciling
the replicas, both ErrorReason and ErrorMessage will be set. ErrorReason
will be populated with a succinct value suitable for machine interpretation,
while ErrorMessage will contain a more verbose string suitable for
logging and human consumption. \n These fields should not be set for
transitive errors that a controller faces that are expected to be
fixed automatically over time (like service outages), but instead
indicate that something is fundamentally wrong with the MachineTemplate's
spec or the configuration of the machine controller, and that manual
intervention is required. Examples of terminal errors would be invalid
combinations of settings in the spec, values that are unsupported
by the machine controller, or the responsible machine controller itself
being critically misconfigured. \n Any transient errors that occur
during the reconciliation of Machines can be added as events to the
MachineSet object and/or logged in the controller's output."
description: "In the event that there is a terminal problem reconciling\
\ the replicas, both ErrorReason and ErrorMessage will be set. ErrorReason\
\ will be populated with a succinct value suitable for machine interpretation,\
\ while ErrorMessage will contain a more verbose string suitable for\
\ logging and human consumption. \n These fields should not be set\
\ for transitive errors that a controller faces that are expected\
\ to be fixed automatically over time (like service outages), but\
\ instead indicate that something is fundamentally wrong with the\
\ MachineTemplate's spec or the configuration of the machine controller,\
\ and that manual intervention is required. Examples of terminal errors\
\ would be invalid combinations of settings in the spec, values that\
\ are unsupported by the machine controller, or the responsible machine\
\ controller itself being critically misconfigured. \n Any transient\
\ errors that occur during the reconciliation of Machines can be added\
\ as events to the MachineSet object and/or logged in the controller's\
\ output."
type: string
fullyLabeledReplicas:
description: The number of replicas that have labels matching the labels
Expand Down Expand Up @@ -272,7 +273,7 @@ spec:
storage: true
status:
acceptedNames:
kind: ""
plural: ""
kind: ''
plural: ''
conditions: []
storedVersions: []
@@ -1,8 +1,8 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
exclude.release.openshift.io/internal-openshift-hosted: 'true'
creationTimestamp: null
name: machinehealthchecks.machine.openshift.io
spec:
Expand Down Expand Up @@ -155,7 +155,7 @@ spec:
storage: true
status:
acceptedNames:
kind: ""
plural: ""
kind: ''
plural: ''
conditions: []
storedVersions: []

0 comments on commit 5971a67

Please sign in to comment.