[node operator] Add nodemaintenance CRD

Signed-off-by: Malte Poll <mp@edgeless.systems>
This commit is contained in:
Malte Poll 2022-07-01 16:42:08 +02:00 committed by Malte Poll
parent 1cc8c36052
commit be27de3b71
3 changed files with 90 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
nodemaintenancev1beta1 "github.com/medik8s/node-maintenance-operator/api/v1beta1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"k8s.io/client-go/kubernetes/scheme"
@ -50,7 +51,10 @@ var _ = BeforeSuite(func() {
By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{
filepath.Join("..", "config", "crd", "bases"),
filepath.Join("..", "external", "github.com", "medik8s", "node-maintenance-operator", "config", "crd", "bases"),
},
ErrorIfCRDPathMissing: true,
}
@ -62,6 +66,8 @@ var _ = BeforeSuite(func() {
err = updatev1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
err = nodemaintenancev1beta1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
//+kubebuilder:scaffold:scheme

View File

@ -0,0 +1,81 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: nodemaintenances.nodemaintenance.medik8s.io
spec:
group: nodemaintenance.medik8s.io
names:
kind: NodeMaintenance
listKind: NodeMaintenanceList
plural: nodemaintenances
shortNames:
- nm
singular: nodemaintenance
scope: Cluster
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: NodeMaintenance is the Schema for the nodemaintenances API
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: NodeMaintenanceSpec defines the desired state of NodeMaintenance
properties:
nodeName:
description: Node name to apply maintanance on/off
type: string
reason:
description: Reason for maintanance
type: string
required:
- nodeName
type: object
status:
description: NodeMaintenanceStatus defines the observed state of NodeMaintenance
properties:
errorOnLeaseCount:
description: Consecutive number of errors upon obtaining a lease
type: integer
evictionPods:
description: EvictionPods is the total number of pods up for eviction
from the start
type: integer
lastError:
description: LastError represents the latest error if any in the latest
reconciliation
type: string
pendingPods:
description: PendingPods is a list of pending pods for eviction
items:
type: string
type: array
phase:
description: Phase is the represtation of the maintenance progress
(Running,Succeeded,Failed)
type: string
totalpods:
description: TotalPods is the total number of all pods on the node
from the start
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}

View File

@ -18,6 +18,7 @@ import (
updatev1alpha1 "github.com/edgelesssys/constellation/operators/constellation-node-operator/api/v1alpha1"
"github.com/edgelesssys/constellation/operators/constellation-node-operator/controllers"
nodemaintenancev1beta1 "github.com/medik8s/node-maintenance-operator/api/v1beta1"
//+kubebuilder:scaffold:imports
)
@ -28,7 +29,7 @@ var (
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(nodemaintenancev1beta1.AddToScheme(scheme))
utilruntime.Must(updatev1alpha1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}