dajudge/kindcontainer

Install local helm chart in container

Closed this issue · 2 comments

d-rk commented

Hi,

I'm currently playing around with your library and so far I really like how it can be used.

I have a helm chart that is build during my maven build and I want to test it with somthing like this:

	private static final K3sContainer<?> K8S = new K3sContainer<>().withHelm3(helm -> {
		helm.install
				.namespace("my-namespace")
				.createNamespace()
				.run("my-release", "local-chart.tgz");
	})

I don't want to publish the chart, because the chart should be published later in my build (but only when the tests are successful).
Is there a way to install a local helm chart currently?

Hey @d-rk - awesome question and thanks for the feedback!

I've hacked together an example: https://github.com/dajudge/kindcontainer-examples/blob/master/operator/src/test/java/com/dajudge/kindcontainer/examples/helm/LocalHelmChartTest.java

The basic idea is to copy your chart to the container helm is running in like this:

new K3sContainer<>()
        .withHelm3(helm -> {
            helm.copyFileToContainer(MountableFile.forHostPath("/path/to/local-chart.tgz"), "/tmp/chart.tgz");
            helm.install
                    .namespace("my-namespace")
                    .createNamespace()
                    .run("my-release", "/tmp/chart.tgz");
        });

Does this resolve your question?

d-rk commented

ah yes, that is exactly what I needed 👍