You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uniffle.apache.org by xi...@apache.org on 2023/03/28 02:04:40 UTC
[incubator-uniffle] branch master updated: [#716] improvement(operator): support specifying imagePullSecrets (#765)
This is an automated email from the ASF dual-hosted git repository.
xianjingfeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
The following commit(s) were added to refs/heads/master by this push:
new e8d99099 [#716] improvement(operator): support specifying imagePullSecrets (#765)
e8d99099 is described below
commit e8d990994c9c149efd01b30373f6b41d98261092
Author: xianjingfeng <xi...@gmail.com>
AuthorDate: Tue Mar 28 10:04:33 2023 +0800
[#716] improvement(operator): support specifying imagePullSecrets (#765)
### What changes were proposed in this pull request?
Support specifying imagePullSecrets
### Why are the changes needed?
If the images are stored in a private registry, Kubernetes needs to be provided with the necessary credentials to authenticate with the registry.
Fix: #716
### Does this PR introduce any user-facing change?
Example:
apiVersion: uniffle.apache.org/v1alpha1
kind: RemoteShuffleService
metadata:
name: rss-demo
namespace: rss
spec:
# ConfigMapName indicates configMap name stores configurations of coordinators and shuffle servers.
configMapName: rss-configuration
imagePullSecrets:
- name: "default-secret"
### How was this patch tested?
UT
---
.../uniffle/v1alpha1/remoteshuffleservice_types.go | 3 +++
.../api/uniffle/v1alpha1/zz_generated.deepcopy.go | 5 +++++
.../uniffle.apache.org_remoteshuffleservices.yaml | 11 ++++++++++
.../pkg/controller/sync/coordinator/coordinator.go | 1 +
.../sync/coordinator/coordinator_test.go | 25 ++++++++++++++++++++++
.../controller/sync/shuffleserver/shuffleserver.go | 1 +
.../sync/shuffleserver/shuffleserver_test.go | 25 ++++++++++++++++++++++
7 files changed, 71 insertions(+)
diff --git a/deploy/kubernetes/operator/api/uniffle/v1alpha1/remoteshuffleservice_types.go b/deploy/kubernetes/operator/api/uniffle/v1alpha1/remoteshuffleservice_types.go
index 3d9a538d..67176eff 100644
--- a/deploy/kubernetes/operator/api/uniffle/v1alpha1/remoteshuffleservice_types.go
+++ b/deploy/kubernetes/operator/api/uniffle/v1alpha1/remoteshuffleservice_types.go
@@ -59,6 +59,9 @@ type RemoteShuffleServiceSpec struct {
// ConfigMapName indicates configMap name stores configurations of coordinators and shuffle servers.
ConfigMapName string `json:"configMapName"`
+
+ // +optional
+ ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
}
// CoordinatorConfig records configuration used to generate workload of coordination.
diff --git a/deploy/kubernetes/operator/api/uniffle/v1alpha1/zz_generated.deepcopy.go b/deploy/kubernetes/operator/api/uniffle/v1alpha1/zz_generated.deepcopy.go
index 65cf106b..81fcd293 100644
--- a/deploy/kubernetes/operator/api/uniffle/v1alpha1/zz_generated.deepcopy.go
+++ b/deploy/kubernetes/operator/api/uniffle/v1alpha1/zz_generated.deepcopy.go
@@ -308,6 +308,11 @@ func (in *RemoteShuffleServiceSpec) DeepCopyInto(out *RemoteShuffleServiceSpec)
*out = new(ShuffleServerConfig)
(*in).DeepCopyInto(*out)
}
+ if in.ImagePullSecrets != nil {
+ in, out := &in.ImagePullSecrets, &out.ImagePullSecrets
+ *out = make([]v1.LocalObjectReference, len(*in))
+ copy(*out, *in)
+ }
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteShuffleServiceSpec.
diff --git a/deploy/kubernetes/operator/config/crd/bases/uniffle.apache.org_remoteshuffleservices.yaml b/deploy/kubernetes/operator/config/crd/bases/uniffle.apache.org_remoteshuffleservices.yaml
index e1df8dbe..f362a5b6 100644
--- a/deploy/kubernetes/operator/config/crd/bases/uniffle.apache.org_remoteshuffleservices.yaml
+++ b/deploy/kubernetes/operator/config/crd/bases/uniffle.apache.org_remoteshuffleservices.yaml
@@ -4189,6 +4189,17 @@ spec:
- image
- xmxSize
type: object
+ imagePullSecrets:
+ items:
+ description: LocalObjectReference contains enough information to
+ let you locate the referenced object inside the same namespace.
+ properties:
+ name:
+ description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
+ TODO: Add other useful fields. apiVersion, kind, uid?'
+ type: string
+ type: object
+ type: array
shuffleServer:
description: ShuffleServer contains configuration of the shuffle servers.
properties:
diff --git a/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator.go b/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator.go
index 1fdb5c55..9f7f5ac4 100644
--- a/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator.go
+++ b/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator.go
@@ -182,6 +182,7 @@ func GenerateDeploy(rss *unifflev1alpha1.RemoteShuffleService, index int) *appsv
Volumes: rss.Spec.Coordinator.Volumes,
NodeSelector: rss.Spec.Coordinator.NodeSelector,
Affinity: rss.Spec.Coordinator.Affinity,
+ ImagePullSecrets: rss.Spec.ImagePullSecrets,
}
configurationVolume := corev1.Volume{
Name: controllerconstants.ConfigurationVolumeName,
diff --git a/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go b/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go
index 52461851..1d3c64d1 100644
--- a/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go
+++ b/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go
@@ -128,6 +128,11 @@ var (
},
},
}
+ testImagePullSecrets = []corev1.LocalObjectReference{
+ {
+ Name: "default-secret",
+ },
+ }
)
func buildRssWithLabels() *uniffleapi.RemoteShuffleService {
@@ -166,6 +171,12 @@ func withCustomAffinity(affinity *corev1.Affinity) *uniffleapi.RemoteShuffleServ
return rss
}
+func withCustomImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) *uniffleapi.RemoteShuffleService {
+ rss := utils.BuildRSSWithDefaultValue()
+ rss.Spec.ImagePullSecrets = imagePullSecrets
+ return rss
+}
+
func buildRssWithCustomRPCPort() *uniffleapi.RemoteShuffleService {
rss := utils.BuildRSSWithDefaultValue()
rss.Spec.Coordinator.RPCPort = pointer.Int32(testRPCPort)
@@ -436,6 +447,20 @@ func TestGenerateDeploy(t *testing.T) {
return false, fmt.Errorf("generated deploy should include affinity: %v", testAffinity)
},
},
+ {
+ name: "set custom imagePullSecrets",
+ rss: withCustomImagePullSecrets(testImagePullSecrets),
+ IsValidDeploy: func(deploy *appsv1.Deployment, rss *uniffleapi.RemoteShuffleService) (bool, error) {
+ if deploy.Spec.Template.Spec.ImagePullSecrets != nil {
+ deploy.Spec.Template.Spec.ImagePullSecrets = rss.Spec.ImagePullSecrets
+ equal := reflect.DeepEqual(deploy.Spec.Template.Spec.ImagePullSecrets, testImagePullSecrets)
+ if equal {
+ return true, nil
+ }
+ }
+ return false, fmt.Errorf("generated deploy should include imagePullSecrets: %v", testImagePullSecrets)
+ },
+ },
} {
t.Run(tt.name, func(tc *testing.T) {
deploy := GenerateDeploy(tt.rss, 0)
diff --git a/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver.go b/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver.go
index ca4abaae..ea025a62 100644
--- a/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver.go
+++ b/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver.go
@@ -89,6 +89,7 @@ func GenerateSts(rss *unifflev1alpha1.RemoteShuffleService) *appsv1.StatefulSet
Volumes: rss.Spec.ShuffleServer.Volumes,
NodeSelector: rss.Spec.ShuffleServer.NodeSelector,
Affinity: rss.Spec.ShuffleServer.Affinity,
+ ImagePullSecrets: rss.Spec.ImagePullSecrets,
}
configurationVolume := corev1.Volume{
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 2a314eb5..da84ad6b 100644
--- a/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go
+++ b/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go
@@ -128,6 +128,11 @@ var (
},
},
}
+ testImagePullSecrets = []corev1.LocalObjectReference{
+ {
+ Name: "default-secret",
+ },
+ }
)
func buildRssWithLabels() *uniffleapi.RemoteShuffleService {
@@ -183,6 +188,12 @@ func withCustomAffinity(affinity *corev1.Affinity) *uniffleapi.RemoteShuffleServ
return rss
}
+func withCustomImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) *uniffleapi.RemoteShuffleService {
+ rss := utils.BuildRSSWithDefaultValue()
+ rss.Spec.ImagePullSecrets = imagePullSecrets
+ return rss
+}
+
func buildCommonExpectedENVs(rss *uniffleapi.RemoteShuffleService) []corev1.EnvVar {
return []corev1.EnvVar{
{
@@ -443,6 +454,20 @@ func TestGenerateSts(t *testing.T) {
return false, fmt.Errorf("generated sts should include affinity: %v", testAffinity)
},
},
+ {
+ name: "set custom imagePullSecrets",
+ rss: withCustomImagePullSecrets(testImagePullSecrets),
+ IsValidSts: func(deploy *appsv1.StatefulSet, rss *uniffleapi.RemoteShuffleService) (bool, error) {
+ if deploy.Spec.Template.Spec.ImagePullSecrets != nil {
+ deploy.Spec.Template.Spec.ImagePullSecrets = rss.Spec.ImagePullSecrets
+ equal := reflect.DeepEqual(deploy.Spec.Template.Spec.ImagePullSecrets, testImagePullSecrets)
+ if equal {
+ return true, nil
+ }
+ }
+ return false, fmt.Errorf("generated sts should include imagePullSecrets: %v", testImagePullSecrets)
+ },
+ },
} {
t.Run(tt.name, func(tc *testing.T) {
sts := GenerateSts(tt.rss)