Skip to content

Commit

Permalink
Add scale subresource for k0scontrolplane (#834)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Pedriza <adripedriza@gmail.com>
Co-authored-by: Adrian Pedriza <adripedriza@gmail.com>
  • Loading branch information
apedriza and AdrianPedriza authored Nov 28, 2024
1 parent 4607fff commit d764604
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 2 deletions.
10 changes: 10 additions & 0 deletions api/controlplane/v1beta1/k0s_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,18 @@ const (

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
// +kubebuilder:metadata:labels="cluster.x-k8s.io/v1beta1=v1beta1"
// +kubebuilder:metadata:labels="cluster.x-k8s.io/provider=control-plane-k0smotron"
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels['cluster\\.x-k8s\\.io/cluster-name']",description="Cluster"
// +kubebuilder:printcolumn:name="API Server Available",type=boolean,JSONPath=".status.ready",description="This denotes that the target API Server is ready to receive requests"
// +kubebuilder:printcolumn:name="Desired",type=integer,JSONPath=".spec.replicas",description="Total number of machines desired by this control plane",priority=10
// +kubebuilder:printcolumn:name="Replicas",type=integer,JSONPath=".status.replicas",description="Total number of non-terminated machines targeted by this control plane"
// +kubebuilder:printcolumn:name="Ready",type=integer,JSONPath=".status.readyReplicas",description="Total number of fully running and ready control plane instances"
// +kubebuilder:printcolumn:name="Updated",type=integer,JSONPath=".status.updatedReplicas",description="Total number of non-terminated machines targeted by this control plane that have the desired template spec"
// +kubebuilder:printcolumn:name="Unavailable",type=integer,JSONPath=".status.unavailableReplicas",description="Total number of unavailable control plane instances targeted by this control plane"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of K0sControlPlane"
// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=".spec.version",description="Kubernetes version associated with this control plane"

type K0sControlPlane struct {
metav1.TypeMeta `json:",inline"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,48 @@ spec:
singular: k0scontrolplane
scope: Namespaced
versions:
- name: v1beta1
- additionalPrinterColumns:
- description: Cluster
jsonPath: .metadata.labels['cluster\.x-k8s\.io/cluster-name']
name: Cluster
type: string
- description: This denotes that the target API Server is ready to receive requests
jsonPath: .status.ready
name: API Server Available
type: boolean
- description: Total number of machines desired by this control plane
jsonPath: .spec.replicas
name: Desired
priority: 10
type: integer
- description: Total number of non-terminated machines targeted by this control
plane
jsonPath: .status.replicas
name: Replicas
type: integer
- description: Total number of fully running and ready control plane instances
jsonPath: .status.readyReplicas
name: Ready
type: integer
- description: Total number of non-terminated machines targeted by this control
plane that have the desired template spec
jsonPath: .status.updatedReplicas
name: Updated
type: integer
- description: Total number of unavailable control plane instances targeted by
this control plane
jsonPath: .status.unavailableReplicas
name: Unavailable
type: integer
- description: Time duration since creation of K0sControlPlane
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Kubernetes version associated with this control plane
jsonPath: .spec.version
name: Version
type: string
name: v1beta1
schema:
openAPIV3Schema:
properties:
Expand Down Expand Up @@ -353,4 +394,8 @@ spec:
served: true
storage: true
subresources:
scale:
labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,48 @@ spec:
singular: k0scontrolplane
scope: Namespaced
versions:
- name: v1beta1
- additionalPrinterColumns:
- description: Cluster
jsonPath: .metadata.labels['cluster\.x-k8s\.io/cluster-name']
name: Cluster
type: string
- description: This denotes that the target API Server is ready to receive requests
jsonPath: .status.ready
name: API Server Available
type: boolean
- description: Total number of machines desired by this control plane
jsonPath: .spec.replicas
name: Desired
priority: 10
type: integer
- description: Total number of non-terminated machines targeted by this control
plane
jsonPath: .status.replicas
name: Replicas
type: integer
- description: Total number of fully running and ready control plane instances
jsonPath: .status.readyReplicas
name: Ready
type: integer
- description: Total number of non-terminated machines targeted by this control
plane that have the desired template spec
jsonPath: .status.updatedReplicas
name: Updated
type: integer
- description: Total number of unavailable control plane instances targeted by
this control plane
jsonPath: .status.unavailableReplicas
name: Unavailable
type: integer
- description: Time duration since creation of K0sControlPlane
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Kubernetes version associated with this control plane
jsonPath: .spec.version
name: Version
type: string
name: v1beta1
schema:
openAPIV3Schema:
properties:
Expand Down Expand Up @@ -353,4 +394,8 @@ spec:
served: true
storage: true
subresources:
scale:
labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
status: {}

0 comments on commit d764604

Please sign in to comment.