Add CloudNativePG Helm Flux Repository
This commit is contained in:
@@ -4,7 +4,7 @@ metadata:
|
|||||||
name: linking
|
name: linking
|
||||||
namespace: linkding
|
namespace: linkding
|
||||||
resources:
|
resources:
|
||||||
- namespace.yaml
|
|
||||||
- srv.yaml
|
- srv.yaml
|
||||||
- pvc.yaml
|
- pvc.yaml
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
|
- namespace.yaml
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"danicos.dev/daniel/homelab/pkg/linkding"
|
"danicos.dev/daniel/homelab/pkg/linkding"
|
||||||
"danicos.dev/daniel/homelab/pkg/longhorn"
|
"danicos.dev/daniel/homelab/pkg/longhorn"
|
||||||
"danicos.dev/daniel/homelab/pkg/monitoring"
|
"danicos.dev/daniel/homelab/pkg/monitoring"
|
||||||
|
"danicos.dev/daniel/homelab/pkg/postgres"
|
||||||
"danicos.dev/daniel/homelab/pkg/root"
|
"danicos.dev/daniel/homelab/pkg/root"
|
||||||
"danicos.dev/daniel/homelab/pkg/truenas"
|
"danicos.dev/daniel/homelab/pkg/truenas"
|
||||||
/*
|
/*
|
||||||
@@ -26,6 +27,7 @@ func main() {
|
|||||||
"monitoring": monitoring.Stack(),
|
"monitoring": monitoring.Stack(),
|
||||||
"longhorn": longhorn.Stack(),
|
"longhorn": longhorn.Stack(),
|
||||||
"truenas-csi": truenas.Stack(),
|
"truenas-csi": truenas.Stack(),
|
||||||
|
"cloud-native-pg": postgres.Stack(),
|
||||||
}
|
}
|
||||||
for name, s := range hydra_infrastructure {
|
for name, s := range hydra_infrastructure {
|
||||||
fmt.Printf("STACK: %s\n", name)
|
fmt.Printf("STACK: %s\n", name)
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cnpg
|
||||||
|
namespace: cnpg-system
|
||||||
|
spec:
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: cnpg/cloudnative-pg
|
||||||
|
interval: 12h0m0s
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: cnpg
|
||||||
|
namespace: cnpg-system
|
||||||
|
install:
|
||||||
|
crds: Create
|
||||||
|
interval: 30m0s
|
||||||
|
upgrade:
|
||||||
|
crds: CreateReplace
|
||||||
|
status: {}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: source.toolkit.fluxcd.io/v1
|
||||||
|
kind: HelmRepository
|
||||||
|
metadata:
|
||||||
|
name: cnpg
|
||||||
|
namespace: cnpg-system
|
||||||
|
spec:
|
||||||
|
interval: 24h0m0s
|
||||||
|
url: https://cloudnative-pg.github.io/charts
|
||||||
|
status: {}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: cnpg-system
|
||||||
|
spec: {}
|
||||||
|
status: {}
|
||||||
@@ -4,16 +4,16 @@ metadata:
|
|||||||
name: truenas-csi
|
name: truenas-csi
|
||||||
namespace: truenas-csi
|
namespace: truenas-csi
|
||||||
resources:
|
resources:
|
||||||
- CSIDriver.yaml
|
- node-service-account.yaml
|
||||||
|
- node-cluster-role.yaml
|
||||||
|
- node-binding.yaml
|
||||||
- nfs-storage-class.yaml
|
- nfs-storage-class.yaml
|
||||||
|
- iscsi-storage-class.yaml
|
||||||
- namespace.yaml
|
- namespace.yaml
|
||||||
|
- controller-deployment.yaml
|
||||||
- controller-service-account.yaml
|
- controller-service-account.yaml
|
||||||
- controller-cluster-role.yaml
|
- controller-cluster-role.yaml
|
||||||
- node-cluster-role.yaml
|
|
||||||
- node-deamonset.yaml
|
|
||||||
- config.yaml
|
|
||||||
- iscsi-storage-class.yaml
|
|
||||||
- controller-deployment.yaml
|
|
||||||
- controller-binding.yaml
|
- controller-binding.yaml
|
||||||
- node-service-account.yaml
|
- node-deamonset.yaml
|
||||||
- node-binding.yaml
|
- CSIDriver.yaml
|
||||||
|
- config.yaml
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package postgres
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"danicos.dev/daniel/go-kube/pkg/flux"
|
||||||
|
"danicos.dev/daniel/go-kube/pkg/kube"
|
||||||
|
"danicos.dev/daniel/go-kube/pkg/stack"
|
||||||
|
"danicos.dev/daniel/homelab/pkg/root"
|
||||||
|
helm "github.com/fluxcd/helm-controller/api/v2"
|
||||||
|
source "github.com/fluxcd/source-controller/api/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var meta kube.Metadata
|
||||||
|
var Namespace = kube.Namespace(root.CloudNativePG + "-system")
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
meta = kube.NewMetadata(root.CloudNativePG, Namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Stack() stack.Stack {
|
||||||
|
s := stack.NewStack("cloud-native-pg", map[string]any{
|
||||||
|
"namespace": Namespace,
|
||||||
|
"helm-repository-source": HelmSource(),
|
||||||
|
"helm-release": HelmRelease(),
|
||||||
|
})
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func HelmSource() source.HelmRepository {
|
||||||
|
spec := source.HelmRepositorySpec{
|
||||||
|
Interval: durHour(root.FLUX_HELM_MONITORING_INTERVAL),
|
||||||
|
URL: root.HELM_CLOUD_NATIVE_PG_URL,
|
||||||
|
}
|
||||||
|
return flux.NewFluxHelmRepositorySource(meta, spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func HelmRelease() helm.HelmRelease {
|
||||||
|
interval := durHour(12)
|
||||||
|
spec := helm.HelmReleaseSpec{
|
||||||
|
Interval: durMin(30),
|
||||||
|
Chart: &helm.HelmChartTemplate{
|
||||||
|
Spec: helm.HelmChartTemplateSpec{
|
||||||
|
Chart: root.HELM_CLOUD_NATIVE_PG_CHART,
|
||||||
|
// Version: root.HELM_CLOUD_NATIVE_PG_CHART_VERSION,
|
||||||
|
Interval: &interval,
|
||||||
|
SourceRef: helm.CrossNamespaceObjectReference{
|
||||||
|
Kind: flux.MetaHelmRepository.Kind,
|
||||||
|
Name: meta.Meta().Name,
|
||||||
|
Namespace: Namespace.Name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Install: &helm.Install{
|
||||||
|
CRDs: helm.Create,
|
||||||
|
},
|
||||||
|
Upgrade: &helm.Upgrade{
|
||||||
|
CRDs: helm.CreateReplace,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return flux.NewFluxHelmRelease(meta, spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func durHour(d int64) metav1.Duration {
|
||||||
|
return metav1.Duration{Duration: (time.Duration(d) * time.Hour)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func durMin(d int64) metav1.Duration {
|
||||||
|
return metav1.Duration{Duration: (time.Duration(d) * time.Minute)}
|
||||||
|
}
|
||||||
@@ -31,6 +31,9 @@ const (
|
|||||||
HELM_LONGHORN_URL = "https://charts.longhorn.io"
|
HELM_LONGHORN_URL = "https://charts.longhorn.io"
|
||||||
HELM_LONGHORN_CHART = "longhorn"
|
HELM_LONGHORN_CHART = "longhorn"
|
||||||
HELM_LONGHORN_CHART_VERSION = "1.11.1"
|
HELM_LONGHORN_CHART_VERSION = "1.11.1"
|
||||||
|
HELM_CLOUD_NATIVE_PG_URL = "https://cloudnative-pg.github.io/charts"
|
||||||
|
HELM_CLOUD_NATIVE_PG_CHART = "cnpg/cloudnative-pg"
|
||||||
|
HELM_CLOUD_NATIVE_PG_CHART_VERSION = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ var Linkding = Service{
|
|||||||
var (
|
var (
|
||||||
Longhorn = "longhorn"
|
Longhorn = "longhorn"
|
||||||
Monitoring = "monitoring"
|
Monitoring = "monitoring"
|
||||||
|
CloudNativePG = "cnpg"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
Reference in New Issue
Block a user