(External) rest api

Hi,

first of all, great job. Garden.io seams to be a game changer for various problems during kubernetes ci cd.

Currently we did a POC where we dynamically deployed projects in a cluster during a pull request. Exposing a merged context allows us to preview changes before it will be deployed on production. This seams to work flawless in azure pipelines with a small setup. But before we step ahead to a full grown project we want to close the circle to be able to teardown the pullrequest deployment.

As we are not 100% familiar with the hole setup we are wondering weather we would be able to call an rest api to do this or to update environments when other repositories publish changes. We know about the possibility to build and keep track of changes within the garden system. but as we are dependent on existing containers we just want to deploy the build ones.

You mention to have a rest api in one point in your documentation but not how it is reachable.
What would be the best approach while using azure to deploy images and integrate them in a preview environment and tear them down if not needed anymore.

Greetings

1 Like

Hi Sebastian and thanks for your question!

We don’t have a proper REST API at the moment (although we use something akin to that internally for the dashboard). Could you point me to the place in the docs were you saw this mentioned?

That being said, you should certainly be able to achieve what you’re after by just using the CLI. You’re probably looking for the garden delete environment --env my-env command. That would essentially delete all the resources and the K8s namespace for the resource in question.

As a side note, the functionality you’re describing is actually built into our enterprise offering—which can automatically deploy and tear down preview environments on pull requests and similar events, among other things. We’d be happy to get into more detail if you think that might fit your use case.

But back to the core CLI, do you think the delete environment command does the trick?

1 Like

Hi,

Thanks, In general i knew about that command to delete the env, but the command to delete an enviroment without a project file is nice to know.
The idea was to use it without the cli, because it would need a kubernetes context. The problem with azure piplines is that a proper reaction to a closed pull request needs to be processed externally. Currently we try to find a setup to have as less different connctions as possible.

A further question would be: would the cli work when used inside the cluster using the kubernetes api server? My thinking would be to call a own api and delegate it to the garden cli which works inside the cluster. Also I saw your node.js wrapper that would call the garden commands within my own api, if it would work inside the cluster-

Maybe you mean something different, but here you mention a rest api
https://docs.garden.io/reference/commands

Thanks for helping

Hi again,

never mind. We just found out that kubectl can also run inside a cluster pod. That being said, I think we have to dig deeper in fundamentals of kubernetes bevor asking obvious questions. But could you please confirm that: If we put a api over a pod which has a cluster role to use kubectl with garden installed we would have a garden control server?

Yes, correct, kubectl can do that. And if you have Garden installed in a container, you can run commands inside a Pod in your cluster.

In fact, we ship a few Garden container images. A lot of our users use them e.g. in CI. You’ll find them under gardendev on Dockerhub, e.g. this one.

You can also see the full list and their contents on our GitHub repo.