Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(kubernetes) Ability to specify callback ip or fqdn & port of HTTP server used by image-builder #264

Open
lknite opened this issue Oct 15, 2024 · 1 comment · May be fixed by #268
Open
Labels
enhancement New feature or request

Comments

@lknite
Copy link

lknite commented Oct 15, 2024

Summary

This feature request is just asking that instead of assuming the callback ip will be the same as the ip where the server is running, (which used to makes sense in the days before kubernetes), is to instead have a variable for the ip where the server is running and another variable for the ip/fqdn to use when accessing the http server... and to let me as a user set that second variable.

e.g. callback_url="http://1.2.3.4"

Use case

I'm running image builder via a gitlab runner pipeline (which is running in kubernetes) and need to setup configuration for the callback HTTP server. Using the same IP the server is running on won't work.

Is your feature request related to a problem? Please describe.

When a pod runs in kubernetes its using a local clusterip, that's not reachable by the outside world. Instead, it needs to be exposed via a service. The gitlab runner helm chart has the ability to expose the runner via a service. So far I do not see where I can specify the IP in image-builder. Even better, it would be nice to use an ingress and an FQDN as the FQDN would remain consistent (the gitlab runner helm chart has the ability to specify an ingress).

Describe the solution you'd like

With the gitlab runner running in a pod it can use whatever port it wants, such as port 80. There's no need to have a random port anymore. 1. Need to be able to specify the port to use so it isn't random. Now that the port is predictable it can be exposed via a service. I can take care of that and request a loadbalancer ip. 2. need to be able to specify the ip for image-builder to use in its callback. Preferably, instead of a loadbalancer ip, I'd rather use an ingress. I can take care of creating the ingress. 3. need ability to specify an ingress for image-builder to use in its callback.

Describe alternatives you've considered

I wouldn't be surprised if this ability already existed. I've been searching for such a feature for a couple weeks now.

Potential configuration

If this ability doesn't already exist, it would be good to add it and configure things via environment variables. Maybe something like:

(top level?)
export CALLBACK_URL="http://10.4.0.71:8080"
export CALLBACK_PORT="8080"
or
export PROXMOX_URL="https://10.0.0.21:8006/api2/json"
export PROXMOX_USERNAME="capmox@pve!capi"
export PROXMOX_CALLBACK_URL="https://image-builder.k.home.net"
export PROXMOX_CALLBACK_PORT="443"
or
export PROXMOX_CALLBACK_URL="http://10.4.0.71:8080"
export PROXMOX_CALLBACK_PORT="8080"

/kind feature

@lknite lknite added the enhancement New feature or request label Oct 15, 2024
@lknite lknite changed the title Ability to specify ip or fqdn & port for HTTP server used by image-builder callback (kubernetes) Ability to specify ip or fqdn & port for HTTP server used by image-builder callback Oct 15, 2024
@lknite lknite changed the title (kubernetes) Ability to specify ip or fqdn & port for HTTP server used by image-builder callback (callback w/ kubernetes) Ability to specify callback ip or fqdn & port of HTTP server used by image-builder Oct 15, 2024
@lknite lknite changed the title (callback w/ kubernetes) Ability to specify callback ip or fqdn & port of HTTP server used by image-builder (kubernetes) Ability to specify callback ip or fqdn & port of HTTP server used by image-builder Oct 15, 2024
@lknite
Copy link
Author

lknite commented Nov 27, 2024

Here's what's needed to get this working:

packer-plugin-sdk

multistep/commonsteps/http_config.go

	HTTPAddress string `mapstructure:"http_bind_address"`
	// Use to specify a specific ip/fqdn a vm should use to reach the callback http server upon completion.
        // This is required when running via workflows/pipelines which are running within a kubernetes cluster.
	HTTPCallbackAddress string `mapstructure:"http_callback_address"`

packer-plugin-proxmox

hashicorp/packer-plugin-proxmox#304

step_type_boot_command.go

        // HTTPCallbackAddress is useful when running within a kubernetes environment using an exposed LoadBalancer ip
        if c.HTTPCallbackAddress != "" {
                httpIP = c.HTTPCallbackAddress
        } else if c.HTTPAddress != "0.0.0.0" {
                httpIP = c.HTTPAddress
        } else {
                httpIP, err = hostIP(c.HTTPInterface)
                if err != nil {
                        err := fmt.Errorf("Failed to determine host IP: %s", err)
                        state.Put("error", err)
                        ui.Error(err.Error())
                        return multistep.ActionHalt
                }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant