@@ -34,11 +34,13 @@ import (
3434 argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1"
3535 "github.com/argoproj-labs/argocd-operator/common"
3636 "github.com/argoproj-labs/argocd-operator/controllers/argoutil"
37+
38+ tlsProfile "github.com/argoproj-labs/argocd-operator/pkg/tlsprofile"
3739)
3840
3941// ReconcilePrincipalDeployment reconciles the ArgoCD agent principal deployment.
4042// It creates, updates, or deletes the deployment based on the ArgoCD CR configuration.
41- func ReconcilePrincipalDeployment (client client.Client , compName , saName string , cr * argoproj.ArgoCD , scheme * runtime.Scheme ) error {
43+ func ReconcilePrincipalDeployment (client client.Client , compName , saName string , cr * argoproj.ArgoCD , scheme * runtime.Scheme , centralTLSProfile tlsProfile. TLSConfigProfile ) error {
4244 deployment := buildDeployment (compName , cr )
4345
4446 // Check if deployment already exists
@@ -60,7 +62,7 @@ func ReconcilePrincipalDeployment(client client.Client, compName, saName string,
6062 return nil
6163 }
6264
63- deployment , changed := updateDeploymentIfChanged (compName , saName , cr , deployment )
65+ deployment , changed := updateDeploymentIfChanged (compName , saName , cr , deployment , centralTLSProfile )
6466 if changed {
6567 argoutil .LogResourceUpdate (log , deployment , "principal deployment is being updated" )
6668 if err := client .Update (context .TODO (), deployment ); err != nil {
@@ -80,7 +82,7 @@ func ReconcilePrincipalDeployment(client client.Client, compName, saName string,
8082 }
8183
8284 argoutil .LogResourceCreation (log , deployment )
83- deployment .Spec = buildPrincipalSpec (compName , saName , cr )
85+ deployment .Spec = buildPrincipalSpec (compName , saName , cr , centralTLSProfile )
8486 if err := client .Create (context .TODO (), deployment ); err != nil {
8587 return fmt .Errorf ("failed to create principal deployment %s in namespace %s: %v" , deployment .Name , cr .Namespace , err )
8688 }
@@ -97,8 +99,9 @@ func buildDeployment(compName string, cr *argoproj.ArgoCD) *appsv1.Deployment {
9799 }
98100}
99101
100- func buildPrincipalSpec (compName , saName string , cr * argoproj.ArgoCD ) appsv1.DeploymentSpec {
102+ func buildPrincipalSpec (compName , saName string , cr * argoproj.ArgoCD , centralTLSProfile tlsProfile. TLSConfigProfile ) appsv1.DeploymentSpec {
101103 redisAuthVolume , redisAuthMount := argoutil .MountRedisAuthToArgo (cr )
104+ envParams := buildPrincipalContainerEnv (cr , centralTLSProfile )
102105 return appsv1.DeploymentSpec {
103106 Selector : buildSelector (compName , cr ),
104107 Template : corev1.PodTemplateSpec {
@@ -111,7 +114,7 @@ func buildPrincipalSpec(compName, saName string, cr *argoproj.ArgoCD) appsv1.Dep
111114 Image : buildPrincipalImage (cr ),
112115 ImagePullPolicy : argoutil .GetImagePullPolicy (cr .Spec .ImagePullPolicy ),
113116 Name : generateAgentResourceName (cr .Name , compName ),
114- Env : buildPrincipalContainerEnv ( cr ) ,
117+ Env : envParams ,
115118 Args : buildArgs (compName ),
116119 SecurityContext : buildSecurityContext (),
117120 Ports : buildPorts (compName ),
@@ -250,7 +253,7 @@ func buildVolumes() []corev1.Volume {
250253// updateDeploymentIfChanged compares the current deployment with the desired state
251254// and updates it if any changes are detected. Returns the updated deployment and a boolean
252255// indicating whether any changes were made.
253- func updateDeploymentIfChanged (compName , saName string , cr * argoproj.ArgoCD , deployment * appsv1.Deployment ) (* appsv1.Deployment , bool ) {
256+ func updateDeploymentIfChanged (compName , saName string , cr * argoproj.ArgoCD , deployment * appsv1.Deployment , centralTLSProfile tlsProfile. TLSConfigProfile ) (* appsv1.Deployment , bool ) {
254257 changed := false
255258
256259 if ! reflect .DeepEqual (deployment .Spec .Selector , buildSelector (compName , cr )) {
@@ -276,11 +279,11 @@ func updateDeploymentIfChanged(compName, saName string, cr *argoproj.ArgoCD, dep
276279 changed = true
277280 deployment .Spec .Template .Spec .Containers [0 ].Name = generateAgentResourceName (cr .Name , compName )
278281 }
279-
280- if ! reflect .DeepEqual (deployment .Spec .Template .Spec .Containers [0 ].Env , buildPrincipalContainerEnv ( cr ) ) {
282+ envParams := buildPrincipalContainerEnv ( cr , centralTLSProfile )
283+ if ! reflect .DeepEqual (deployment .Spec .Template .Spec .Containers [0 ].Env , envParams ) {
281284 log .Info ("deployment container env is being updated" )
282285 changed = true
283- deployment .Spec .Template .Spec .Containers [0 ].Env = buildPrincipalContainerEnv ( cr )
286+ deployment .Spec .Template .Spec .Containers [0 ].Env = envParams
284287 }
285288
286289 if ! reflect .DeepEqual (deployment .Spec .Template .Spec .Containers [0 ].Args , buildArgs (compName )) {
@@ -332,7 +335,8 @@ func updateDeploymentIfChanged(compName, saName string, cr *argoproj.ArgoCD, dep
332335 return deployment , changed
333336}
334337
335- func buildPrincipalContainerEnv (cr * argoproj.ArgoCD ) []corev1.EnvVar {
338+ func buildPrincipalContainerEnv (cr * argoproj.ArgoCD , centralTLSProfile tlsProfile.TLSConfigProfile ) []corev1.EnvVar {
339+ arguments := getPrincipalTlsConfig (centralTLSProfile )
336340 env := []corev1.EnvVar {
337341 {
338342 Name : EnvArgoCDPrincipalLogLevel ,
@@ -391,6 +395,12 @@ func buildPrincipalContainerEnv(cr *argoproj.ArgoCD) []corev1.EnvVar {
391395 }, {
392396 Name : EnvArgoCDPrincipalResourceProxyCaSecretName ,
393397 Value : getPrincipalResourceProxyCaSecretName (cr ),
398+ }, {
399+ Name : EnvArgoCDPrincipalTlsMinVersion ,
400+ Value : arguments ["--tlsminversion" ],
401+ }, {
402+ Name : EnvArgoCDPrincipalCipherSuites ,
403+ Value : arguments ["--tlsciphers" ],
394404 }, {
395405 Name : EnvArgoCDPrincipalJwtSecretName ,
396406 Value : getPrincipalJWTSecretName (cr ),
@@ -435,8 +445,42 @@ const (
435445 EnvArgoCDPrincipalJwtSecretName = "ARGOCD_PRINCIPAL_JWT_SECRET_NAME"
436446 EnvArgoCDPrincipalImage = "ARGOCD_PRINCIPAL_IMAGE"
437447 EnvArgoCDPrincipalDestinationBasedMapping = "ARGOCD_PRINCIPAL_DESTINATION_BASED_MAPPING"
448+ EnvArgoCDPrincipalTlsMinVersion = "ARGOCD_PRINCIPAL_TLS_MIN_VERSION"
449+ EnvArgoCDPrincipalCipherSuites = "ARGOCD_PRINCIPAL_TLS_CIPHERSUITES"
438450)
439451
452+ func getPrincipalTlsConfig (centralTLSProfile tlsProfile.TLSConfigProfile ) map [string ]string {
453+ if centralTLSProfile .DisableClusterTLSProfile {
454+ return nil
455+ }
456+ arguments := make (map [string ]string )
457+ if v := argoutil .AgentTLSProtocolVersionString (centralTLSProfile .MinVersion ); v != "" {
458+ arguments ["--tlsminversion" ] = v
459+ }
460+ if ciphers := argoutil .MapCipherSuites (centralTLSProfile .Ciphers ); len (ciphers ) > 0 {
461+ // Go does not allow configuring TLS 1.3 cipher suites.
462+ // Only filter them when TLS versions below 1.3 are used.
463+ if centralTLSProfile .MinVersion != "VersionTLS13" {
464+ tls13Ciphers := map [string ]bool {
465+ "TLS_AES_128_GCM_SHA256" : true ,
466+ "TLS_AES_256_GCM_SHA384" : true ,
467+ "TLS_CHACHA20_POLY1305_SHA256" : true ,
468+ }
469+ filtered := make ([]string , 0 , len (ciphers ))
470+ for _ , cipher := range ciphers {
471+ if ! tls13Ciphers [cipher ] {
472+ filtered = append (filtered , cipher )
473+ }
474+ }
475+ ciphers = filtered
476+ }
477+ if len (ciphers ) > 0 {
478+ arguments ["--tlsciphers" ] = strings .Join (ciphers , "," )
479+ }
480+ }
481+ return arguments
482+ }
483+
440484// Logging Configuration
441485func getPrincipalLogLevel (cr * argoproj.ArgoCD ) string {
442486 if hasPrincipal (cr ) && cr .Spec .ArgoCDAgent .Principal .LogLevel != "" {
0 commit comments