I’ve create my pipeline and all works fine. On push I have them pipeline:
Run tests
Build docker image
Push docker image to private registery
Tell rancher there is an image
rancher will then pull the image
Up to here is fine, but I need to go and add the labels into the container via the UI even though these have been added at the time of building the Docker image…
When I inspect the container on the host ie the labels.
Does rancher not see the labels? Can I get a container on the host, via rancher without any manual leg work?
Yes/No
What are you trying to do with the labels?
It seems the labels built into the image work just fine for scheduling and other programmatic needs. Though yes, you can’t see the labels inside the rancher UI.
Interestingly enough, containers launched through docker run command line seem to have the labels in the docker UI.
You might want to submit this as a bug/feature request.
@JohnDavidLarsen So, I’m trying to achieve the following:
LABEL traefik.frontend.rule=Host:$URL
LABEL traefik.backend=$CONTAINER_NAME
LABEL traefik.enable=true
LABEL traefik.port=3000
I then pass them variables via the build job. As soon as I add the labels manually via the Rancher UI I am able to see my containers show up in Traefik.
This obviously does not allow me to have complete automated deployment for my containers, so spinning up review containers on the fly without having to add further config for it to work is a bit of a blocker for using Rancher in this use case.
Yeah, you can’t use variables in your Dockerfile
Anything done with the rancher UI can be done with the API (and in fact is done with the API).
https://rancher.com/docs/rancher/v1.6/en/api/v2-beta/api-resources/service/
You may want to use your browsers developer tools and watch the network when you manually create a service in your stack, and record exactly what it is sending to the api. Then you can replay that yourself via your script. You need to setup API keys for that.
1 Like
@JohnDavidLarsen thank you very much for the heads up on the API. For some reason I never thought about hitting that. After playing with it tonight it does exactly what I wanted so a big thank you!
I’ve also contributed to cdrx/rancher-gitlab-deploy which adds a feature of passing labels (although I’ve never written Python before )