Skip to content

Commit

Permalink
Accept default public IP setting from environment variable (#1389)
Browse files Browse the repository at this point in the history
SUBMARINER_PUBLICIP is now accepted as part of the input environment
variables. This environment variable will override the default.

The order of preferrence for setting the public IP resolvers on a
gateway will remain as follows:

1) Annotation set on the gateway as gateway.submariner.io/public-ip=....
2) Environment variable passed as SUBMARINER_PUBLICIP
3) the default `"api:api.ipify.org,api:api.my-ip.io/ip,api:ip4.seeip.org"`

Related-Issue: #1071
Related-Issue: submariner-io/submariner-operator#1406

Signed-off-by: Miguel Angel Ajo <[email protected]>
  • Loading branch information
mangelajo authored Jun 8, 2021
1 parent dfc495a commit 9254c16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/endpoint/public_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ var IPv4RE = regexp.MustCompile(`(?:\d{1,3}\.){3}\d{1,3}`)
func getPublicIP(submSpec types.SubmarinerSpecification, k8sClient kubernetes.Interface, backendConfig map[string]string) (string, error) {
config, ok := backendConfig[v1.PublicIP]
if !ok {
config = "api:api.ipify.org,api:api.my-ip.io/ip,api:ip4.seeip.org"
if submSpec.PublicIP != "" {
config = submSpec.PublicIP
} else {
config = "api:api.ipify.org,api:api.my-ip.io/ip,api:ip4.seeip.org"
}
}

resolvers := strings.Split(config, ",")
Expand Down
1 change: 1 addition & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type SubmarinerSpecification struct {
CableDriver string
ClusterID string
Namespace string
PublicIP string
Token string
Debug bool
NATEnabled bool
Expand Down

0 comments on commit 9254c16

Please sign in to comment.