Skip to content

Commit 7ce7ac3

Browse files
committed
Add plan override flag for Equinix Metal
Enables use of a cheaper plan for Equinix Metal users when available in their account. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 35de486 commit 7ce7ac3

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type InfraConfig struct {
2525
AnnotatedOnly bool
2626
ProConfig InletsProConfig
2727
MaxClientMemory string
28+
Plan string
2829
}
2930

3031
type InletsProConfig struct {

controller.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ func (c *Controller) syncHandler(key string) error {
425425
log.Printf("Provisioning started with provider: %s host: %s", c.infraConfig.Provider, tunnel.Name)
426426

427427
start := time.Now()
428-
host := getHostConfig(c, tunnel)
428+
host := getHostConfig(c, tunnel, c.infraConfig.Plan)
429429
res, err := provisioner.Provision(host)
430430
if err != nil {
431431
return err
@@ -516,7 +516,7 @@ func createClientDeployment(tunnel *inletsv1alpha1.Tunnel, c *Controller) error
516516
return nil
517517
}
518518

519-
func getHostConfig(c *Controller, tunnel *inletsv1alpha1.Tunnel) provision.BasicHost {
519+
func getHostConfig(c *Controller, tunnel *inletsv1alpha1.Tunnel, planOverride string) provision.BasicHost {
520520

521521
userData := provision.MakeExitServerUserdata(
522522
tunnel.Spec.AuthToken,
@@ -528,10 +528,16 @@ func getHostConfig(c *Controller, tunnel *inletsv1alpha1.Tunnel) provision.Basic
528528

529529
switch c.infraConfig.Provider {
530530
case "equinix-metal":
531+
532+
plan := "c3.small.x86"
533+
if len(planOverride) > 0 {
534+
plan = planOverride
535+
}
536+
531537
host = provision.BasicHost{
532538
Name: tunnel.Name,
533539
OS: "ubuntu_20_04",
534-
Plan: "c3.small.x86",
540+
Plan: plan,
535541
Region: c.infraConfig.Region,
536542
UserData: userData,
537543
Additional: map[string]string{

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ func main() {
5858
flag.StringVar(&infra.ProConfig.ClientImage, "pro-client-image", "", "Supply a Docker image for the inlets-pro client")
5959
flag.StringVar(&infra.MaxClientMemory, "max-client-memory", "128Mi", "Maximum memory limit for the tunnel clients")
6060

61+
flag.StringVar(&infra.Plan, "plan", "", "Plan code for cloud host")
62+
6163
flag.BoolVar(&infra.AnnotatedOnly, "annotated-only", false, "Only create a tunnel for annotated services. Annotate with dev.inlets.manage=true.")
6264

6365
flag.Parse()

0 commit comments

Comments
 (0)