This is an automated email from the ASF dual-hosted git repository.
roryqi pushed a commit to branch support-pvc
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
The following commit(s) were added to refs/heads/support-pvc by this push:
new c6c11083b Add ut and doc
c6c11083b is described below
commit c6c11083b109c698bfa833e3f1bfa09f8b7d40ca
Author: Rory <[email protected]>
AuthorDate: Wed Jun 19 16:59:19 2024 +0800
Add ut and doc
---
.../operator/examples/pvc-example/README.md | 26 +++++++++
.../examples/pvc-example/rss-pvc-all-restart.yaml | 68 ++++++++++++++++++++++
.../examples/pvc-example/storage-class.yml | 25 ++++++++
.../sync/shuffleserver/shuffleserver_test.go | 49 ++++++++++++++++
4 files changed, 168 insertions(+)
diff --git a/deploy/kubernetes/operator/examples/pvc-example/README.md
b/deploy/kubernetes/operator/examples/pvc-example/README.md
new file mode 100644
index 000000000..b1135af73
--- /dev/null
+++ b/deploy/kubernetes/operator/examples/pvc-example/README.md
@@ -0,0 +1,26 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+# Use PVC for Shuffle Servers
+
+If we want to use PVC for shuffle servers, we need to edit the rss object as
follows.
+
++ update `.spec.shuffleServer.volumeMounts` with the mount points of PVC.
++ update `.spec.shuffleServer.volumeClaimTemplates` with the correct volume
claim templates.
+
+We can refer to the [example](rss-pvc-all-restart.yaml).
+
diff --git
a/deploy/kubernetes/operator/examples/pvc-example/rss-pvc-all-restart.yaml
b/deploy/kubernetes/operator/examples/pvc-example/rss-pvc-all-restart.yaml
new file mode 100644
index 000000000..2e4fde058
--- /dev/null
+++ b/deploy/kubernetes/operator/examples/pvc-example/rss-pvc-all-restart.yaml
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+apiVersion: uniffle.apache.org/v1alpha1
+kind: RemoteShuffleService
+metadata:
+ name: rss-pvc-full-restart-demo
+ namespace: kube-system
+spec:
+ configMapName: "${rss-configuration-name}"
+ coordinator:
+ image: "${rss-shuffle-server-image}"
+ initContainerImage: "busybox:latest"
+ rpcNodePort:
+ - 32005
+ - 32015
+ httpNodePort:
+ - 32006
+ - 32016
+ xmxSize: "10G"
+ configDir: "/data/rssadmin/rss/conf"
+ replicas: 1
+ excludeNodesFilePath: "/data/rssadmin/rss/coo/exclude_nodes"
+ securityContext:
+ runAsUser: 1000
+ fsGroup: 1000
+ shuffleServer:
+ sync: true
+ replicas: 2
+ rpcPort: 20009
+ rpcNodePort: 20009
+ httpPort: 20019
+ httpNodePort: 20019
+ image: "${rss-shuffle-server-image}"
+ initContainerImage: "busybox:latest"
+ upgradeStrategy:
+ type: "FullRestart"
+ xmxSize: "10G"
+ configDir: "/data/rssadmin/rss/conf"
+ securityContext:
+ runAsUser: 1000
+ fsGroup: 1000
+ volumeMounts:
+ - name: volume
+ mountPath: /data1
+ volumeClaimTemplates:
+ - volumeNameTemplate: "volume"
+ spec:
+ accessModes: ["ReadWriteOnce"]
+ storageClassName: fast
+ resources:
+ requests:
+ storage: 30Gi
\ No newline at end of file
diff --git a/deploy/kubernetes/operator/examples/pvc-example/storage-class.yml
b/deploy/kubernetes/operator/examples/pvc-example/storage-class.yml
new file mode 100644
index 000000000..87f764d66
--- /dev/null
+++ b/deploy/kubernetes/operator/examples/pvc-example/storage-class.yml
@@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+apiVersion: storage.k8s.io/v1
+kind: StorageClass
+metadata:
+ name: fast
+provisioner: kubernetes.io/gce-pd
+parameters:
+ type: pd-ssd
\ No newline at end of file
diff --git
a/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go
b/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go
index f8c7e0a7e..dc151c5df 100644
---
a/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go
+++
b/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go
@@ -27,6 +27,8 @@ import (
appsv1 "k8s.io/api/apps/v1"
autoscalingv2 "k8s.io/api/autoscaling/v2"
corev1 "k8s.io/api/core/v1"
+ "k8s.io/apimachinery/pkg/api/resource"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/utils/pointer"
@@ -138,6 +140,26 @@ var (
Name: "default-secret",
},
}
+
+ standard = "standard"
+ testVolumeClaimTemplates = []corev1.PersistentVolumeClaim{
+ {
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "testVolumeClaimTemplate",
+ },
+ Spec: corev1.PersistentVolumeClaimSpec{
+ AccessModes:
[]corev1.PersistentVolumeAccessMode{
+ "ReadWriteOnce",
+ },
+ Resources: corev1.ResourceRequirements{
+ Requests: corev1.ResourceList{
+ "storage":
*resource.NewQuantity(5*1000*1000*1000, resource.DecimalSI),
+ },
+ },
+ StorageClassName: &standard,
+ },
+ },
+ }
)
func buildRssWithLabels() *uniffleapi.RemoteShuffleService {
@@ -199,6 +221,18 @@ func withCustomImagePullSecrets(imagePullSecrets
[]corev1.LocalObjectReference)
return rss
}
+func withCustomVolumeClaimTemplates(volumeClaimTemplates
[]corev1.PersistentVolumeClaim) *uniffleapi.RemoteShuffleService {
+ rss := utils.BuildRSSWithDefaultValue()
+ rss.Spec.ShuffleServer.VolumeClaimTemplates =
make([]uniffleapi.ShuffleServerPersistentVolumeClaimTemplate, 0,
len(volumeClaimTemplates))
+ for _, pvcTemplate := range volumeClaimTemplates {
+ rss.Spec.ShuffleServer.VolumeClaimTemplates =
append(rss.Spec.ShuffleServer.VolumeClaimTemplates,
uniffleapi.ShuffleServerPersistentVolumeClaimTemplate{
+ VolumeNameTemplate: &pvcTemplate.ObjectMeta.Name,
+ Spec: pvcTemplate.Spec,
+ })
+ }
+ return rss
+}
+
func buildRssWithHPA() *uniffleapi.RemoteShuffleService {
rss := utils.BuildRSSWithDefaultValue()
rss.Spec.ShuffleServer.Autoscaler.Enable = true
@@ -486,6 +520,21 @@ func TestGenerateSts(t *testing.T) {
return false, fmt.Errorf("generated sts should
include imagePullSecrets: %v", testImagePullSecrets)
},
},
+ {
+ name: "set volume claim templates",
+ rss:
withCustomVolumeClaimTemplates(testVolumeClaimTemplates),
+ IsValidSts: func(deploy *appsv1.StatefulSet, rss
*uniffleapi.RemoteShuffleService) (bool, error) {
+ if deploy.Spec.VolumeClaimTemplates != nil {
+ for _, volumeClaimTemplate := range
deploy.Spec.VolumeClaimTemplates {
+ equal :=
reflect.DeepEqual(volumeClaimTemplate, testVolumeClaimTemplates[0])
+ if equal {
+ return true, nil
+ }
+ }
+ }
+ return false, fmt.Errorf("generated sts should
include volumeClaimTemplates: %v", testImagePullSecrets)
+ },
+ },
} {
t.Run(tt.name, func(tc *testing.T) {
sts := GenerateSts(nil, tt.rss)