@@ -80,6 +80,11 @@ func NewAgentRunCommand() *cobra.Command {
8080 // OpenTelemetry configuration
8181 otlpAddress string
8282 otlpInsecure bool
83+ // Redis TLS configuration
84+ redisTLSEnabled bool
85+ redisTLSCAPath string
86+ redisTLSCASecretName string
87+ redisTLSInsecure bool
8388 )
8489 command := & cobra.Command {
8590 Use : "agent" ,
@@ -207,6 +212,40 @@ func NewAgentRunCommand() *cobra.Command {
207212 agentOpts = append (agentOpts , agent .WithRedisUsername (redisUsername ))
208213 agentOpts = append (agentOpts , agent .WithRedisPassword (redisPassword ))
209214
215+ // Configure Redis TLS
216+ agentOpts = append (agentOpts , agent .WithRedisTLSEnabled (redisTLSEnabled ))
217+ if redisTLSEnabled {
218+ // Validate Redis TLS configuration - only one mode can be specified
219+ // This validation works for both CLI flags and environment variables
220+ modesSet := 0
221+ if redisTLSInsecure {
222+ modesSet ++
223+ }
224+ if redisTLSCAPath != "" {
225+ modesSet ++
226+ }
227+ // For secret name: count it if explicitly set (CLI) or if set to non-default value (env var)
228+ // This allows the default secret name to be used as a fallback when no mode is explicitly specified
229+ if c .Flags ().Changed ("redis-tls-ca-secret-name" ) || (redisTLSCASecretName != "" && redisTLSCASecretName != "argocd-redis-tls" ) {
230+ modesSet ++
231+ }
232+ if modesSet > 1 {
233+ cmdutil .Fatal ("Only one Redis TLS mode can be specified: --redis-tls-insecure, --redis-tls-ca-path, or --redis-tls-ca-secret-name" )
234+ }
235+
236+ // Redis TLS (for connections to agent's argocd-redis)
237+ if redisTLSInsecure {
238+ logrus .Warn ("INSECURE: Not verifying Redis TLS certificate" )
239+ agentOpts = append (agentOpts , agent .WithRedisTLSInsecure (true ))
240+ } else if redisTLSCAPath != "" {
241+ logrus .Infof ("Loading Redis CA certificate from file %s" , redisTLSCAPath )
242+ agentOpts = append (agentOpts , agent .WithRedisTLSCAPath (redisTLSCAPath ))
243+ } else {
244+ logrus .Infof ("Loading Redis CA certificate from secret %s/%s" , namespace , redisTLSCASecretName )
245+ agentOpts = append (agentOpts , agent .WithRedisTLSCAFromSecret (kubeConfig .Clientset , namespace , redisTLSCASecretName , "ca.crt" ))
246+ }
247+ }
248+
210249 agentOpts = append (agentOpts , agent .WithEnableResourceProxy (enableResourceProxy ))
211250 agentOpts = append (agentOpts , agent .WithCacheRefreshInterval (cacheRefreshInterval ))
212251 agentOpts = append (agentOpts , agent .WithHeartbeatInterval (heartbeatInterval ))
@@ -248,6 +287,20 @@ func NewAgentRunCommand() *cobra.Command {
248287 env .StringWithDefault ("REDIS_PASSWORD" , nil , "" ),
249288 "The password to connect to redis with" )
250289
290+ // Redis TLS flags
291+ command .Flags ().BoolVar (& redisTLSEnabled , "redis-tls-enabled" ,
292+ env .BoolWithDefault ("ARGOCD_AGENT_REDIS_TLS_ENABLED" , true ),
293+ "Enable TLS for Redis connections (enabled by default for security)" )
294+ command .Flags ().StringVar (& redisTLSCAPath , "redis-tls-ca-path" ,
295+ env .StringWithDefault ("ARGOCD_AGENT_REDIS_TLS_CA_PATH" , nil , "" ),
296+ "Path to CA certificate for Redis TLS (for local development)" )
297+ command .Flags ().StringVar (& redisTLSCASecretName , "redis-tls-ca-secret-name" ,
298+ env .StringWithDefault ("ARGOCD_AGENT_REDIS_TLS_CA_SECRET_NAME" , nil , "argocd-redis-tls" ),
299+ "Secret name containing CA certificate for Redis TLS (for production deployment)" )
300+ command .Flags ().BoolVar (& redisTLSInsecure , "redis-tls-insecure" ,
301+ env .BoolWithDefault ("ARGOCD_AGENT_REDIS_TLS_INSECURE" , false ),
302+ "INSECURE: Do not verify Redis TLS certificate" )
303+
251304 command .Flags ().StringVar (& logFormat , "log-format" ,
252305 env .StringWithDefault ("ARGOCD_PRINCIPAL_LOG_FORMAT" , nil , "text" ),
253306 "The log format to use (one of: text, json)" )
0 commit comments