Skip to content

Commit 2925398

Browse files
author
smiletan
committed
support kerberos on ddc
1 parent 75c21f4 commit 2925398

File tree

5 files changed

+81
-4
lines changed

5 files changed

+81
-4
lines changed

api/disaggregated/v1/types.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ type DorisDisaggregatedClusterSpec struct {
4848
// if true, will decommission be node when scale down compute group.
4949
// if false, will drop be node when scale down compute group.
5050
EnableDecommission bool `json:"enableDecommission,omitempty"`
51+
52+
// KerberosInfo contains a series of access key files, Provides access to kerberos.
53+
KerberosInfo *KerberosInfo `json:"kerberosInfo,omitempty"`
54+
}
55+
56+
type KerberosInfo struct {
57+
// Krb5ConfigMap is the name of configmap within 'krb5.conf'
58+
Krb5ConfigMap string `json:"krb5ConfigMap,omitempty"`
59+
60+
// SecretName is the name of sercet within '*.keytab' files,
61+
// refer to the following command to create a Secret :
62+
// 'kubectl create secret generic {secret-name} --from-file=. '
63+
KeytabSecretName string `json:"keytabSecretName,omitempty"`
64+
65+
// KeytabPath is the path where the Secret is finally stored inside the pod. default '/etc/keytab/'.
66+
// It is not recommended to modify it unless necessary.
67+
// This path is the path filled in when configuring "hadoop.kerberos.keytab".
68+
KeytabPath string `json:"keytabPath,omitempty"`
5169
}
5270

5371
// AdminUser describe administrator for manage components in specified cluster.

pkg/common/utils/resource/pod.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,24 @@ func GetMultiSecretVolumeAndVolumeMountWithCommonSpec(cSpec *dv1.CommonSpec) ([]
900900
}
901901

902902
func getKerberosVolumeAndVolumeMount(kerberosInfo *v1.KerberosInfo) ([]corev1.Volume, []corev1.VolumeMount) {
903+
if kerberosInfo == nil {
904+
return []corev1.Volume{}, []corev1.VolumeMount{}
905+
}
906+
907+
return getKerberosConfigAndSecretVolumeAndVolumeMount(kerberosInfo.Krb5ConfigMap, kerberosInfo.KeytabSecretName)
908+
}
909+
910+
//get the kerberos volume and mounts to ddc.
911+
func GetDv1KerberosVolumeAndVolumeMount(kerberosInfo *dv1.KerberosInfo)([]corev1.Volume, []corev1.VolumeMount) {
912+
if kerberosInfo == nil {
913+
return []corev1.Volume{}, []corev1.VolumeMount{}
914+
}
915+
916+
return getKerberosConfigAndSecretVolumeAndVolumeMount(kerberosInfo.Krb5ConfigMap, kerberosInfo.KeytabSecretName)
917+
}
918+
919+
//abstract a base function for dcr and ddc used.
920+
func getKerberosConfigAndSecretVolumeAndVolumeMount(configMapName, secretName string) ([]corev1.Volume, []corev1.VolumeMount) {
903921
var volumes []corev1.Volume
904922
var volumeMounts []corev1.VolumeMount
905923

@@ -909,7 +927,7 @@ func getKerberosVolumeAndVolumeMount(kerberosInfo *v1.KerberosInfo) ([]corev1.Vo
909927
VolumeSource: corev1.VolumeSource{
910928
ConfigMap: &corev1.ConfigMapVolumeSource{
911929
LocalObjectReference: corev1.LocalObjectReference{
912-
Name: kerberosInfo.Krb5ConfigMap,
930+
Name: configMapName,
913931
},
914932
},
915933
},
@@ -925,7 +943,7 @@ func getKerberosVolumeAndVolumeMount(kerberosInfo *v1.KerberosInfo) ([]corev1.Vo
925943
Name: keytab_volume_name,
926944
VolumeSource: corev1.VolumeSource{
927945
Secret: &corev1.SecretVolumeSource{
928-
SecretName: kerberosInfo.KeytabSecretName,
946+
SecretName: secretName,
929947
},
930948
},
931949
})

pkg/controller/sub_controller/disaggregated_cluster/computegroups/statefulset.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ func (dcgs *DisaggregatedComputeGroupsController) NewPodTemplateSpec(ddc *dv1.Do
115115
pts.Spec.Volumes = append(pts.Spec.Volumes, secretVolumes...)
116116
}
117117

118+
//add last supplementary spec. if add new config in ddc spec and the config need add in pod, use the follow function to add.
119+
dcgs.DisaggregatedSubDefaultController.AddClusterSpecForPodTemplate(dv1.DisaggregatedBE, &ddc.Spec, &pts)
118120
cgUniqueId := selector[dv1.DorisDisaggregatedComputeGroupUniqueId]
119121
pts.Spec.Affinity = dcgs.ConstructDefaultAffinity(dv1.DorisDisaggregatedComputeGroupUniqueId, cgUniqueId, pts.Spec.Affinity)
120122

@@ -135,7 +137,7 @@ func (dcgs *DisaggregatedComputeGroupsController) NewCGContainer(ddc *dv1.DorisD
135137
cmd, args := sub.GetDisaggregatedCommand(dv1.DisaggregatedBE)
136138
c.Command = cmd
137139
c.Args = args
138-
c.Name = "compute"
140+
c.Name = sub.BEMainContainerName
139141

140142
c.Ports = resource.GetDisaggregatedContainerPorts(cvs, dv1.DisaggregatedBE)
141143
c.Env = cg.CommonSpec.EnvVars

pkg/controller/sub_controller/disaggregated_cluster/disaggregated_fe/statefulset.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
//DefaultStorageSize int64 = 107374182400
3939
basic_auth_path = "/etc/basic_auth"
4040
auth_volume_name = "basic-auth"
41+
4142
)
4243

4344
func (dfc *DisaggregatedFEController) newFEPodsSelector(ddcName string) map[string]string {
@@ -59,6 +60,8 @@ func (dfc *DisaggregatedFEController) NewStatefulset(ddc *v1.DorisDisaggregatedC
5960
spec := ddc.Spec.FeSpec
6061
_, _, vcts := dfc.BuildVolumesVolumeMountsAndPVCs(confMap, v1.DisaggregatedFE, &spec.CommonSpec)
6162
pts := dfc.NewPodTemplateSpec(ddc, confMap)
63+
//add last supplementary spec. if add new config in ddc spec and the config need add in pod, use the follow function to add.
64+
dfc.DisaggregatedSubDefaultController.AddClusterSpecForPodTemplate(v1.DisaggregatedFE, &ddc.Spec, &pts)
6265
st := dfc.NewDefaultStatefulset(ddc)
6366
//metadata
6467
func() {
@@ -124,7 +127,7 @@ func (dfc *DisaggregatedFEController) NewFEContainer(ddc *v1.DorisDisaggregatedC
124127
cmd, args := sub.GetDisaggregatedCommand(v1.DisaggregatedFE)
125128
c.Command = cmd
126129
c.Args = args
127-
c.Name = "fe"
130+
c.Name = sub.FEMainContainerName
128131

129132
c.Ports = resource.GetDisaggregatedContainerPorts(cvs, v1.DisaggregatedFE)
130133
c.Env = ddc.Spec.FeSpec.CommonSpec.EnvVars

pkg/controller/sub_controller/disaggregated_subcontroller.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ const (
5757
FileCachePathKey = "file_cache_path"
5858
FileCacheSubConfigPathKey = "path"
5959
FileCacheSubConfigTotalSizeKey = "total_size"
60+
FEMainContainerName = "fe"
61+
BEMainContainerName = "compute"
6062
)
6163

6264
type DisaggregatedSubController interface {
@@ -292,7 +294,41 @@ func (d *DisaggregatedSubDefaultController) GetManagementAdminUserAndPWD(ctx con
292294

293295
}
294296

297+
// add cluster specification on container spec. this is useful to add common spec on different type pods, example: kerberos volume for fe and be.
298+
func(d *DisaggregatedSubDefaultController) AddClusterSpecForPodTemplate(componentType v1.DisaggregatedComponentType, spec *v1.DorisDisaggregatedClusterSpec, pts *corev1.PodTemplateSpec){
299+
//TODO: realize the kerberos volumeMounts added.
300+
var c *corev1.Container
301+
switch componentType {
302+
case v1.DisaggregatedFE:
303+
for i, _ := range pts.Spec.Containers {
304+
if pts.Spec.Containers[i].Name == FEMainContainerName {
305+
c = &pts.Spec.Containers[i]
306+
break
307+
}
308+
}
309+
case v1.DisaggregatedBE:
310+
for i, _ := range pts.Spec.Containers {
311+
if pts.Spec.Containers[i].Name == BEMainContainerName {
312+
c = &pts.Spec.Containers[i]
313+
break
314+
}
315+
}
316+
317+
default:
318+
klog.Errorf("DisaggregatedSubDefaultController AddClusterSpecForPodTemplate componentType %s not supported.", componentType)
319+
return
320+
}
295321

322+
//add kerberos volumeMounts and volumes
323+
volumes, volumeMounts := resource.GetDv1KerberosVolumeAndVolumeMount(spec.KerberosInfo)
324+
if len(volumeMounts) != 0 {
325+
c.VolumeMounts = append(c.VolumeMounts, volumeMounts...)
326+
}
327+
if len(volumes) != 0 {
328+
pts.Spec.Volumes = append(pts.Spec.Volumes, volumes...)
329+
}
330+
331+
}
296332

297333
func (d *DisaggregatedSubDefaultController) BuildVolumesVolumeMountsAndPVCs(confMap map[string]interface{}, componentType v1.DisaggregatedComponentType, commonSpec *v1.CommonSpec) ([]corev1.Volume, []corev1.VolumeMount, []corev1.PersistentVolumeClaim) {
298334
if commonSpec.PersistentVolume == nil && len(commonSpec.PersistentVolumes) == 0 {

0 commit comments

Comments
 (0)