Using Portainer git...
 
Notifications
Clear all

Using Portainer gitops feature?

3 Posts
2 Users
1 Reactions
635 Views
Posts: 1
Topic starter
(@bastianthies)
New Member
Joined: 2 months ago

Hi!

I have a Docker-host running in my homelab with Traefik as reverse proxy and Portainer as orchestration tool (3 node free BE version). I plan to expand my single hosts into a Docker Swarm cluster with shared storage soon, using the concept of Brandon's recent video โ€œBest Docker Container Server Setup // Docker Swarm, CephFS, and Portainerโ€. But that doesn't really have much to do with my question 😊 It's more about the interaction between my local development client and the docker cluster.

How I work so far: I'm using VSCode as a code editor and deploying my python web applications already into containers using the VSCode Docker extensions - to test them locally. On the docker side I use a wildcard subdomain of a public domain, *.mydomain.com with dns0-challenge, so all I have to do is to add {myproject}.mydomain.com as a Traefik router host rule label and the service is made available to me via HTTPS with a valid certificate. This works great. Pushing the image into my private docker registry is also no problem and a local git server (gitea) is also already running. But all the pushing and pulling is done manually - so far...

...so I'm looking for a little bit more automation (without the complexity of a whole CI/CD pipeline). What I want to do: Starting from VSCode, pushing my project into a special git deploy branch, so that Portainer is informed about the change over a webhook. Portainer pulls then the updated and automatically built Docker image. The docker-compose is adjusted and prepared on the git side, so that the whole stack fits to my cluster config with Traefik, the needed networks and so on. Ideally, I don't want to have to open Portainer for this because all runs in the background.

I have now read through a lot of documentation and watched videos (mainly from VHT, of course 😉) and have a concept in my head, but I'm not sure if it will work:

I want to use Portainer's gitOps functions to pull the image and update the stack via webhook. The Traefik labels should also be integrated automatically, if possible. My idea is to do this via a git submodule โ€œtraefik-configโ€, where I store the needed Traefik labels as a yaml template. The project names and hostnames are passed via environment variables. The template should then be included into the docker-compose.yml from the main project and and the result is pulled from Portainer as docker-compose.final.yml (with Traefik labels included and some other changes or enhancements).

As you can see, from here on it gets kind of imprecise and vague, because I'm not entirely sure whether it will work like this. I don't know, where to script this process and where to add the needed triggers (gitea actions?).

I would appreciate your opinions. Has anyone already used Portainer's gitops functions? Are they are any good for such a workflow? Better ideas?

Many thanks and best regards,
Bastian

2 Replies
Brandon Lee
Posts: 407
Admin
(@brandon-lee)
Member
Joined: 14 years ago

Bastion,

Awesome forum post and definitely something that is close to my heart as well. I have been moving towards a much more DevOps and GitOps focus in the home lab and in production environments. Portainer is an awesome tool overall and can do so much.

Also, i have been pivoting my home lab environment from GitLab to Gitea so I am definitely on the same page with you there. I really like Gitlab and as most can see I have written about it a lot in the past.ย 

However, I find that Gitea is super fast and I don't have the sluggishness that I find with GitLab. I ran the Omnibus config so this is probably part of my issue but even throwing hardware at it, I haven't found the performance that I have with Gitea. Anyways, I am digressing there. On to the topic at hand.

I think what you are wanting to do you will need to configure a very basic CI/CD environment. But this is not too difficult. I just added Drone CI Server to my Gitea config and look for a blog post on all the ins and outs of doing that. Drone looks to be great so far. So, in reading through what you are wanting to accomplish.

I believe you will want to do the following:

1) Commit and push your code to your repo

2) Kick off a pipeline that builds your new container image based on the new push

3) The pipeline kicks off the webhook in Portainer that updates the container and pulls from your private repo where you have pushed the newly built image.ย 

4) Your traefik config should stay the same since really all you are changing is the container image.

Let me know if this sounds like the workflow?

Brandon

Reply
Brandon Lee
Posts: 407
Admin
(@brandon-lee)
Member
Joined: 14 years ago

Hello @bastianthies. Just checking in to see if you made any progress or need any other help? Just let me know. Thanks again.

Reply