56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
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),
|
|
)
|
|
|
|
options := []ingressroute.ClientOption{}
|
|
if appSettings.CertCleanup {
|
|
options = append(options, ingressroute.WithCertCleanup())
|
|
}
|
|
|
|
irClient := ingressroute.NewClient(
|
|
*client,
|
|
cmClient,
|
|
options...,
|
|
)
|
|
|
|
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")
|
|
}
|