Skip to content

Commit 66f0be4

Browse files
committed
PVC object moved to the k0smotron types
Signed-off-by: Alexey Makhov <amakhov@mirantis.com>
1 parent 9fc744b commit 66f0be4

File tree

5 files changed

+115
-4
lines changed

5 files changed

+115
-4
lines changed

.github/workflows/go.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ jobs:
182182
run: |
183183
clusterctl init --infrastructure docker
184184
185+
- name: Install PVC provider
186+
run: |
187+
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.24/deploy/local-path-storage.yaml
188+
185189
- name: Run inttest for CAPI with docker provider
186190
run: |
187191
kind get kubeconfig > kind.conf

api/k0smotron.io/v1beta1/k0smotroncluster_types.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,50 @@ type PersistenceSpec struct {
152152
Type string `json:"type"`
153153
// PersistentVolumeClaim defines the PVC configuration. Will be used as is in case of .spec.persistence.type is pvc.
154154
//+kubebuilder:validation:Optional
155-
PersistentVolumeClaim *v1.PersistentVolumeClaim `json:"persistentVolumeClaim,omitempty"`
155+
PersistentVolumeClaim *PersistentVolumeClaim `json:"persistentVolumeClaim,omitempty"`
156156
// HostPath defines the host path configuration. Will be used as is in case of .spec.persistence.type is hostPath.
157157
//+kubebuilder:validation:Optional
158158
HostPath string `json:"hostPath,omitempty"`
159159
}
160160

161+
// PersistentVolumeClaim is a user's request for and claim to a persistent volume
162+
type PersistentVolumeClaim struct {
163+
metav1.TypeMeta `json:",inline"`
164+
// Standard object's metadata.
165+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
166+
// +optional
167+
ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
168+
169+
// spec defines the desired characteristics of a volume requested by a pod author.
170+
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
171+
// +optional
172+
Spec v1.PersistentVolumeClaimSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
173+
174+
// status represents the current information/status of a persistent volume claim.
175+
// Read-only.
176+
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
177+
// +optional
178+
Status v1.PersistentVolumeClaimStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
179+
}
180+
181+
type ObjectMeta struct {
182+
// +optional
183+
Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
184+
185+
// +optional
186+
Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"`
187+
188+
// +optional
189+
Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"`
190+
191+
// +optional
192+
Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"`
193+
194+
// +optional
195+
// +patchStrategy=merge
196+
Finalizers []string `json:"finalizers,omitempty" patchStrategy:"merge" protobuf:"bytes,14,rep,name=finalizers"`
197+
}
198+
161199
type CertificateRef struct {
162200
//+kubebuilder:validation:Enum=ca;sa;proxy
163201
Type string `json:"type"`

api/k0smotron.io/v1beta1/zz_generated.deepcopy.go

Lines changed: 54 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/k0smotron.io/k0smotroncluster_statefulset.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,16 @@ func (r *ClusterReconciler) generateStatefulSet(kmc *km.Cluster) (apps.StatefulS
185185
if kmc.Spec.Persistence.PersistentVolumeClaim.Name == "" {
186186
kmc.Spec.Persistence.PersistentVolumeClaim.Name = kmc.GetVolumeName()
187187
}
188-
statefulSet.Spec.VolumeClaimTemplates = append(statefulSet.Spec.VolumeClaimTemplates, *kmc.Spec.Persistence.PersistentVolumeClaim)
188+
statefulSet.Spec.VolumeClaimTemplates = append(statefulSet.Spec.VolumeClaimTemplates, v1.PersistentVolumeClaim{
189+
ObjectMeta: metav1.ObjectMeta{
190+
Name: kmc.Spec.Persistence.PersistentVolumeClaim.Name,
191+
Namespace: kmc.Spec.Persistence.PersistentVolumeClaim.Namespace,
192+
Labels: kmc.Spec.Persistence.PersistentVolumeClaim.Labels,
193+
Annotations: kmc.Spec.Persistence.PersistentVolumeClaim.Annotations,
194+
Finalizers: kmc.Spec.Persistence.PersistentVolumeClaim.Finalizers,
195+
},
196+
Spec: kmc.Spec.Persistence.PersistentVolumeClaim.Spec,
197+
})
189198

190199
statefulSet.Spec.Template.Spec.Containers[0].VolumeMounts = append(statefulSet.Spec.Template.Spec.Containers[0].VolumeMounts, v1.VolumeMount{
191200
Name: kmc.Spec.Persistence.PersistentVolumeClaim.Name,

inttest/capi-docker/capi_docker_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,14 @@ metadata:
181181
spec:
182182
k0sVersion: v1.27.2-k0s.0
183183
persistence:
184-
type: emptyDir
184+
type: pvc
185+
persistentVolumeClaim:
186+
spec:
187+
accessModes:
188+
- ReadWriteOnce
189+
resources:
190+
requests:
191+
storage: 50Mi
185192
service:
186193
type: NodePort
187194
k0sConfig:

0 commit comments

Comments
 (0)