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

(feature) if env var CALLBACK_URI is specified, the vm uses that when complete, instead of the local ip used with http bind (enables pipelines/workflows executing via kubernetes) #304

Open
lknite opened this issue Nov 27, 2024 · 1 comment · May be fixed by hashicorp/packer-plugin-sdk#268 or #305

Comments

@lknite
Copy link

lknite commented Nov 27, 2024

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

When sending the ip to a vm to use when complete and calling back to the http server, instead of just providing the local ip used when performing the bind of the http server, if the environment variable CALLBACK_URI exists, provide that to the vm instead.

Use Case(s)

I wish to run image-builder via pipelines which run in kubernetes, whether using argocd-workflows, tekton, gitlab-runner running in k8s, or jenkins with the kubernetes plugin.

Kubernetes requires a pod to be exposed before it can be reached from the outside. When using gitlab-runner I can select an option to expose the pod via a LoadBalancer ip or ingress. I can easily provide either of these via an environment variable such as CALLBACK_URI.

Without this feature, no one can use image-builder via pipelines running in kubernetes.

Potential configuration

CALLBACK_URI=http://1.2.3.4
CALLBACK_URI=https://1.2.3.4
CALLBACK_URI=https://gitlab-runner.k.home.net

I could probably submit a pull request, but I haven't been able to figure out how this plugin is passing the ip for the vm to use when its finished. Could it be this functionality is in the packer-plugin-sdk?

@lknite lknite changed the title (feature) if env var CALLBACK_URI is specified, the vm uses that when complete, instead of the local ip used with http bind (feature) if env var CALLBACK_URI is specified, the vm uses that when complete, instead of the local ip used with http bind (otherwise this cannot be used in pipelines/workflows executing via kubernetes) Nov 27, 2024
@lknite
Copy link
Author

lknite commented Nov 27, 2024

Thinking out loud ...

packer-plugin-sdk

hashicorp/packer-plugin-sdk#264

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

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
                }
        }

packer.json.tmpl

"builders": {
  "http_callback_address": "{{user `http_callback_address`}}",
},
"variables": {
  "http_callback_address": "{{env `PROXMOX_HTTP_CALLBACK_ADDRESS`}}"
}

@lknite lknite changed the title (feature) if env var CALLBACK_URI is specified, the vm uses that when complete, instead of the local ip used with http bind (otherwise this cannot be used in pipelines/workflows executing via kubernetes) (feature) if env var CALLBACK_URI is specified, the vm uses that when complete, instead of the local ip used with http bind (enables pipelines/workflows executing via kubernetes) Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant