@@ -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,33 @@ 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+ // Redis upstream TLS (for connections to principal's argocd-redis)
273+ if redisUpstreamTLSInsecure {
274+ logrus .Warn ("INSECURE: Not verifying upstream Redis TLS certificate" )
275+ opts = append (opts , principal .WithRedisUpstreamTLSInsecure (true ))
276+ } else if redisUpstreamTLSCAPath != "" {
277+ logrus .Infof ("Loading Redis upstream CA certificate from file %s" , redisUpstreamTLSCAPath )
278+ opts = append (opts , principal .WithRedisUpstreamTLSCAFromFile (redisUpstreamTLSCAPath ))
279+ } else {
280+ logrus .Infof ("Loading Redis upstream CA certificate from secret %s/%s" , namespace , redisUpstreamTLSCASecretName )
281+ opts = append (opts , principal .WithRedisUpstreamTLSCAFromSecret (kubeConfig .Clientset , namespace , redisUpstreamTLSCASecretName , "tls.crt" ))
282+ }
283+ }
284+
249285 s , err := principal .NewServer (ctx , kubeConfig , namespace , opts ... )
250286 if err != nil {
251287 cmdutil .Fatal ("Could not create new server instance: %v" , err )
@@ -375,6 +411,29 @@ func NewPrincipalRunCommand() *cobra.Command {
375411 env .NumWithDefault ("ARGOCD_PRINCIPAL_HEALTH_CHECK_PORT" , cmdutil .ValidPort , 8003 ),
376412 "Port the health check server will listen on" )
377413
414+ // Redis TLS flags
415+ command .Flags ().BoolVar (& redisTLSEnabled , "redis-tls-enabled" ,
416+ env .BoolWithDefault ("ARGOCD_PRINCIPAL_REDIS_TLS_ENABLED" , false ),
417+ "Enable TLS for Redis connections" )
418+ command .Flags ().StringVar (& redisServerTLSCertPath , "redis-server-tls-cert" ,
419+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_SERVER_TLS_CERT_PATH" , nil , "" ),
420+ "Path to TLS certificate for Redis proxy server" )
421+ command .Flags ().StringVar (& redisServerTLSKeyPath , "redis-server-tls-key" ,
422+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_SERVER_TLS_KEY_PATH" , nil , "" ),
423+ "Path to TLS private key for Redis proxy server" )
424+ command .Flags ().StringVar (& redisServerTLSSecretName , "redis-server-tls-secret-name" ,
425+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_SERVER_TLS_SECRET_NAME" , nil , "argocd-redis-tls" ),
426+ "Secret name containing TLS certificate and key for Redis proxy server" )
427+ command .Flags ().StringVar (& redisUpstreamTLSCAPath , "redis-upstream-ca-path" ,
428+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_UPSTREAM_CA_PATH" , nil , "" ),
429+ "Path to CA certificate for verifying upstream Redis TLS certificate" )
430+ command .Flags ().StringVar (& redisUpstreamTLSCASecretName , "redis-upstream-ca-secret-name" ,
431+ env .StringWithDefault ("ARGOCD_PRINCIPAL_REDIS_UPSTREAM_CA_SECRET_NAME" , nil , "argocd-redis-tls" ),
432+ "Secret name containing CA certificate for verifying upstream Redis TLS certificate" )
433+ command .Flags ().BoolVar (& redisUpstreamTLSInsecure , "redis-upstream-tls-insecure" ,
434+ env .BoolWithDefault ("ARGOCD_PRINCIPAL_REDIS_UPSTREAM_TLS_INSECURE" , false ),
435+ "INSECURE: Do not verify upstream Redis TLS certificate" )
436+
378437 command .Flags ().StringVar (& kubeConfig , "kubeconfig" , "" , "Path to a kubeconfig file to use" )
379438 command .Flags ().StringVar (& kubeContext , "kubecontext" , "" , "Override the default kube context" )
380439
0 commit comments