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

PVC object moved to the k0smotron types #348

Merged
merged 3 commits into from
Nov 16, 2023
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
4 changes: 4 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ jobs:
run: |
clusterctl init --infrastructure docker

- name: Install PVC provider
run: |
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.24/deploy/local-path-storage.yaml

- name: Run inttest for CAPI with docker provider
run: |
kind get kubeconfig > kind.conf
Expand Down
40 changes: 39 additions & 1 deletion api/k0smotron.io/v1beta1/k0smotroncluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,50 @@ 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 *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"`
}

// PersistentVolumeClaim is a user's request for and claim to a persistent volume
type PersistentVolumeClaim struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

// spec defines the desired characteristics of a volume requested by a pod author.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
// +optional
Spec v1.PersistentVolumeClaimSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`

// status represents the current information/status of a persistent volume claim.
// Read-only.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
// +optional
Status v1.PersistentVolumeClaimStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}

type ObjectMeta struct {
// +optional
Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`

// +optional
Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"`

// +optional
Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"`

// +optional
Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"`

// +optional
// +patchStrategy=merge
Finalizers []string `json:"finalizers,omitempty" patchStrategy:"merge" protobuf:"bytes,14,rep,name=finalizers"`
}

type CertificateRef struct {
//+kubebuilder:validation:Enum=ca;sa;proxy
Type string `json:"type"`
Expand Down
55 changes: 54 additions & 1 deletion api/k0smotron.io/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 @@ -187,7 +187,16 @@ func (r *ClusterReconciler) generateStatefulSet(kmc *km.Cluster) (apps.StatefulS
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.VolumeClaimTemplates = append(statefulSet.Spec.VolumeClaimTemplates, v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: kmc.Spec.Persistence.PersistentVolumeClaim.Name,
Namespace: kmc.Spec.Persistence.PersistentVolumeClaim.Namespace,
Labels: kmc.Spec.Persistence.PersistentVolumeClaim.Labels,
Annotations: kmc.Spec.Persistence.PersistentVolumeClaim.Annotations,
Finalizers: kmc.Spec.Persistence.PersistentVolumeClaim.Finalizers,
},
Spec: kmc.Spec.Persistence.PersistentVolumeClaim.Spec,
})

statefulSet.Spec.Template.Spec.Containers[0].VolumeMounts = append(statefulSet.Spec.Template.Spec.Containers[0].VolumeMounts, v1.VolumeMount{
Name: kmc.Spec.Persistence.PersistentVolumeClaim.Name,
Expand Down
9 changes: 8 additions & 1 deletion inttest/capi-docker/capi_docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,14 @@ metadata:
spec:
k0sVersion: v1.27.2-k0s.0
persistence:
type: emptyDir
type: pvc
persistentVolumeClaim:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
service:
type: NodePort
k0sConfig:
Expand Down