Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ legacy management-cluster install and will be removed. See
[Planning and registering physical devices](../docs/operations/physical-inventory.md).

`config/components/device-operations` registers `DeviceCustody`, the Device
operation kinds, their ProtectedResources, the coordinator, requester, viewer
and recovery operator roles, and the creator webhook. `config/milo` includes all
of it, and the `fleet-registration` server serves the webhook at
`/validate-operation-creator`. `config/milo-synthetic` includes the kinds,
ProtectedResources and roles without the webhook, because it installs no
registration webhook. `config/standalone` includes only the CRDs and enforces the
creator rule with a ValidatingAdmissionPolicy. Including the kinds installs no
coordinator: the production manager has no provider, so nothing creates
custody operations there. See [device custody](../docs/development/device-custody.md#cutover-increment-c).
operation kinds, their ProtectedResources, the coordinator, requester, viewer,
recovery operator and power operator roles, and the creator webhook.
`config/milo` includes all of it, and the `fleet-registration` server serves
the webhook at `/validate-operation-creator`. `config/milo-synthetic` includes
the kinds, ProtectedResources and roles without the webhook, because it
installs no registration webhook. `config/standalone` includes only the CRDs
and enforces the creator rule with a ValidatingAdmissionPolicy. Including the
kinds installs no coordinator: the production manager has no provider, so
nothing creates custody operations there. See [device custody](../docs/development/device-custody.md#cutover-increment-c).

`config/base/bmc-discovery` runs read-only BMC discovery for one Milo project
in a cluster that can reach the BMC network: one replica, no leader election,
Expand Down
250 changes: 250 additions & 0 deletions config/components/device-operations/crds/fleet.datumapis.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,256 @@ spec:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: devicepoweroperations.fleet.datumapis.com
annotations:
discovery.miloapis.com/parent-contexts: Project
spec:
group: fleet.datumapis.com
names:
kind: DevicePowerOperation
listKind: DevicePowerOperationList
plural: devicepoweroperations
singular: devicepoweroperation
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
subresources:
status: {}
additionalPrinterColumns:
- name: Device
type: string
jsonPath: .spec.deviceRef.name
- name: Action
type: string
jsonPath: .spec.action
- name: Phase
type: string
jsonPath: .status.phase
- name: Reason
type: string
jsonPath: .status.reason
- name: Fence
type: integer
jsonPath: .status.fence
schema:
openAPIV3Schema:
type: object
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
type: object
properties:
creator:
type: object
properties:
username:
type: string
minLength: 1
maxLength: 512
uid:
type: string
minLength: 1
maxLength: 512
required:
- username
- uid
deviceRef:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 253
required:
- name
authority:
type: object
properties:
allocationRef:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 253
required:
- name
serviceRequest:
type: object
properties:
reason:
type: string
minLength: 1
maxLength: 512
required:
- reason
x-kubernetes-validations:
- rule: has(self.allocationRef) != has(self.serviceRequest)
message: set exactly one of allocationRef and serviceRequest
action:
type: string
enum:
- "On"
- ForceOff
- ForceRestart
- PowerCycle
expectedSystemUUID:
type: string
pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
machineGeneration:
type: integer
format: int64
minimum: 1
required:
- creator
- deviceRef
- authority
- action
x-kubernetes-validations:
- rule: self == oldSelf
message: an operation spec is immutable after create
- rule: has(self.authority.serviceRequest) == has(self.expectedSystemUUID)
message: a staff operation sets expectedSystemUUID, and a provider operation omits it
- rule: has(self.authority.allocationRef) == has(self.machineGeneration)
message: a provider operation sets machineGeneration, and a staff operation omits it
- rule: '!has(self.authority.allocationRef) || size(self.authority.allocationRef.name) <= 200'
message: a provider operation's allocation name is at most 200 characters, so its name and retry names fit
status:
type: object
properties:
admission:
type: object
properties:
fence:
type: integer
format: int64
minimum: 1
required:
- fence
phase:
type: string
enum:
- Pending
- Admitted
- Dispatched
- Verifying
- Succeeded
- Failed
- Cancelled
- OutcomeUnknown
reason:
type: string
maxLength: 128
message:
type: string
maxLength: 1024
fence:
type: integer
format: int64
minimum: 0
admittedAt:
type: string
format: date-time
deadline:
type: string
format: date-time
finishedAt:
type: string
format: date-time
inputDigest:
type: string
maxLength: 128
snapshot:
type: object
properties:
bmcEndpoint:
type: string
maxLength: 2048
systemUUID:
type: string
maxLength: 64
bootMACAddress:
type: string
maxLength: 32
bmcPublicKeySHA256:
type: string
maxLength: 128
deviceGeneration:
type: integer
format: int64
discoveryObservedAt:
type: string
maxLength: 64
extra:
type: object
maxProperties: 16
additionalProperties:
type: string
maxLength: 256
evidence:
type: object
properties:
requestSentAt:
type: string
format: date-time
power:
type: object
properties:
before:
type: object
properties:
state:
type: string
enum:
- "On"
- "Off"
- PoweringOn
- PoweringOff
- Paused
observedAt:
type: string
format: date-time
required:
- state
- observedAt
after:
type: object
properties:
state:
type: string
enum:
- "On"
- "Off"
- PoweringOn
- PoweringOff
- Paused
observedAt:
type: string
format: date-time
required:
- state
- observedAt
resetEvidence:
type: string
enum:
- LastResetTime
- ObservedOff
x-kubernetes-validations:
- rule: '!has(oldSelf.phase) || (has(self.phase) && self.phase in {''Pending'': [''Pending'', ''Admitted'', ''Failed'', ''Cancelled'', ''OutcomeUnknown''], ''Admitted'': [''Admitted'', ''Dispatched'', ''Verifying'', ''Succeeded'', ''Failed'', ''Cancelled'', ''OutcomeUnknown''], ''Dispatched'': [''Dispatched'', ''Verifying'', ''Succeeded'', ''Failed'', ''Cancelled'', ''OutcomeUnknown''], ''Verifying'': [''Verifying'', ''Succeeded'', ''Failed'', ''Cancelled'', ''OutcomeUnknown''], ''Succeeded'': [''Succeeded''], ''Failed'': [''Failed''], ''Cancelled'': [''Cancelled''], ''OutcomeUnknown'': [''OutcomeUnknown'']}[oldSelf.phase])'
message: operation phases move forward only, and an ended phase is final
required:
- spec
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: devicerecoveries.fleet.datumapis.com
annotations:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: iam.miloapis.com/v1alpha1
kind: ProtectedResource
metadata:
name: fleet.datumapis.com-devicepoweroperation
spec:
serviceRef:
name: fleet.datumapis.com
kind: DevicePowerOperation
plural: devicepoweroperations
singular: devicepoweroperation
# Status has one writer, the coordinator. With subresource authorization
# enabled, status writes use devicepoweroperations/status.update and
# devicepoweroperations/status.patch instead of updateStatus.
permissions: [list, get, watch, create, update, patch, delete, updateStatus]
subresources:
- name: status
permissions: [update, patch]
parentResources:
- apiGroup: resourcemanager.miloapis.com
kind: Project
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ resources:
- devicecustody.yaml
- deviceinstallation.yaml
- devicewipe.yaml
- devicepoweroperation.yaml
- devicerecovery.yaml
6 changes: 6 additions & 0 deletions config/components/device-operations/roles/coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ spec:
- fleet.datumapis.com/devicewipes.delete
- fleet.datumapis.com/devicewipes.updateStatus
- fleet.datumapis.com/devicewipes/status.update
- fleet.datumapis.com/devicepoweroperations.get
- fleet.datumapis.com/devicepoweroperations.list
- fleet.datumapis.com/devicepoweroperations.watch
- fleet.datumapis.com/devicepoweroperations.delete
- fleet.datumapis.com/devicepoweroperations.updateStatus
- fleet.datumapis.com/devicepoweroperations/status.update
- fleet.datumapis.com/devicerecoveries.get
- fleet.datumapis.com/devicerecoveries.list
- fleet.datumapis.com/devicerecoveries.watch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ resources:
- recovery-operator.yaml
- installation-requester.yaml
- wipe-requester.yaml
- power-operator.yaml
- power-requester.yaml
13 changes: 13 additions & 0 deletions config/components/device-operations/roles/power-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: iam.miloapis.com/v1alpha1
kind: Role
metadata:
name: fleet.datumapis.com-device-power-operator
annotations:
kubernetes.io/display-name: Fleet Device Power Operator
kubernetes.io/description: Power a Device on or off, or reset it, while no customer holds it. Creates only DevicePowerOperations, and does not read MachineAllocations.
spec:
launchStage: Alpha
inheritedRoles:
- name: fleet.datumapis.com-device-operations-viewer
includedPermissions:
- fleet.datumapis.com/devicepoweroperations.create
17 changes: 17 additions & 0 deletions config/components/device-operations/roles/power-requester.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: iam.miloapis.com/v1alpha1
kind: Role
metadata:
name: fleet.datumapis.com-device-power-requester
annotations:
kubernetes.io/display-name: Fleet Device Power Requester
kubernetes.io/description: The Fleet provider for Metal. Creates DevicePowerOperations from Machine power intent and reads custody.
spec:
launchStage: Alpha
includedPermissions:
- fleet.datumapis.com/devicepoweroperations.create
- fleet.datumapis.com/devicepoweroperations.get
- fleet.datumapis.com/devicepoweroperations.list
- fleet.datumapis.com/devicepoweroperations.watch
- fleet.datumapis.com/devicecustodies.get
- fleet.datumapis.com/devicecustodies.list
- fleet.datumapis.com/devicecustodies.watch
3 changes: 3 additions & 0 deletions config/components/device-operations/roles/viewer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ spec:
- fleet.datumapis.com/devicewipes.get
- fleet.datumapis.com/devicewipes.list
- fleet.datumapis.com/devicewipes.watch
- fleet.datumapis.com/devicepoweroperations.get
- fleet.datumapis.com/devicepoweroperations.list
- fleet.datumapis.com/devicepoweroperations.watch
- fleet.datumapis.com/devicerecoveries.get
- fleet.datumapis.com/devicerecoveries.list
- fleet.datumapis.com/devicerecoveries.watch
2 changes: 1 addition & 1 deletion config/components/device-operations/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ webhooks:
- apiGroups: [fleet.datumapis.com]
apiVersions: [v1alpha1]
operations: [CREATE, UPDATE]
resources: [deviceinstallations, devicewipes, devicerecoveries]
resources: [deviceinstallations, devicewipes, devicepoweroperations, devicerecoveries]
scope: Namespaced
4 changes: 4 additions & 0 deletions config/components/inventory/crds/fleet.datumapis.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ spec:
serialNumber: {type: string, maxLength: 253}
sku: {type: string, maxLength: 253}
powerState: {type: string, maxLength: 63}
resetTypes:
type: array
maxItems: 16
items: {type: string, minLength: 1, maxLength: 63}
networkInterfaces:
type: array
maxItems: 32
Expand Down
Loading
Loading