Add k3s and flux installation
This commit is contained in:
@@ -1,30 +1 @@
|
|||||||
# GitOps
|
# GitOps
|
||||||
> A set of "best practices" where the entire code delivery process is controlled via Git,
|
|
||||||
including infrastructure and application definition as code and automation to complete updates
|
|
||||||
and rollbacks.
|
|
||||||
|
|
||||||
The key GitOps Principles
|
|
||||||
- The entire system (infrastructure and applications) is described declaratively.
|
|
||||||
- The canonical desired system state is versioned in Git.
|
|
||||||
- Changes approved are automated and applied to the system.
|
|
||||||
- Software agents ensure correctness and alert on divergence.
|
|
||||||
|
|
||||||
https://opengitops.dev/
|
|
||||||
|
|
||||||
Key points for a Kubernetes cluster:
|
|
||||||
1. The state of the cluster is always described in Git. Git holds everything for the application
|
|
||||||
and not just the source code.
|
|
||||||
2. There is no external deployment system with full access to the cluster. The cluster itself
|
|
||||||
is pulling changes and deployment information.
|
|
||||||
3. The GitOps controller is running in a constant loop and always matches the Git state with the
|
|
||||||
cluster state (reconciliation loop).
|
|
||||||
|
|
||||||
## flux vs ArgoCD
|
|
||||||
Flux is more CLI Driven
|
|
||||||
ArgoCD has a richer GUI
|
|
||||||
|
|
||||||
## Flux
|
|
||||||
Prerequisites:
|
|
||||||
- Kubernetes Cluster
|
|
||||||
- Github (giea, etc) personal access token
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
|||||||
# This manifest was generated by flux. DO NOT EDIT.
|
|
||||||
---
|
|
||||||
apiVersion: source.toolkit.fluxcd.io/v1
|
|
||||||
kind: GitRepository
|
|
||||||
metadata:
|
|
||||||
name: flux-system
|
|
||||||
namespace: flux-system
|
|
||||||
spec:
|
|
||||||
interval: 1m0s
|
|
||||||
ref:
|
|
||||||
branch: main
|
|
||||||
secretRef:
|
|
||||||
name: flux-system
|
|
||||||
url: https://danicos.dev/daniel/homelab.git
|
|
||||||
---
|
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
|
||||||
kind: Kustomization
|
|
||||||
metadata:
|
|
||||||
name: flux-system
|
|
||||||
namespace: flux-system
|
|
||||||
spec:
|
|
||||||
interval: 10m0s
|
|
||||||
path: ./clusters/hydra
|
|
||||||
prune: true
|
|
||||||
sourceRef:
|
|
||||||
kind: GitRepository
|
|
||||||
name: flux-system
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
resources:
|
|
||||||
- gotk-components.yaml
|
|
||||||
- gotk-sync.yaml
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# This file should be in: /etc/rancher/k3s/config.yaml
|
||||||
|
write-kubeconfig-mode: "0644"
|
||||||
|
disable:
|
||||||
|
- helm-controller
|
||||||
|
# tls-san:
|
||||||
|
# - "kube.danicos.dev"
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
module danicos.dev/daniel/homelab
|
||||||
|
|
||||||
|
go 1.26.2
|
||||||
|
|
||||||
|
require (
|
||||||
|
danicos.dev/daniel/go-kube v1.2.0
|
||||||
|
github.com/fatih/color v1.19.0
|
||||||
|
github.com/fluxcd/kustomize-controller/api v1.8.3
|
||||||
|
github.com/magefile/mage v1.17.1
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/fluxcd/pkg/apis/kustomize v1.15.1 // indirect
|
||||||
|
github.com/fluxcd/pkg/apis/meta v1.25.1 // indirect
|
||||||
|
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
|
||||||
|
github.com/go-logr/logr v1.4.3 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
|
||||||
|
github.com/x448/float16 v0.8.4 // indirect
|
||||||
|
go.yaml.in/yaml/v2 v2.4.3 // indirect
|
||||||
|
golang.org/x/net v0.49.0 // indirect
|
||||||
|
golang.org/x/sys v0.42.0 // indirect
|
||||||
|
golang.org/x/text v0.33.0 // indirect
|
||||||
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
|
k8s.io/api v0.35.2 // indirect
|
||||||
|
k8s.io/apiextensions-apiserver v0.35.2 // indirect
|
||||||
|
k8s.io/apimachinery v0.35.2 // indirect
|
||||||
|
k8s.io/klog/v2 v2.130.1 // indirect
|
||||||
|
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
|
||||||
|
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
|
||||||
|
sigs.k8s.io/controller-runtime v0.23.1 // indirect
|
||||||
|
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
|
||||||
|
sigs.k8s.io/randfill v1.0.0 // indirect
|
||||||
|
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 // indirect
|
||||||
|
sigs.k8s.io/yaml v1.6.0 // indirect
|
||||||
|
)
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
danicos.dev/daniel/go-kube v1.2.0 h1:nLcpSOmszmkMnHd4Fb9V7R8qO7z2OwNgUFFWQNwQazs=
|
||||||
|
danicos.dev/daniel/go-kube v1.2.0/go.mod h1:FLgPxaiDpLmIwWddx5x4jTfP/onTzkOLbhmpdt2uX6w=
|
||||||
|
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
|
||||||
|
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
|
||||||
|
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
|
||||||
|
github.com/fluxcd/kustomize-controller/api v1.8.3 h1:Ux9AAOY0lkP6FgRg5/b/ITvRSy8lz6VBBaZ9bXmTLmI=
|
||||||
|
github.com/fluxcd/kustomize-controller/api v1.8.3/go.mod h1:c/mUPIffDDLg1EicXCJtX4N/rc+z5Zh0e/CXjhd7Dyc=
|
||||||
|
github.com/fluxcd/pkg/apis/kustomize v1.15.1 h1:t9QZh+3ZS8EKmlxrnnbcKZcGTrg8FDvMF1T8BHMCuqI=
|
||||||
|
github.com/fluxcd/pkg/apis/kustomize v1.15.1/go.mod h1:IZOy4CCtR/hxMGb7erK1RfbGnczVv4/dRBoVD37AywI=
|
||||||
|
github.com/fluxcd/pkg/apis/meta v1.25.1 h1:WG1GIC/SOz0GjxT0uVuO6AMicQ3yFsk6bDozCnq+fto=
|
||||||
|
github.com/fluxcd/pkg/apis/meta v1.25.1/go.mod h1:c7o6mJGLCMvNrfdinGZehkrdZuFT9vZdZNrn66DtVD0=
|
||||||
|
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
|
||||||
|
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
||||||
|
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||||
|
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
|
||||||
|
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
||||||
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
|
||||||
|
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/magefile/mage v1.17.1 h1:F1d2lnLSlbQDM0Plq6Ac4NtaHxkxTK8t5nrMY9SkoNA=
|
||||||
|
github.com/magefile/mage v1.17.1/go.mod h1:Yj51kqllmsgFpvvSzgrZPK9WtluG3kUhFaBUVLo4feA=
|
||||||
|
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||||
|
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8=
|
||||||
|
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns=
|
||||||
|
github.com/onsi/ginkgo/v2 v2.27.2/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
|
||||||
|
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
|
||||||
|
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
|
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
|
||||||
|
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
|
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||||
|
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||||
|
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
|
||||||
|
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
|
||||||
|
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||||
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
|
golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
|
||||||
|
golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
|
||||||
|
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
|
||||||
|
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
|
||||||
|
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||||
|
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||||
|
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||||
|
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
|
||||||
|
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
|
||||||
|
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
|
||||||
|
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||||
|
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
k8s.io/api v0.35.2 h1:tW7mWc2RpxW7HS4CoRXhtYHSzme1PN1UjGHJ1bdrtdw=
|
||||||
|
k8s.io/api v0.35.2/go.mod h1:7AJfqGoAZcwSFhOjcGM7WV05QxMMgUaChNfLTXDRE60=
|
||||||
|
k8s.io/apiextensions-apiserver v0.35.2 h1:iyStXHoJZsUXPh/nFAsjC29rjJWdSgUmG1XpApE29c0=
|
||||||
|
k8s.io/apiextensions-apiserver v0.35.2/go.mod h1:OdyGvcO1FtMDWQ+rRh/Ei3b6X3g2+ZDHd0MSRGeS8rU=
|
||||||
|
k8s.io/apimachinery v0.35.2 h1:NqsM/mmZA7sHW02JZ9RTtk3wInRgbVxL8MPfzSANAK8=
|
||||||
|
k8s.io/apimachinery v0.35.2/go.mod h1:jQCgFZFR1F4Ik7hvr2g84RTJSZegBc8yHgFWKn//hns=
|
||||||
|
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||||
|
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
|
||||||
|
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE=
|
||||||
|
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ=
|
||||||
|
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck=
|
||||||
|
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||||
|
sigs.k8s.io/controller-runtime v0.23.1 h1:TjJSM80Nf43Mg21+RCy3J70aj/W6KyvDtOlpKf+PupE=
|
||||||
|
sigs.k8s.io/controller-runtime v0.23.1/go.mod h1:B6COOxKptp+YaUT5q4l6LqUJTRpizbgf9KSRNdQGns0=
|
||||||
|
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
|
||||||
|
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
|
||||||
|
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
|
||||||
|
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
|
||||||
|
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 h1:2WOzJpHUBVrrkDjU4KBT8n5LDcj824eX0I5UKcgeRUs=
|
||||||
|
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
|
||||||
|
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
|
||||||
|
sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
sudo mkdir -p /etc/rancher/k3s
|
|
||||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=helm-controller" sh
|
|
||||||
sudo systemctl status k3s.service
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"danicos.dev/daniel/homelab/pkg/root"
|
||||||
|
"danicos.dev/daniel/homelab/pkg/target"
|
||||||
|
// "github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps
|
||||||
|
/*
|
||||||
|
NOTE: Mage https://github.com/magefile/mage
|
||||||
|
Mage other packages
|
||||||
|
"github.com/magefile/mage/mage"
|
||||||
|
"github.com/magefile/mage/parse"
|
||||||
|
"github.com/magefile/mage/target"
|
||||||
|
*/)
|
||||||
|
|
||||||
|
var r target.Runner
|
||||||
|
var Default = Run
|
||||||
|
var Aliases = map[string]any{
|
||||||
|
"r": Run,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Env := map[string]string{
|
||||||
|
"LINUX_ADMIN": "arch",
|
||||||
|
"CLUSTER_NAME": root.HYDRA_CLUSTER,
|
||||||
|
"CLUSTER_HOST": root.HYDRA_HOSTNAME,
|
||||||
|
"GITEA_HOST": root.GITEA_HOST,
|
||||||
|
}
|
||||||
|
r = target.NewRunner(Env, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Run() error {
|
||||||
|
t := target.NewA("go", "run", ".")
|
||||||
|
return r.RunV("run", t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func InstallK3S() error {
|
||||||
|
t := target.New("./scripts/install_k3s.sh")
|
||||||
|
return r.RunV("Install k3s", t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetKubeconfig() error {
|
||||||
|
t := target.New("./scripts/get_kubeconfig.sh")
|
||||||
|
return r.RunV("Get Kubeconfig", t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func InstallFlux() error {
|
||||||
|
t := target.New("./scripts/install_flux.sh")
|
||||||
|
return r.RunV("Install Flux", t)
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"danicos.dev/daniel/go-kube/pkg/kube"
|
||||||
|
"danicos.dev/daniel/homelab/pkg/flux"
|
||||||
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
meta := kube.NewMetadata("name", kube.Namespace("nae"))
|
||||||
|
kuz := kube.NewKustomization(meta, kustomizev1.KustomizationSpec{})
|
||||||
|
fluxStack := flux.Stack()
|
||||||
|
fluxStack.Add("apps", kuz)
|
||||||
|
fluxStack.MarshalYaml("")
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package flux
|
||||||
|
|
||||||
|
import "danicos.dev/daniel/go-kube/pkg/stack"
|
||||||
|
|
||||||
|
func Stack() stack.Stack {
|
||||||
|
s := stack.NewStack("", nil)
|
||||||
|
return s
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package root
|
||||||
|
|
||||||
|
var (
|
||||||
|
HYDRA_CLUSTER = "hydra"
|
||||||
|
HYDRA_HOSTNAME = "hydra-0" // VPN Host
|
||||||
|
GITEA_HOST = "danicos.dev"
|
||||||
|
)
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package target
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
import "github.com/magefile/mage/sh"
|
||||||
|
import "github.com/fatih/color"
|
||||||
|
|
||||||
|
type Target struct {
|
||||||
|
Bin string
|
||||||
|
args []string
|
||||||
|
Silent bool
|
||||||
|
Msg string
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(bin string) (c Target) {
|
||||||
|
c.Bin = bin
|
||||||
|
return NewA(bin)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewA(bin string, args ...string) (c Target) {
|
||||||
|
c.Bin = bin
|
||||||
|
c.args = args
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Target) Args(args ...string) {
|
||||||
|
t.args = append(t.args, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t Target) SetMsg(m string) Target {
|
||||||
|
t.Msg = m
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
type Runner struct {
|
||||||
|
env map[string]string
|
||||||
|
info *color.Color
|
||||||
|
error *color.Color
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRunner(env map[string]string, c *color.Color) (r Runner) {
|
||||||
|
r.info = c
|
||||||
|
if c == nil {
|
||||||
|
r.info = color.New(color.FgGreen)
|
||||||
|
}
|
||||||
|
r.error = color.New(color.FgRed)
|
||||||
|
r.env = env
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Runner) RunV(targetName string, t Target) error {
|
||||||
|
return r.run(true, targetName, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Runner) Run(targetName string, t Target) error {
|
||||||
|
return r.run(false, targetName, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Runner) run(verbose bool, targetName string, t Target) error {
|
||||||
|
tar := "Target: "
|
||||||
|
td := fmt.Sprintf("<%s> ", targetName)
|
||||||
|
if len(t.args) == 0 {
|
||||||
|
r.info.Println(tar, td, t.Bin)
|
||||||
|
} else {
|
||||||
|
r.info.Println(tar, td, t.Bin, t.args)
|
||||||
|
}
|
||||||
|
if t.Msg != "" {
|
||||||
|
r.error.Println(" ", t.Msg)
|
||||||
|
}
|
||||||
|
if verbose {
|
||||||
|
return sh.RunWithV(r.env, t.Bin, t.args...)
|
||||||
|
}
|
||||||
|
return sh.RunWith(r.env, t.Bin, t.args...)
|
||||||
|
}
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo CLUSTER NAME: $CLUSTER_NAME
|
||||||
|
echo HOST: $CLUSTER_HOST
|
||||||
|
echo USER: $LINUX_ADMIN
|
||||||
|
|
||||||
|
rsync --rsync-path="sudo rsync" $LINUX_ADMIN@$CLUSTER_HOST:/etc/rancher/k3s/k3s.yaml ~/.kube/$CLUSTER_NAME
|
||||||
|
sudo sed -i "s/127.0.0.1/$CLUSTER_HOST/g" ~/.kube/$CLUSTER_NAME
|
||||||
|
kubectl --kubeconfig ~/.kube/$CLUSTER_NAME get pods -A
|
||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo CLUSTER NAME: $CLUSTER_NAME
|
||||||
|
|
||||||
|
flux --kubeconfig ~/.kube/$CLUSTER_NAME \
|
||||||
|
bootstrap gitea \
|
||||||
|
--token-auth \
|
||||||
|
--hostname=$GITEA_HOST \
|
||||||
|
--owner=daniel \
|
||||||
|
--repository=homelab \
|
||||||
|
--private=false \
|
||||||
|
--branch=main \
|
||||||
|
--personal=true \
|
||||||
|
--path=./clusters/hydra
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo HOST: $CLUSTER_HOST
|
||||||
|
echo USER: $LINUX_ADMIN
|
||||||
|
|
||||||
|
ssh $LINUX_ADMIN@$CLUSTER_HOST "sudo mkdir -p /etc/rancher/k3s"
|
||||||
|
rsync --rsync-path="sudo rsync" ./config/k3s/config.yaml $LINUX_ADMIN@$CLUSTER_HOST:/etc/rancher/k3s
|
||||||
|
ssh $LINUX_ADMIN@$CLUSTER_HOST "sudo curl -sfL https://get.k3s.io | sudo sh"
|
||||||
|
ssh $LINUX_ADMIN@$CLUSTER_HOST "sudo systemctl status k3s.service"
|
||||||
Reference in New Issue
Block a user