@@ -86,6 +86,15 @@ func NewPrincipalRunCommand() *cobra.Command {
8686 redisPassword string
8787 redisCompressionType string
8888 healthzPort int
89+
90+ // Redis TLS configuration
91+ redisTLSEnabled bool
92+ redisServerTLSCertPath string
93+ redisServerTLSKeyPath string
94+ redisServerTLSSecretName string
95+ redisUpstreamTLSCAPath string
96+ redisUpstreamTLSCASecretName string
97+ redisUpstreamTLSInsecure bool
8998 )
9099 var command = & cobra.Command {
91100 Use : "principal" ,
@@ -246,6 +255,38 @@ func NewPrincipalRunCommand() *cobra.Command {
246255 opts = append (opts , principal .WithRedis (redisAddress , redisPassword , redisCompressionType ))
247256 opts = append (opts , principal .WithHealthzPort (healthzPort ))
248257
258+ // Configure Redis TLS
259+ opts = append (opts , principal .WithRedisTLSEnabled (redisTLSEnabled ))
260+ if redisTLSEnabled {
261+ // Redis proxy server TLS (for incoming connections from Argo CD)
262+ if redisServerTLSCertPath != "" && redisServerTLSKeyPath != "" {
263+ logrus .Infof ("Loading Redis proxy server TLS configuration from files cert=%s and key=%s" , redisServerTLSCertPath , redisServerTLSKeyPath )
264+ opts = append (opts , principal .WithRedisServerTLSFromPath (redisServerTLSCertPath , redisServerTLSKeyPath ))
265+ } else if (redisServerTLSCertPath != "" && redisServerTLSKeyPath == "" ) || (redisServerTLSCertPath == "" && redisServerTLSKeyPath != "" ) {
266+ cmdutil .Fatal ("Both --redis-server-tls-cert and --redis-server-tls-key have to be given" )
267+ } else {
268+ logrus .Infof ("Loading Redis proxy server TLS certificate from secret %s/%s" , namespace , redisServerTLSSecretName )
269+ opts = append (opts , principal .WithRedisServerTLSFromSecret (kubeConfig .Clientset , namespace , redisServerTLSSecretName ))
270+ }
271+
272+ // Validate upstream TLS configuration - insecure and CA path are mutually exclusive
273+ if redisUpstreamTLSInsecure && redisUpstreamTLSCAPath != "" {
274+ cmdutil .Fatal ("Cannot specify both --redis-upstream-tls-insecure and --redis-upstream-ca-path" )
275+ }
276+
277+ // Redis upstream TLS (for connections to principal's argocd-redis)
278+ if redisUpstreamTLSInsecure {
279+ logrus .Warn ("INSECURE: Not verifying upstream Redis TLS certificate" )
280+ opts = append (opts , principal .WithRedisUpstreamTLSInsecure (true ))
281+ } else if redisUpstreamTLSCAPath != "" {
282+ logrus .Infof ("Loading Redis upstream CA certificate from file %s" , redisUpstreamTLSCAPath )
283+ opts = append (opts , principal .WithRedisUpstreamTLSCAFromFile (redisUpstreamTLSCAPath ))
284+ } else {
285+ logrus .Infof ("Loading Redis upstream CA certificate from secret %s/%s" , namespace , redisUpstreamTLSCASecretName )
286+ opts = append (opts , principal .WithRedisUpstreamTLSCAFromSecret (kubeConfig .Clientset , namespace , redisUpstreamTLSCASecretName , "tls.crt" ))
287+ }
288+ }
289+
249290 s , err := principal .NewServer (ctx , kubeConfig , namespace , opts ... )
250291 if err != nil {
251292 cmdutil .Fatal ("Could not create new server instance: %v" , err )
@@ -375,6 +416,29 @@ func NewPrincipalRunCommand() *cobra.Command {
375416 env .NumWithDefault ("ARGOCD_PRINCIPAL_HEALTH_CHECK_PORT" , cmdutil .ValidPort , 8003 ),
376417 "Port the health check server will listen on" )
377418
419+ // Redis TLS flags
420+ command .Flags ().BoolVar (& redisTLSEnabled , "redis-tls-enabled" ,
421+ env .BoolWithDefault ("ARGOCD_PRINCIPAL_REDIS_TLS_ENABLED" , false ),
422+ "Enable TLS for Redis connections" )
423+ command .Flags ().StringVar (& redisServerTLSCertPath , "redis-server-tls-cert" ,
424+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_SERVER_TLS_CERT_PATH" , nil , "" ),
425+ "Path to TLS certificate for Redis proxy server" )
426+ command .Flags ().StringVar (& redisServerTLSKeyPath , "redis-server-tls-key" ,
427+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_SERVER_TLS_KEY_PATH" , nil , "" ),
428+ "Path to TLS private key for Redis proxy server" )
429+ command .Flags ().StringVar (& redisServerTLSSecretName , "redis-server-tls-secret-name" ,
430+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_SERVER_TLS_SECRET_NAME" , nil , "argocd-redis-tls" ),
431+ "Secret name containing TLS certificate and key for Redis proxy server" )
432+ command .Flags ().StringVar (& redisUpstreamTLSCAPath , "redis-upstream-ca-path" ,
433+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_UPSTREAM_CA_PATH" , nil , "" ),
434+ "Path to CA certificate for verifying upstream Redis TLS certificate" )
435+ command .Flags ().StringVar (& redisUpstreamTLSCASecretName , "redis-upstream-ca-secret-name" ,
436+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_UPSTREAM_CA_SECRET_NAME" , nil , "argocd-redis-tls" ),
437+ "Secret name containing CA certificate for verifying upstream Redis TLS certificate" )
438+ command .Flags ().BoolVar (& redisUpstreamTLSInsecure , "redis-upstream-tls-insecure" ,
439+ env .BoolWithDefault ("ARGOCD_PRINCIPAL_REDIS_UPSTREAM_TLS_INSECURE" , false ),
440+ "INSECURE: Do not verify upstream Redis TLS certificate" )
441+
378442 command .Flags ().StringVar (& kubeConfig , "kubeconfig" , "" , "Path to a kubeconfig file to use" )
379443 command .Flags ().StringVar (& kubeContext , "kubecontext" , "" , "Override the default kube context" )
380444
0 commit comments