Skip to content
Merged
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
225 changes: 225 additions & 0 deletions specs/kube-capacity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,146 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
description: delete node detail
operationId: DeleteNode
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NodeDeleteDto'
responses:
'200':
description: Successfully return node detail
content:
application/json:
schema:
$ref: '#/components/schemas/NodeCapacityDetailDto'
'400':
description: Bad Request. Input Validation error/wrong request body.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Unauthorized User
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/orchestrator/k8s/capacity/node/cordon:
put:
description: cordon/unCordon node
operationId: CordonOrUnCordonNode
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NodeCordonReqDto'
responses:
'200':
description: Return successful operation string.
content:
application/json:
schema:
type: string
'400':
description: Bad Request. Input Validation error/wrong request body.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Unauthorized User
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/orchestrator/k8s/capacity/node/drain:
put:
description: drain a node
operationId: DrainNode
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NodeDrainReqDto'
responses:
'200':
description: Return successful operation string.
content:
application/json:
schema:
type: string
'400':
description: Bad Request. Input Validation error/wrong request body.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Unauthorized User
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/orchestrator/k8s/capacity/node/taints/edit:
put:
description: edit node taints
operationId: EditNodeTaints
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NodeTaintEditReqDto'
responses:
'200':
description: Return successful operation string.
content:
application/json:
schema:
type: string
'400':
description: Bad Request. Input Validation error/wrong request body.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Unauthorized User
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

components:
schemas:
ClusterCapacityDto:
Expand Down Expand Up @@ -326,6 +466,91 @@ components:
type: string
kind:
type: string
NodeDeleteDto:
type: object
properties:
clusterId:
type: integer
name:
type: string
version:
type: string
kind:
type: string
NodeCordonReqDto:
type: object
properties:
clusterId:
type: integer
name:
type: string
version:
type: string
kind:
type: string
nodeCordonOptions:
$ref: '#/components/schemas/NodeCordonHelper'
NodeCordonHelper:
type: object
properties:
unschedulableDesired:
type: boolean
description: set true if want to cordon, set false if want to uncordon
NodeDrainReqDto:
type: object
properties:
clusterId:
type: integer
name:
type: string
version:
type: string
kind:
type: string
nodeDrainOptions:
$ref: '#/components/schemas/NodeDrainHelper'
NodeDrainHelper:
type: object
properties:
gracePeriodSeconds:
type: integer
force:
type: boolean
deleteEmptyDirData:
type: boolean
ignoreAllDaemonSets:
type: boolean
disableEviction:
type: boolean
NodeTaintEditReqDto:
type: object
properties:
clusterId:
type: integer
name:
type: string
version:
type: string
kind:
type: string
taints:
type: array
items:
$ref: '#/components/schemas/Taint'
Taint:
type: object
properties:
key:
type: string
effect:
type: string
oneOf:
- "NoSchedule"
- "NoExecute"
- "PreferNoSchedule"
value:
type: string
required: false
NodeManifestUpdateResponse:
type: object
properties:
Expand Down
40 changes: 30 additions & 10 deletions util/k8s/bean.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package k8s

import (
metav1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/kubernetes"
)

type ClusterCapacityDetail struct {
Expand All @@ -11,7 +12,7 @@ type ClusterCapacityDetail struct {
ErrorInConnection string `json:"errorInNodeListing,omitempty"`
NodeCount int `json:"nodeCount,omitempty"`
NodeNames []string `json:"nodeNames"`
NodeErrors map[metav1.NodeConditionType][]string `json:"nodeErrors"`
NodeErrors map[corev1.NodeConditionType][]string `json:"nodeErrors"`
NodeK8sVersions []string `json:"nodeK8sVersions"`
ServerVersion string `json:"serverVersion,omitempty"`
Cpu *ResourceDetailObject `json:"cpu"`
Expand All @@ -29,8 +30,7 @@ type NodeCapacityDetail struct {
Age string `json:"age,omitempty"`
Status string `json:"status,omitempty"`
PodCount int `json:"podCount,omitempty"`
TaintCount int `json:"taintCount,omitempty"`
Errors map[metav1.NodeConditionType]string `json:"errors"`
Errors map[corev1.NodeConditionType]string `json:"errors"`
InternalIp string `json:"internalIp"`
ExternalIp string `json:"externalIp"`
Unschedulable bool `json:"unschedulable"`
Expand Down Expand Up @@ -85,10 +85,30 @@ type NodeConditionObject struct {
Message string `json:"message"`
}

type NodeManifestUpdateDto struct {
ClusterId int `json:"clusterId"`
Name string `json:"name"`
ManifestPatch string `json:"manifestPatch"`
Version string `json:"version"`
Kind string `json:"kind"`
type NodeUpdateRequestDto struct {
ClusterId int `json:"clusterId"`
Name string `json:"name"`
ManifestPatch string `json:"manifestPatch"`
Version string `json:"version"`
Kind string `json:"kind"`
Taints []corev1.Taint `json:"taints"`
NodeCordonHelper *NodeCordonHelper `json:"nodeCordonOptions"`
NodeDrainHelper *NodeDrainHelper `json:"nodeDrainOptions"`
}

type NodeCordonHelper struct {
UnschedulableDesired bool `json:"unschedulableDesired"`
}

type NodeDrainHelper struct {
Force bool `json:"force"`
DeleteEmptyDirData bool `json:"deleteEmptyDirData"`
// GracePeriodSeconds is how long to wait for a pod to terminate.
// IMPORTANT: 0 means "delete immediately"; set to a negative value
// to use the pod's terminationGracePeriodSeconds.
GracePeriodSeconds int `json:"gracePeriodSeconds"`
IgnoreAllDaemonSets bool `json:"ignoreAllDaemonSets"`
// DisableEviction forces drain to use delete rather than evict
DisableEviction bool `json:"disableEviction"`
k8sClientSet *kubernetes.Clientset
}
Loading