@@ -62,8 +62,6 @@ const LTPAServerXMLMountSuffix = "-managed-ltpa-mount-server-xml"
6262const LTPAKeysFileName = "ltpa.keys"
6363const LTPAKeysXMLFileName = "managedLTPA.xml"
6464const LTPAKeysMountXMLFileName = "managedLTPAMount.xml"
65- const LTPAKeysCreationScriptFileName = "create_ltpa_keys.sh"
66- const LTPAConfigCreationScriptFileName = "create_ltpa_config.sh"
6765
6866// Mount constants
6967const SecureMountPath = "/output/liberty-operator"
@@ -935,119 +933,6 @@ func IsLTPAJobConfigurationOutdated(job *v1.Job, appLeaderInstance *wlv1.WebSphe
935933 return false
936934}
937935
938- func CustomizeLTPAKeysJob (job * v1.Job , jobRootName string , la * wlv1.WebSphereLibertyApplication , ltpaConfig * LTPAConfig , client client.Client ) {
939- ltpaVolumeMountName := parseMountName (ltpaConfig .FileName )
940- encodingType := "aes" // the password encoding type for securityUtility (one of "xor", "aes", or "hash")
941- job .Spec .Template .ObjectMeta .Name = "liberty"
942- job .Spec .Template .ObjectMeta .Labels = GetRequiredLabels (jobRootName , job .Name )
943- job .Spec .Template .Spec .Containers = []corev1.Container {
944- {
945- Name : job .Spec .Template .ObjectMeta .Name ,
946- Image : la .GetStatus ().GetImageReference (),
947- ImagePullPolicy : * la .GetPullPolicy (),
948- SecurityContext : rcoutils .GetSecurityContext (la ),
949- Command : []string {"/bin/bash" , "-c" },
950- // Usage: /bin/create_ltpa_keys.sh <namespace> <ltpa-secret-name> <securityUtility-encoding>
951- Args : []string {managedLTPAMountPath + "/bin/" + LTPAKeysCreationScriptFileName + " " + la .GetNamespace () + " " + ltpaConfig .SecretName + " " + ltpaConfig .SecretInstanceName + " " + ltpaConfig .FileName + " " + encodingType + " " + ltpaConfig .EncryptionKeySecretName + " " + strconv .FormatBool (ltpaConfig .EncryptionKeySharingEnabled ) + " " + ResourcePathIndexLabel + " " + ltpaConfig .Metadata .PathIndex + " " + ltpaConfig .JobRequestConfigMapName },
952- VolumeMounts : []corev1.VolumeMount {
953- {
954- Name : ltpaVolumeMountName ,
955- MountPath : managedLTPAMountPath + "/bin" ,
956- },
957- },
958- },
959- }
960- if la .GetPullSecret () != nil && * la .GetPullSecret () != "" {
961- job .Spec .Template .Spec .ImagePullSecrets = append (job .Spec .Template .Spec .ImagePullSecrets , corev1.LocalObjectReference {
962- Name : * la .GetPullSecret (),
963- })
964- }
965- job .Spec .Template .Spec .ServiceAccountName = ltpaConfig .ServiceAccountName
966- // If there is a custom ServiceAccount, include it's pull secrets into the LTPA Job
967- if leaderSAName := rcoutils .GetServiceAccountName (la ); len (leaderSAName ) > 0 {
968- customServiceAccount := & corev1.ServiceAccount {}
969- if err := client .Get (context .TODO (), types.NamespacedName {Name : leaderSAName , Namespace : la .GetNamespace ()}, customServiceAccount ); err == nil {
970- // For each of the custom SA's pull secret's, if it is not found within the Job, append it to the Job
971- for _ , customSAObjectReference := range customServiceAccount .ImagePullSecrets {
972- if ! LocalObjectReferenceContainsName (job .Spec .Template .Spec .ImagePullSecrets , customSAObjectReference .Name ) {
973- job .Spec .Template .Spec .ImagePullSecrets = append (job .Spec .Template .Spec .ImagePullSecrets , corev1.LocalObjectReference {
974- Name : customSAObjectReference .Name ,
975- })
976- }
977- }
978- }
979- }
980- job .Spec .Template .Spec .RestartPolicy = corev1 .RestartPolicyOnFailure
981- number := int32 (0777 )
982- job .Spec .Template .Spec .Volumes = append (job .Spec .Template .Spec .Volumes , corev1.Volume {
983- Name : ltpaVolumeMountName ,
984- VolumeSource : corev1.VolumeSource {
985- ConfigMap : & corev1.ConfigMapVolumeSource {
986- LocalObjectReference : corev1.LocalObjectReference {
987- Name : ltpaConfig .ConfigMapName ,
988- },
989- DefaultMode : & number ,
990- },
991- },
992- })
993- }
994-
995- func CustomizeLTPAConfigJob (job * v1.Job , jobRootName string , la * wlv1.WebSphereLibertyApplication , ltpaConfig * LTPAConfig , client client.Client ) {
996- ltpaVolumeMountName := parseMountName (ltpaConfig .FileName )
997- encodingType := "aes" // the password encoding type for securityUtility (one of "xor", "aes", or "hash")
998- job .Spec .Template .ObjectMeta .Name = "liberty"
999- job .Spec .Template .ObjectMeta .Labels = GetRequiredLabels (jobRootName , job .Name )
1000- job .Spec .Template .Spec .Containers = []corev1.Container {
1001- {
1002- Name : job .Spec .Template .ObjectMeta .Name ,
1003- Image : la .GetStatus ().GetImageReference (),
1004- ImagePullPolicy : * la .GetPullPolicy (),
1005- SecurityContext : rcoutils .GetSecurityContext (la ),
1006- Command : []string {"/bin/bash" , "-c" },
1007- Args : []string {managedLTPAMountPath + "/bin/" + LTPAConfigCreationScriptFileName + " " + la .GetNamespace () + " " + ltpaConfig .SecretName + " " + ltpaConfig .SecretInstanceName + " " + ltpaConfig .ConfigSecretName + " " + ltpaConfig .ConfigSecretInstanceName + " " + ltpaConfig .FileName + " " + encodingType + " " + ltpaConfig .EncryptionKeySecretName + " " + strconv .FormatBool (ltpaConfig .EncryptionKeySharingEnabled ) + " " + ResourcePathIndexLabel + " " + ltpaConfig .Metadata .PathIndex + " " + ltpaConfig .JobRequestConfigMapName },
1008- VolumeMounts : []corev1.VolumeMount {
1009- {
1010- Name : ltpaVolumeMountName ,
1011- MountPath : managedLTPAMountPath + "/bin" ,
1012- },
1013- },
1014- },
1015- }
1016- if la .GetPullSecret () != nil && * la .GetPullSecret () != "" {
1017- job .Spec .Template .Spec .ImagePullSecrets = append (job .Spec .Template .Spec .ImagePullSecrets , corev1.LocalObjectReference {
1018- Name : * la .GetPullSecret (),
1019- })
1020- }
1021- job .Spec .Template .Spec .ServiceAccountName = ltpaConfig .ServiceAccountName
1022- // If there is a custom ServiceAccount, include it's pull secrets into the LTPA Job
1023- if leaderSAName := rcoutils .GetServiceAccountName (la ); len (leaderSAName ) > 0 {
1024- customServiceAccount := & corev1.ServiceAccount {}
1025- if err := client .Get (context .TODO (), types.NamespacedName {Name : leaderSAName , Namespace : la .GetNamespace ()}, customServiceAccount ); err == nil {
1026- // For each of the custom SA's pull secret's, if it is not found within the Job, append it to the Job
1027- for _ , customSAObjectReference := range customServiceAccount .ImagePullSecrets {
1028- if ! LocalObjectReferenceContainsName (job .Spec .Template .Spec .ImagePullSecrets , customSAObjectReference .Name ) {
1029- job .Spec .Template .Spec .ImagePullSecrets = append (job .Spec .Template .Spec .ImagePullSecrets , corev1.LocalObjectReference {
1030- Name : customSAObjectReference .Name ,
1031- })
1032- }
1033- }
1034- }
1035- }
1036- job .Spec .Template .Spec .RestartPolicy = corev1 .RestartPolicyOnFailure
1037- number := int32 (0777 )
1038- job .Spec .Template .Spec .Volumes = append (job .Spec .Template .Spec .Volumes , corev1.Volume {
1039- Name : ltpaVolumeMountName ,
1040- VolumeSource : corev1.VolumeSource {
1041- ConfigMap : & corev1.ConfigMapVolumeSource {
1042- LocalObjectReference : corev1.LocalObjectReference {
1043- Name : ltpaConfig .ConfigMapName ,
1044- },
1045- DefaultMode : & number ,
1046- },
1047- },
1048- })
1049- }
1050-
1051936// Converts a file name into a lowercase word separated string
1052937// Example: managedLTPASecret.xml -> managed-ltpa-secret-xml
1053938func parseMountName (fileName string ) string {
0 commit comments