Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing K0sControlPlane status fields and refactor status calc #774

Merged
Merged
Show file tree
Hide file tree
Changes from 11 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
27 changes: 24 additions & 3 deletions .github/workflows/capi-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ jobs:
uses: supplypike/setup-bin@v4
with:
name: kind
version: v0.20.0
uri: https://github.com/kubernetes-sigs/kind/releases/download/v0.20.0/kind-linux-amd64
version: v0.24.0
uri: https://github.com/kubernetes-sigs/kind/releases/download/v0.24.0/kind-linux-amd64

- name: Install support-bundle
run: |
curl --proto '=https' --tlsv1.2 -L https://github.com/replicatedhq/troubleshoot/releases/download/v0.107.0/support-bundle_linux_amd64.tar.gz \
| tar xzO support-bundle >/usr/local/bin/kubectl-supportbundle \
&& chmod +x /usr/local/bin/kubectl-supportbundle

- name: Setup KinD cluster
run: |
Expand Down Expand Up @@ -88,7 +94,7 @@ jobs:
kind get kubeconfig > kind.conf
export KUBECONFIG=$(realpath kind.conf)
docker system prune -f
make -C inttest ${{ inputs.smoke-suite }} K0S_VERSION=${{ inputs.k0s-version }}
make -C inttest ${{ inputs.smoke-suite }} K0S_VERSION=${{ inputs.k0s-version }} KEEP_AFTER_TESTS=true

- name: Get k0smotron logs
if: failure()
Expand All @@ -97,11 +103,26 @@ jobs:
kubectl logs -n k0smotron deploy/k0smotron-controller-manager-control-plane > /tmp/${{ inputs.smoke-suite }}-k0smotron-control-plane.log
kubectl logs -n k0smotron deploy/k0smotron-controller-manager-infrastructure > /tmp/${{ inputs.smoke-suite }}-k0smotron-infrastructure.log

- name: Collect support bundle
if: failure()
run: |
pwd
kubectl-supportbundle --debug --interactive=false --output="/tmp/${{ inputs.smoke-suite }}-support-bundle.tar.gz" inttest/support-bundle.yaml 1>&2

- name: Docker dump
if: failure()
run: |
docker ps -a > /tmp/${{ inputs.smoke-suite }}-docker-ps.log
docker images > /tmp/${{ inputs.smoke-suite }}-docker-images.log
docker info > /tmp/${{ inputs.smoke-suite }}-docker-info.log

- name: Collect k0s logs and support bundle
if: failure()
uses: actions/upload-artifact@v4
with:
name: smoketests-${{ inputs.smoke-suite }}-files
path: |
/tmp/${{ inputs.smoke-suite }}-k0smotron-*.log
/tmp/${{ inputs.smoke-suite }}-support-bundle.tar.gz
/tmp/${{ inputs.smoke-suite }}-docker-*.log

5 changes: 5 additions & 0 deletions api/controlplane/v1beta1/k0s_template_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ type K0sControlPlaneTemplateResourceSpec struct {
K0sConfigSpec bootstrapv1.K0sConfigSpec `json:"k0sConfigSpec"`
MachineTemplate *K0sControlPlaneMachineTemplate `json:"machineTemplate,omitempty"`
Version string `json:"version,omitempty"`
// UpdateStrategy defines the strategy to use when updating the control plane.
//+kubebuilder:validation:Optional
//+kubebuilder:validation:Enum=InPlace;Recreate
//+kubebuilder:default=InPlace
UpdateStrategy UpdateStrategy `json:"updateStrategy,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
21 changes: 21 additions & 0 deletions api/controlplane/v1beta1/k0s_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const (
UpdateRecreate UpdateStrategy = "Recreate"
)

const (
// ControlPlaneReadyCondition documents the status of the control plane
ControlPlaneReadyCondition clusterv1.ConditionType = "ControlPlaneReady"
)

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:metadata:labels="cluster.x-k8s.io/v1beta1=v1beta1"
Expand Down Expand Up @@ -91,4 +96,20 @@ type K0sControlPlaneStatus struct {
ExternalManagedControlPlane bool `json:"externalManagedControlPlane"`
Replicas int32 `json:"replicas"`
Version string `json:"version"`
Selector string `json:"selector"`
UnavailableReplicas int32 `json:"unavailableReplicas"`
ReadyReplicas int32 `json:"readyReplicas"`
UpdatedReplicas int32 `json:"updatedReplicas"`

// Conditions defines current service state of the K0sControlPlane.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

func (in *K0sControlPlane) GetConditions() clusterv1.Conditions {
return in.Status.Conditions
}

func (in *K0sControlPlane) SetConditions(conditions clusterv1.Conditions) {
in.Status.Conditions = conditions
}
10 changes: 9 additions & 1 deletion api/controlplane/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,51 @@ spec:
type: object
status:
properties:
conditions:
description: Conditions defines current service state of the K0sControlPlane.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
A human readable message indicating details about the transition.
This field may be empty.
type: string
reason:
description: |-
The reason for the condition's last transition in CamelCase.
The specific API may choose whether or not this field is considered a guaranteed API.
This field may not be empty.
type: string
severity:
description: |-
Severity provides an explicit classification of Reason code, so the users or machines can immediately
understand the current situation and act accordingly.
The Severity field MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: |-
Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability to deconflict is important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
controlPlaneReady:
type: boolean
externalManagedControlPlane:
Expand All @@ -276,17 +321,32 @@ spec:
ready:
description: Ready denotes that the control plane is ready
type: boolean
readyReplicas:
format: int32
type: integer
replicas:
format: int32
type: integer
selector:
type: string
unavailableReplicas:
format: int32
type: integer
updatedReplicas:
format: int32
type: integer
version:
type: string
required:
- controlPlaneReady
- externalManagedControlPlane
- initialized
- ready
- readyReplicas
- replicas
- selector
- unavailableReplicas
- updatedReplicas
- version
type: object
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ spec:
required:
- infrastructureRef
type: object
updateStrategy:
default: InPlace
description: UpdateStrategy defines the strategy to use when
updating the control plane.
enum:
- InPlace
- Recreate
type: string
version:
type: string
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,51 @@ spec:
type: object
status:
properties:
conditions:
description: Conditions defines current service state of the K0sControlPlane.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
A human readable message indicating details about the transition.
This field may be empty.
type: string
reason:
description: |-
The reason for the condition's last transition in CamelCase.
The specific API may choose whether or not this field is considered a guaranteed API.
This field may not be empty.
type: string
severity:
description: |-
Severity provides an explicit classification of Reason code, so the users or machines can immediately
understand the current situation and act accordingly.
The Severity field MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: |-
Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability to deconflict is important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
controlPlaneReady:
type: boolean
externalManagedControlPlane:
Expand All @@ -276,17 +321,32 @@ spec:
ready:
description: Ready denotes that the control plane is ready
type: boolean
readyReplicas:
format: int32
type: integer
replicas:
format: int32
type: integer
selector:
type: string
unavailableReplicas:
format: int32
type: integer
updatedReplicas:
format: int32
type: integer
version:
type: string
required:
- controlPlaneReady
- externalManagedControlPlane
- initialized
- ready
- readyReplicas
- replicas
- selector
- unavailableReplicas
- updatedReplicas
- version
type: object
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ spec:
required:
- infrastructureRef
type: object
updateStrategy:
default: InPlace
description: UpdateStrategy defines the strategy to use when
updating the control plane.
enum:
- InPlace
- Recreate
type: string
version:
type: string
required:
Expand Down
Loading
Loading