Service Account and Meta Service not available for cloud config services

Anyone used the metaservice or a service account with a service configured to run at startup via cloud init.

I have service configure that starts when the host starts

labelme:
  image: myimagename
  labels:
    - io.rancher.container.dns=true
    - io.rancher.container.agent.role=environment
    - io.rancher.container.create_agent=true

I’ve tried the agent role and create agent labels. They work if I create a standalone container but not when configured via cloud init. Same is true for MetaService. I’ve tried manage networking and container dns. Works fine when I create a standalone container via ui but not cloud init.

Anyone used the metaservice from a cloud config container? Love to know how you got it to work.

I believe the metadata service and service account can only be used by scheduling the container to run via Rancher. Launching the container directly on the host won’t allow the scheduler from perform any of it’s additional behavior.

What’s the purpose of launching via cloudinit? Can you achieve this behavior using a global service in Rancher?

I was trying to create a container that would label the host with an ec2instance id. This would help in auto cleaning up removed hosts when using spot fleets in EC2. I can get this to work as a global service how ever the service has to be deployed in each environment. It “just would be nicer” (technical term) if I could do this through a readable cloud init. We have made it work by using scripts in the cloud init rather than a cloud config.

Looks like rancher sees a container created this way as a native container. However containers started by the agent that was initially launched as a native container do not appear as native containers. I’ve been looking at how the agent creates containers and will experiment with that approach to see what happens. (Not productive work just interested.)