feat(go-traefik-certmanager): initial commit

This commit is contained in:
Tom Neuber 2025-01-21 21:29:51 +01:00
parent 913eaceaa4
commit c10b760c0b
Signed by: tom
GPG key ID: F17EFE4272D89FF6
14 changed files with 835 additions and 0 deletions

51
main.go Normal file
View file

@ -0,0 +1,51 @@
package main
import (
"log"
"os"
"os/signal"
"syscall"
"git.ar21.de/yolokube/go-traefik-certmanager/internal/cmd"
"git.ar21.de/yolokube/go-traefik-certmanager/pkg/certmanager"
"git.ar21.de/yolokube/go-traefik-certmanager/pkg/ingressroute"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
)
func main() {
cli := cmd.CLI{}
appSettings := cli.Parse()
config, err := rest.InClusterConfig()
if err != nil {
log.Fatal(err)
}
client, err := dynamic.NewForConfig(config)
if err != nil {
log.Fatal(err)
}
cmClient := certmanager.NewClient(
*client,
certmanager.WithCertIssuerKind(appSettings.CertIssuerKind),
certmanager.WithCertIssuerName(appSettings.CertIssuerName),
)
irClient := ingressroute.NewClient(
*client,
cmClient,
ingressroute.WithCertCleanup(),
)
stopCh := make(chan struct{})
defer close(stopCh)
go irClient.IngressRoutes.Watch(stopCh)
signalCh := make(chan os.Signal, 1)
signal.Notify(signalCh, syscall.SIGINT, syscall.SIGTERM)
<-signalCh
log.Print("Shutting down gracefully")
}