Skip to content

Commit 70c8d8d

Browse files
author
smiletan
authored
Merge pull request #396 from intelligentfu8/kerberos-ddc
[Feature] support kerberos on ddc
2 parents 75c21f4 + 344881f commit 70c8d8d

File tree

5 files changed

+104
-8
lines changed

5 files changed

+104
-8
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: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,23 +562,37 @@ func buildKerberosEnv(info *v1.KerberosInfo, config map[string]interface{}, comp
562562
return nil
563563
}
564564

565+
return buildKerberosEnvUseSecretMountPath(info.KeytabPath, config, string(componentType))
566+
}
567+
568+
func BuildKerberosEnvForDDC(info *dv1.KerberosInfo, config map[string]interface{}, componentType dv1.DisaggregatedComponentType)[]corev1.EnvVar {
569+
if info == nil {
570+
return nil
571+
}
572+
573+
return buildKerberosEnvUseSecretMountPath(info.KeytabPath, config, string(componentType))
574+
}
575+
576+
func buildKerberosEnvUseSecretMountPath(keytabPath string, config map[string]interface{}, componentType string) []corev1.EnvVar {
565577
var krb5ConfPath string
566578
switch componentType {
567-
case v1.Component_FE:
579+
case string(v1.Component_FE), string(dv1.DisaggregatedFE):
568580
krb5ConfPath = kerberos.GetKrb5ConfFromJavaOpts(config)
569-
case v1.Component_BE, v1.Component_CN:
581+
case string(v1.Component_BE), string(v1.Component_CN), string(dv1.DisaggregatedBE):
570582
// be config krb5.conf file must set 'kerberos_krb5_conf_path' in be.conf
571583
// https://doris.apache.org/docs/3.0/lakehouse/datalake-analytics/hive?_highlight=kerberos_krb5_conf_path#connect-to-kerberos-enabled-hive
572584
if value, exists := config["kerberos_krb5_conf_path"]; exists {
573585
krb5ConfPath = value.(string)
574586
} else {
575587
krb5ConfPath = kerberos.KRB5_DEFAULT_CONFIG
576588
}
589+
default:
590+
klog.Errorf("BuildKerberosEnvUseSecretMountPath, componentType %s not supported.", componentType)
577591
}
578592

579593
keytabFinalUsedPath := keytab_default_mount_path
580-
if info.KeytabPath != "" {
581-
keytabFinalUsedPath = info.KeytabPath
594+
if keytabPath != "" {
595+
keytabFinalUsedPath = keytabPath
582596
}
583597

584598
return []corev1.EnvVar{
@@ -900,6 +914,24 @@ func GetMultiSecretVolumeAndVolumeMountWithCommonSpec(cSpec *dv1.CommonSpec) ([]
900914
}
901915

902916
func getKerberosVolumeAndVolumeMount(kerberosInfo *v1.KerberosInfo) ([]corev1.Volume, []corev1.VolumeMount) {
917+
if kerberosInfo == nil {
918+
return []corev1.Volume{}, []corev1.VolumeMount{}
919+
}
920+
921+
return getKerberosConfigAndSecretVolumeAndVolumeMount(kerberosInfo.Krb5ConfigMap, kerberosInfo.KeytabSecretName)
922+
}
923+
924+
//get the kerberos volume and mounts to ddc.
925+
func GetDv1KerberosVolumeAndVolumeMount(kerberosInfo *dv1.KerberosInfo)([]corev1.Volume, []corev1.VolumeMount) {
926+
if kerberosInfo == nil {
927+
return []corev1.Volume{}, []corev1.VolumeMount{}
928+
}
929+
930+
return getKerberosConfigAndSecretVolumeAndVolumeMount(kerberosInfo.Krb5ConfigMap, kerberosInfo.KeytabSecretName)
931+
}
932+
933+
//abstract a base function for dcr and ddc used.
934+
func getKerberosConfigAndSecretVolumeAndVolumeMount(configMapName, secretName string) ([]corev1.Volume, []corev1.VolumeMount) {
903935
var volumes []corev1.Volume
904936
var volumeMounts []corev1.VolumeMount
905937

@@ -909,7 +941,7 @@ func getKerberosVolumeAndVolumeMount(kerberosInfo *v1.KerberosInfo) ([]corev1.Vo
909941
VolumeSource: corev1.VolumeSource{
910942
ConfigMap: &corev1.ConfigMapVolumeSource{
911943
LocalObjectReference: corev1.LocalObjectReference{
912-
Name: kerberosInfo.Krb5ConfigMap,
944+
Name: configMapName,
913945
},
914946
},
915947
},
@@ -925,7 +957,7 @@ func getKerberosVolumeAndVolumeMount(kerberosInfo *v1.KerberosInfo) ([]corev1.Vo
925957
Name: keytab_volume_name,
926958
VolumeSource: corev1.VolumeSource{
927959
Secret: &corev1.SecretVolumeSource{
928-
SecretName: kerberosInfo.KeytabSecretName,
960+
SecretName: secretName,
929961
},
930962
},
931963
})

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, cvs, &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,confMap, &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: 41 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,46 @@ 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, configMap map[string]interface{}, spec *v1.DorisDisaggregatedClusterSpec, pts *corev1.PodTemplateSpec){
299+
var c *corev1.Container
300+
switch componentType {
301+
case v1.DisaggregatedFE:
302+
for i, _ := range pts.Spec.Containers {
303+
if pts.Spec.Containers[i].Name == FEMainContainerName {
304+
c = &pts.Spec.Containers[i]
305+
break
306+
}
307+
}
308+
case v1.DisaggregatedBE:
309+
for i, _ := range pts.Spec.Containers {
310+
if pts.Spec.Containers[i].Name == BEMainContainerName {
311+
c = &pts.Spec.Containers[i]
312+
break
313+
}
314+
}
295315

316+
default:
317+
klog.Errorf("DisaggregatedSubDefaultController AddClusterSpecForPodTemplate componentType %s not supported.", componentType)
318+
return
319+
}
320+
321+
//add pod envs
322+
envs := resource.BuildKerberosEnvForDDC(spec.KerberosInfo, configMap, componentType)
323+
if len(envs) != 0 {
324+
c.Env = append(c.Env, envs...)
325+
}
326+
327+
//add kerberos volumeMounts and volumes
328+
volumes, volumeMounts := resource.GetDv1KerberosVolumeAndVolumeMount(spec.KerberosInfo)
329+
if len(volumeMounts) != 0 {
330+
c.VolumeMounts = append(c.VolumeMounts, volumeMounts...)
331+
}
332+
if len(volumes) != 0 {
333+
pts.Spec.Volumes = append(pts.Spec.Volumes, volumes...)
334+
}
335+
336+
}
296337

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

0 commit comments

Comments
 (0)