@@ -83,6 +83,11 @@ func NewAgentRunCommand() *cobra.Command {
8383 // OpenTelemetry configuration
8484 otlpAddress string
8585 otlpInsecure bool
86+ // Redis TLS configuration
87+ redisTLSEnabled bool
88+ redisTLSCAPath string
89+ redisTLSCASecretName string
90+ redisTLSInsecure bool
8691 )
8792 command := & cobra.Command {
8893 Use : "agent" ,
@@ -175,7 +180,7 @@ func NewAgentRunCommand() *cobra.Command {
175180 remoteOpts = append (remoteOpts , client .WithRootAuthoritiesFromFile (rootCAPath ))
176181 } else {
177182 logrus .Infof ("Loading root CA certificate from secret %s/%s" , namespace , rootCASecretName )
178- remoteOpts = append (remoteOpts , client .WithRootAuthoritiesFromSecret (kubeConfig .Clientset , namespace , rootCASecretName , "" ))
183+ remoteOpts = append (remoteOpts , client .WithRootAuthoritiesFromSecret (kubeConfig .Clientset , namespace , rootCASecretName , "tls.crt " ))
179184 }
180185
181186 // If both a certificate and a key are specified on the command
@@ -229,6 +234,40 @@ func NewAgentRunCommand() *cobra.Command {
229234 agentOpts = append (agentOpts , agent .WithRedisUsername (redisUsername ))
230235 agentOpts = append (agentOpts , agent .WithRedisPassword (redisPassword ))
231236
237+ // Configure Redis TLS
238+ agentOpts = append (agentOpts , agent .WithRedisTLSEnabled (redisTLSEnabled ))
239+ if redisTLSEnabled {
240+ // Validate Redis TLS configuration - only one mode can be specified
241+ // This validation works for both CLI flags and environment variables
242+ modesSet := 0
243+ if redisTLSInsecure {
244+ modesSet ++
245+ }
246+ if redisTLSCAPath != "" {
247+ modesSet ++
248+ }
249+ // For secret name: count it if explicitly set (CLI) or if set to non-default value (env var)
250+ // This allows the default secret name to be used as a fallback when no mode is explicitly specified
251+ if c .Flags ().Changed ("redis-tls-ca-secret-name" ) || (redisTLSCASecretName != "" && redisTLSCASecretName != "argocd-redis-tls" ) {
252+ modesSet ++
253+ }
254+ if modesSet > 1 {
255+ cmdutil .Fatal ("Only one Redis TLS mode can be specified: --redis-tls-insecure, --redis-tls-ca-path, or --redis-tls-ca-secret-name" )
256+ }
257+
258+ // Redis TLS (for connections to agent's argocd-redis)
259+ if redisTLSInsecure {
260+ logrus .Warn ("INSECURE: Not verifying Redis TLS certificate" )
261+ agentOpts = append (agentOpts , agent .WithRedisTLSInsecure (true ))
262+ } else if redisTLSCAPath != "" {
263+ logrus .Infof ("Loading Redis CA certificate from file %s" , redisTLSCAPath )
264+ agentOpts = append (agentOpts , agent .WithRedisTLSCAPath (redisTLSCAPath ))
265+ } else {
266+ logrus .Infof ("Loading Redis CA certificate from secret %s/%s" , namespace , redisTLSCASecretName )
267+ agentOpts = append (agentOpts , agent .WithRedisTLSCAFromSecret (kubeConfig .Clientset , namespace , redisTLSCASecretName , "ca.crt" ))
268+ }
269+ }
270+
232271 agentOpts = append (agentOpts , agent .WithEnableResourceProxy (enableResourceProxy ))
233272 agentOpts = append (agentOpts , agent .WithCacheRefreshInterval (cacheRefreshInterval ))
234273 agentOpts = append (agentOpts , agent .WithHeartbeatInterval (heartbeatInterval ))
@@ -270,6 +309,20 @@ func NewAgentRunCommand() *cobra.Command {
270309 env .StringWithDefault ("REDIS_PASSWORD" , nil , "" ),
271310 "The password to connect to redis with" )
272311
312+ // Redis TLS flags
313+ command .Flags ().BoolVar (& redisTLSEnabled , "redis-tls-enabled" ,
314+ env .BoolWithDefault ("ARGOCD_AGENT_REDIS_TLS_ENABLED" , true ),
315+ "Enable TLS for Redis connections (enabled by default for security)" )
316+ command .Flags ().StringVar (& redisTLSCAPath , "redis-tls-ca-path" ,
317+ env .StringWithDefault ("ARGOCD_AGENT_REDIS_TLS_CA_PATH" , nil , "" ),
318+ "Path to CA certificate for Redis TLS (for local development)" )
319+ command .Flags ().StringVar (& redisTLSCASecretName , "redis-tls-ca-secret-name" ,
320+ env .StringWithDefault ("ARGOCD_AGENT_REDIS_TLS_CA_SECRET_NAME" , nil , "argocd-redis-tls" ),
321+ "Secret name containing CA certificate for Redis TLS (for production deployment)" )
322+ command .Flags ().BoolVar (& redisTLSInsecure , "redis-tls-insecure" ,
323+ env .BoolWithDefault ("ARGOCD_AGENT_REDIS_TLS_INSECURE" , false ),
324+ "INSECURE: Do not verify Redis TLS certificate" )
325+
273326 command .Flags ().StringVar (& logFormat , "log-format" ,
274327 env .StringWithDefault ("ARGOCD_PRINCIPAL_LOG_FORMAT" , nil , "text" ),
275328 "The log format to use (one of: text, json)" )
0 commit comments