Skip to content
Open
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ metadata:
name: nodedrain-node1
spec:
nodeName: node1
disableCordon: false # optional
waitForPodsToRestart: true # optional
```

Expand Down
22 changes: 11 additions & 11 deletions api/v1/nodedrain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ type NodeDrainPhase string

const (
// NodeDrainFinalizer is a finalizer for a NodeMaintenance CR deletion
NodeDrainFinalizer string = "co.uk.gezb,NodeDrain"
NodeDrainFinalizer string = "co.uk.gezb.NodeDrain"

NodeDrainAnnotation string = "co.uk.gezb.node-restart-controller"

NodeDrainPhasePending NodeDrainPhase = "Pending"
NodeDrainPhaseCordoned NodeDrainPhase = "Cordoned"
Expand All @@ -33,31 +35,29 @@ type NodeDrainSpec struct {
VersionToDrainRegex string `json:"versionToDrainRegex"`
// NodeRole is the nodes expected "role" label
NodeRole string `json:"nodeRole"`
// DisableCordon stop the controller cordoning the node
// +kubebuilder:validation:Optional
DisableCordon bool `json:"disableCordon"`
// WaitForPods waits for the evicted pods to be running again before completing
// +kubebuilder:validation:Optional
WaitForPodsToRestart bool `json:"waitForPodsToRestart"`
SkipWaitForPodsToRestart bool `json:"skipWaitForPodsToRestart"`
}

// NodeDrainStatus defines the observed state of NodeDrain.
type NodeDrainStatus struct {
// Phase represents the progress of this nodeDrain
// +operator-sdk:csv:customresourcedefinitions:type=status
Phase NodeDrainPhase `json:"phase"`
// The last time the status has been updated
LastUpdate metav1.Time `json:"lastUpdate,omitempty"`
// LastError represents the latest error if any in the latest reconciliation
LastError string `json:"lastError,omitempty"`
// PodsToBeEvicted is the list of pods for the controller needs to evict
PodsToBeEvicted []NamespaceAndName `json:"podsToBeEvicted,omitempty"`
// PendingPods is a list of pending pods for eviction
PendingPods []string `json:"pendingPods,omitempty"`
// PendingEvictionPods is a list of pods still to be evicted
PendingEvictionPods []string `json:"PendingEvictionPods,omitempty"`
// PodsToRestart is the list of pods that we are waiting to restart
PodsToRestart []NamespaceAndName `json:"PodsToRestart,omitempty"`
// TotalPods is the total number of all pods on the node from the start
// +operator-sdk:csv:customresourcedefinitions:type=status
TotalPods int `json:"totalPods,omitempty"`
// EvictionPods is the total number of pods up for eviction from the start
EvictionPodCount int `json:"evictionPods,omitempty"`
EvictionPodCount int `json:"evictionPods"`
// Percentage completion of draining the node
DrainProgress int `json:"drainProgress,omitempty"`
// PodsBlockingDrain is a list of pods that are blocking the draining of this node
Expand All @@ -67,7 +67,7 @@ type NodeDrainStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Phase of the NodeDrain"
// +kubebuilder:printcolumn:name="Pods BlockingDrain",type="string",JSONPath=".status.podsblockingdrain",description="Pods that are blocking drain"
// +kubebuilder:printcolumn:name="Pods BlockingDrain",type="string",JSONPath=".status.podsBlockingDrain",description="Pods that are blocking drain"

// NodeDrain is the Schema for the nodedrains API.
type NodeDrain struct {
Expand Down
9 changes: 7 additions & 2 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 23 additions & 13 deletions config/crd/bases/k8s.gezb.co.uk_nodedrains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
name: Phase
type: string
- description: Pods that are blocking drain
jsonPath: .status.podsblockingdrain
jsonPath: .status.podsBlockingDrain
name: Pods BlockingDrain
type: string
name: v1
Expand Down Expand Up @@ -48,31 +48,45 @@ spec:
spec:
description: NodeDrainSpec defines the desired state of NodeDrain.
properties:
disableCordon:
description: DisableCordon stop the controller cordoning the node
type: boolean
nodeName:
description: NodeName is the name of the node to drain
type: string
nodeRole:
description: NodeRole is the nodes expected "role" label
type: string
skipWaitForPodsToRestart:
description: WaitForPods waits for the evicted pods to be running
again before completing
type: boolean
versionToDrainRegex:
description: VersionToDrainRegex is a regex to match the expected
kubernetes version that we want to Drain
type: string
waitForPodsToRestart:
description: WaitForPods waits for the evicted pods to be running
again before completing
type: boolean
required:
- nodeName
- nodeRole
- skipWaitForPodsToRestart
- versionToDrainRegex
type: object
status:
description: NodeDrainStatus defines the observed state of NodeDrain.
properties:
PendingEvictionPods:
description: PendingEvictionPods is a list of pods still to be evicted
items:
type: string
type: array
PodsToRestart:
description: PodsToRestart is the list of pods that we are waiting
to restart
items:
properties:
name:
type: string
namespace:
type: string
type: object
type: array
drainProgress:
description: Percentage completion of draining the node
type: integer
Expand All @@ -88,11 +102,6 @@ spec:
description: The last time the status has been updated
format: date-time
type: string
pendingPods:
description: PendingPods is a list of pending pods for eviction
items:
type: string
type: array
phase:
description: Phase represents the progress of this nodeDrain
type: string
Expand All @@ -116,6 +125,7 @@ spec:
from the start
type: integer
required:
- evictionPods
- phase
type: object
type: object
Expand Down
1 change: 0 additions & 1 deletion config/samples/k8s_v1_nodedrain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ metadata:
name: nodedrain-sample
spec:
nodeName: node1
disableCordon: false # optional
waitForPodsToRestart: true # optional
Loading
Loading