Skip to content

Expose tlsconfig as a Public Package for HTTP Probes in Cloudprober #1007

Closed

Description

@kssahazeer

Currently, the tlsconfig package in Cloudprober is located under internal/tlsconfig/proto, which prevents external Go clients from importing it. This limitation makes it difficult to configure TLS settings for HTTP probes programmatically using the Go API.

A common use case is setting ServerName and enabling/disabling certificate validation in HTTP probes via a Go client. However, due to the internal restriction, users must rely on workarounds such as JSON-based protobuf parsing or templating.

To improve usability and enable direct Go-based configuration, we request that tlsconfig be moved to a public package (e.g., github.com/cloudprober/cloudprober/tlsconfig/proto) so it can be accessed externally.

Proposed Solution:
• Move internal/tlsconfig/proto to a public package such as cloudprober/tlsconfig/proto.
• Update Cloudprober’s documentation to reflect this change.

Benefits:
• Enables direct Go-based configuration of HTTP probes with TLS.
• Reduces reliance on JSON workarounds.
• Improves extensibility for Cloudprober users integrating it into Go applications.

Activity

  1. added
    enhancement
    on Feb 14, 2025
  2. manugarg commented on Feb 14, 2025

    @manugarg
    Contributor

    @kssahazeer Can you please explain what exactly you're trying to do?

    This limitation makes it difficult to configure TLS settings for HTTP probes programmatically using the Go API.

    Which Go API?

  3. kssahazeer commented on Feb 14, 2025

    @kssahazeer
    Author

    @manugarg this is how I am trying to add a probe to cloudprober, not sure if this is the best practice, need to write service in golang

    // ======================================HTTPS-PROBE=====================================
    	netflixHttp = "https://100.20.171.230"
    	nUrlHttp = "https://100.20.171.230"
    	targetsDef = target.TargetsDef{
    		Endpoint: []*proto2.Endpoint{
    			{
    				Name: &netflixHttp,
    				Url:  &nUrlHttp,
    			},
    		},
    	}
    
    	name = "https_ping_ifa2"
    	probeType = proto.ProbeDef_HTTP
    	intervalMsec = int32(10000)
    	port = int32(443)
    
    	// serverName := "dummyServerName"
    	// tlsConfig := tlsConfig.TLSConfig{     =======> this is not possible with existing cloudeprober structure
    	// 	ServerName: &serverName,
    	// }
    	disableCertValidation := true
    	httpProbeConfig = httpconfig.ProbeConf{
    		Port: &port,
    		LatencyBreakdown: []httpconfig.ProbeConf_LatencyBreakdown{
    			httpconfig.ProbeConf_ALL_STAGES,
    		},
    		// TlsConfig:             &tlsConfig,
    		DisableCertValidation: &disableCertValidation,
    	}
    
    	val = pb.AddProbeRequest{
    		ProbeConfig: &proto.ProbeDef{
    			Name:         &name,
    			Type:         &probeType,
    			Targets:      &targetsDef,
    			IntervalMsec: &intervalMsec,
    			TimeoutMsec:  &intervalMsec,
    			Probe:        &proto.ProbeDef_HttpProbe{HttpProbe: &httpProbeConfig},
    		},
    	}
    	cloudprober.GetProber().AddProbe(ctx, &val)
    
    	log.Println("Prometheus metrics available at http://localhost:9313/metrics")
    	select {}
    }
    
  4. self-assigned this
    on Mar 12, 2025
  5. added this to the v0.14.0 milestone on Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions