Instance Tagging and/or Grouping

Not sure if I’ve seen any suggestions on this, but is there any interest on making something like tags or groups on instances?
I would like to have something like projects but purely cosmetic, or something like proxmox’s tagging.
It would work with the api or in the client as a filtering option or something like that.
If it’s not a planned feature I could probably get something working, I’m familiar with go.

I think I hit discard by mistake… nice. (apparently not, ignore the deleted post please)

I found another suggestion like this one (that being this one).
Keeping it in user configs is fine, metadata would be nicer since the tag isn’t supposed to be something that affects the instance? Might be better to use metadata if possible, in the case of many instances with many configs set.

In theory, it should only require an operator that the filter can use to read the value as a string slice and check if that value/regex is in that slice?
Depending on how the terraform module is set up, the type may or may not need to be changed unless the type is something arbitrary like any. Yaml has support for arrays or it could be a json string, either should work.

If this is something that can be done without much changing to other systems I could try and implement it, I am familiar with go.

After some digging in the incus repo, I think the only thing that needs to be changed is in here. Possibly some changes in the supported filter section here?
A new operator would need to be defined but that’s just a matter of picking a character. If that character is found, it goes to the respective case and filtered. Since it’s just a true/false to show the instance, it shouldn’t be too bad. I might try and get it working later and put in a PR.

I was having issues building incus so I’m not able to test the change I made. My machine is on windows, and I couldn’t get wsl to run the dev container or the nix shell. I opened an issue/feature request. Add filter for slice contains · Issue #3326 · lxc/incus

Is this not going to be sufficient? I mean, you can have comma separated value and then filter with regexp.

user.tags = "backend,go,api"

And filter for multiple with

incus list user.tags="(backend|go)"
1 Like

It should be, I can’t get it to work. Am I missing something?

✓ incus config set yes-server:authentik user.tags=“auth,services”
✓ incus config set yes-server:caddy user.tags=“proxy,services”
✓ incus list yes-server: user.tags=“(auth)”
±-----±------±-----±-----±-----±----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
±-----±------±-----±-----±-----±----------+
✓ incus list yes-server: user.tags=“(services)”
±-----±------±-----±-----±-----±----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
±-----±------±-----±-----±-----±----------+
✓ incus list yes-server: user.tags=“(auth|services)”
±-----±------±-----±-----±-----±----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
±-----±------±-----±-----±-----±----------+

✓ incus list yes-server: user.tags=“auth,services”
±----------±--------±---------------------±-----±----------------±----------+
|   NAME    |  STATE  |         IPV4         | IPV6 |      TYPE       | SNAPSHOTS |
±----------±--------±---------------------±-----±----------------±----------+
| authentik | RUNNING | 192.168.2.220 (eth0) |      | CONTAINER (APP) | 0         |
±----------±--------±---------------------±-----±----------------±----------+

Regexp matching on values works fine here:

stgraber@dakara:~$ incus list user.tags='(^.*bar.*)'
+------+---------+------+------+-----------+-----------+
| NAME |  STATE  | IPV4 | IPV6 |   TYPE    | SNAPSHOTS |
+------+---------+------+------+-----------+-----------+
| c1   | STOPPED |      |      | CONTAINER | 0         |
+------+---------+------+------+-----------+-----------+

So I don’t think that we really need to add anything to the API, it’s mostly just a matter of building the correct regexp to parse the field and you’re good to go.

Ah I see, I’ve never had to deal with regex so that didn’t occur to me. I just tested it and it definitely works, thanks!

✓ incus list yes-server: user.tags='(^.*auth.*)'
+-----------+---------+----------------------+------+-----------------+-----------+
|   NAME    |  STATE  |         IPV4         | IPV6 |      TYPE       | SNAPSHOTS |
+-----------+---------+----------------------+------+-----------------+-----------+
| authentik | RUNNING | 192.168.2.220 (eth0) |      | CONTAINER (APP) | 0         |
+-----------+---------+----------------------+------+-----------------+-----------+
✓ incus list yes-server: user.tags='(^.*auth|proxy.*)'
+-----------+---------+----------------------+------+-----------------+-----------+
|   NAME    |  STATE  |         IPV4         | IPV6 |      TYPE       | SNAPSHOTS |
+-----------+---------+----------------------+------+-----------------+-----------+
| authentik | RUNNING | 192.168.2.220 (eth0) |      | CONTAINER (APP) | 0         |
+-----------+---------+----------------------+------+-----------------+-----------+
| caddy     | RUNNING | 192.168.2.151 (eth0) |      | CONTAINER (APP) | 0         |
+-----------+---------+----------------------+------+-----------------+-----------+
✓ incus list yes-server: user.tags='(^.*auth|proxy|git.*)'
+----------------+---------+----------------------+------+-----------------+-----------+
|      NAME      |  STATE  |         IPV4         | IPV6 |      TYPE       | SNAPSHOTS |
+----------------+---------+----------------------+------+-----------------+-----------+
| authentik      | RUNNING | 192.168.2.220 (eth0) |      | CONTAINER (APP) | 0         |
+----------------+---------+----------------------+------+-----------------+-----------+
| caddy          | RUNNING | 192.168.2.151 (eth0) |      | CONTAINER (APP) | 0         |
+----------------+---------+----------------------+------+-----------------+-----------+
| forgejo-server | RUNNING | 192.168.2.196 (eth0) |      | CONTAINER (APP) | 0         |
+----------------+---------+----------------------+------+-----------------+-----------+```