diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 639765bc..3f582527 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -188,3 +188,16 @@ jobs: export KUBECONFIG=$(realpath kind.conf) docker system prune -f make -C inttest ${{ matrix.smoke-suite }} + + - name: Get k0smotron logs + if: failure() + run: | + kubectl logs -n k0smotron deploy/k0smotron-controller-manager > /tmp/${{ matrix.smoke-suite }}-k0smotron.log + + - name: Collect k0s logs and support bundle + if: failure() + uses: actions/upload-artifact@v3 + with: + name: smoketests-${{ matrix.smoke-suite }}-files + path: | + /tmp/${{ matrix.smoke-suite }}-k0smotron.log diff --git a/Makefile b/Makefile index 0c1645b7..4d26b373 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ help: ## Display this help. ### manifests manifests_targets += config/crd/bases/bootstrap.cluster.x-k8s.io_k0sconfigs.yaml config/crd/bases/bootstrap.cluster.x-k8s.io_k0sconfigs.yaml: $(CONTROLLER_GEN) - $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases + $(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./..." output:crd:artifacts:config=config/crd/bases manifests_targets += config/crd/bases/k0smotron.io_clusters.yaml manifests_targets += config/crd/bases/k0smotron.io_jointokenrequests.yaml diff --git a/api/k0smotron.io/v1beta1/k0smotroncluster_types.go b/api/k0smotron.io/v1beta1/k0smotroncluster_types.go index 53ade393..65afd254 100644 --- a/api/k0smotron.io/v1beta1/k0smotroncluster_types.go +++ b/api/k0smotron.io/v1beta1/k0smotroncluster_types.go @@ -152,7 +152,7 @@ type PersistenceSpec struct { Type string `json:"type"` // PersistentVolumeClaim defines the PVC configuration. Will be used as is in case of .spec.persistence.type is pvc. //+kubebuilder:validation:Optional - PersistentVolumeClaim v1.PersistentVolumeClaim `json:"persistentVolumeClaim,omitempty"` + PersistentVolumeClaim *v1.PersistentVolumeClaim `json:"persistentVolumeClaim,omitempty"` // HostPath defines the host path configuration. Will be used as is in case of .spec.persistence.type is hostPath. //+kubebuilder:validation:Optional HostPath string `json:"hostPath,omitempty"` diff --git a/api/k0smotron.io/v1beta1/zz_generated.deepcopy.go b/api/k0smotron.io/v1beta1/zz_generated.deepcopy.go index d9586e11..abc9f46c 100644 --- a/api/k0smotron.io/v1beta1/zz_generated.deepcopy.go +++ b/api/k0smotron.io/v1beta1/zz_generated.deepcopy.go @@ -262,7 +262,11 @@ func (in *JoinTokenRequestStatus) DeepCopy() *JoinTokenRequestStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PersistenceSpec) DeepCopyInto(out *PersistenceSpec) { *out = *in - in.PersistentVolumeClaim.DeepCopyInto(&out.PersistentVolumeClaim) + if in.PersistentVolumeClaim != nil { + in, out := &in.PersistentVolumeClaim, &out.PersistentVolumeClaim + *out = new(v1.PersistentVolumeClaim) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceSpec. diff --git a/config/crd/bases/bootstrap.cluster.x-k8s.io_k0sworkerconfigtemplates.yaml b/config/crd/bases/bootstrap.cluster.x-k8s.io_k0sworkerconfigtemplates.yaml index b547e463..c261e7d4 100644 --- a/config/crd/bases/bootstrap.cluster.x-k8s.io_k0sworkerconfigtemplates.yaml +++ b/config/crd/bases/bootstrap.cluster.x-k8s.io_k0sworkerconfigtemplates.yaml @@ -37,6 +37,23 @@ spec: template: properties: metadata: + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string type: object spec: properties: diff --git a/config/crd/bases/controlplane.cluster.x-k8s.io_k0smotroncontrolplanes.yaml b/config/crd/bases/controlplane.cluster.x-k8s.io_k0smotroncontrolplanes.yaml index 2e87cf83..73ca0b93 100644 --- a/config/crd/bases/controlplane.cluster.x-k8s.io_k0smotroncontrolplanes.yaml +++ b/config/crd/bases/controlplane.cluster.x-k8s.io_k0smotroncontrolplanes.yaml @@ -535,6 +535,23 @@ spec: description: May contain labels and annotations that will be copied into the PVC when creating it. No other fields are allowed and will be rejected during validation. + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string type: object spec: description: The specification for the PersistentVolumeClaim. @@ -1685,6 +1702,23 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string type: object spec: description: 'spec defines the desired characteristics of diff --git a/config/crd/bases/k0smotron.io_clusters.yaml b/config/crd/bases/k0smotron.io_clusters.yaml index e89111cf..3ea26a0d 100644 --- a/config/crd/bases/k0smotron.io_clusters.yaml +++ b/config/crd/bases/k0smotron.io_clusters.yaml @@ -539,6 +539,23 @@ spec: description: May contain labels and annotations that will be copied into the PVC when creating it. No other fields are allowed and will be rejected during validation. + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string type: object spec: description: The specification for the PersistentVolumeClaim. @@ -1689,6 +1706,23 @@ spec: type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string type: object spec: description: 'spec defines the desired characteristics of diff --git a/internal/controller/k0smotron.io/k0smotroncluster_statefulset.go b/internal/controller/k0smotron.io/k0smotroncluster_statefulset.go index 6a8d6989..5f3354f4 100644 --- a/internal/controller/k0smotron.io/k0smotroncluster_statefulset.go +++ b/internal/controller/k0smotron.io/k0smotroncluster_statefulset.go @@ -179,10 +179,16 @@ func (r *ClusterReconciler) generateStatefulSet(kmc *km.Cluster) (apps.StatefulS MountPath: "/var/lib/k0s", }) case "pvc": - statefulSet.Spec.VolumeClaimTemplates = append(statefulSet.Spec.VolumeClaimTemplates, kmc.Spec.Persistence.PersistentVolumeClaim) + if kmc.Spec.Persistence.PersistentVolumeClaim == nil { + return apps.StatefulSet{}, fmt.Errorf("persistence type is pvc but no pvc is defined") + } + if kmc.Spec.Persistence.PersistentVolumeClaim.Name == "" { + kmc.Spec.Persistence.PersistentVolumeClaim.Name = kmc.GetVolumeName() + } + statefulSet.Spec.VolumeClaimTemplates = append(statefulSet.Spec.VolumeClaimTemplates, *kmc.Spec.Persistence.PersistentVolumeClaim) statefulSet.Spec.Template.Spec.Containers[0].VolumeMounts = append(statefulSet.Spec.Template.Spec.Containers[0].VolumeMounts, v1.VolumeMount{ - Name: kmc.GetVolumeName(), + Name: kmc.Spec.Persistence.PersistentVolumeClaim.Name, MountPath: "/var/lib/k0s", }) }