in pkg/webhook/webhook.go [426:463]
func addProjectedServiceAccountTokenVolume(pod *corev1.Pod, serviceAccountTokenExpiration int64, audience string) {
// add the projected service account token volume to the pod if not exists
for _, volume := range pod.Spec.Volumes {
if volume.Projected == nil {
continue
}
for _, pvs := range volume.Projected.Sources {
if pvs.ServiceAccountToken == nil {
continue
}
if pvs.ServiceAccountToken.Path == TokenFilePathName {
return
}
}
}
// add the projected service account token volume
// the path for this volume will always be set to "azure-identity-token"
pod.Spec.Volumes = append(
pod.Spec.Volumes,
corev1.Volume{
Name: TokenFilePathName,
VolumeSource: corev1.VolumeSource{
Projected: &corev1.ProjectedVolumeSource{
Sources: []corev1.VolumeProjection{
{
ServiceAccountToken: &corev1.ServiceAccountTokenProjection{
Path: TokenFilePathName,
ExpirationSeconds: &serviceAccountTokenExpiration,
Audience: audience,
},
},
},
},
},
},
)
}