add: simple flux
This commit is contained in:
Vendored
+10
-9
@@ -13,12 +13,12 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"type": "markdown",
|
"type": "markdown",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "README.md",
|
"file": "infra.md",
|
||||||
"mode": "source",
|
"mode": "source",
|
||||||
"source": false
|
"source": false
|
||||||
},
|
},
|
||||||
"icon": "lucide-file",
|
"icon": "lucide-file",
|
||||||
"title": "README"
|
"title": "infra"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -41,12 +41,12 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"type": "markdown",
|
"type": "markdown",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Games.md",
|
"file": "Simple Flux.md",
|
||||||
"mode": "source",
|
"mode": "source",
|
||||||
"source": false
|
"source": false
|
||||||
},
|
},
|
||||||
"icon": "lucide-file",
|
"icon": "lucide-file",
|
||||||
"title": "Games"
|
"title": "Simple Flux"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -142,12 +142,12 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"type": "outgoing-link",
|
"type": "outgoing-link",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Games.md",
|
"file": "Simple Flux.md",
|
||||||
"linksCollapsed": false,
|
"linksCollapsed": false,
|
||||||
"unlinkedCollapsed": true
|
"unlinkedCollapsed": true
|
||||||
},
|
},
|
||||||
"icon": "links-going-out",
|
"icon": "links-going-out",
|
||||||
"title": "Outgoing links from Games"
|
"title": "Outgoing links from Simple Flux"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -214,11 +214,12 @@
|
|||||||
},
|
},
|
||||||
"active": "a0cc81e9a0ac6335",
|
"active": "a0cc81e9a0ac6335",
|
||||||
"lastOpenFiles": [
|
"lastOpenFiles": [
|
||||||
"README.md",
|
|
||||||
"thoughts.md",
|
|
||||||
"Games.md",
|
|
||||||
"infra.md",
|
"infra.md",
|
||||||
|
"README.md",
|
||||||
"learning ai.md",
|
"learning ai.md",
|
||||||
|
"Simple Flux.md",
|
||||||
|
"Games.md",
|
||||||
|
"thoughts.md",
|
||||||
"rikidown.md",
|
"rikidown.md",
|
||||||
"skubelb.md",
|
"skubelb.md",
|
||||||
"valheim.md",
|
"valheim.md",
|
||||||
|
|||||||
+152
@@ -0,0 +1,152 @@
|
|||||||
|
The Flux tutorial makes things very complicated. In essence, all Flux is is a tool that pulls a git repo, and does `kubectl apply -k`; there should be a much easier way to set it up.
|
||||||
|
## Install Flux
|
||||||
|
Export your GITEA_TOKEN:
|
||||||
|
```
|
||||||
|
export GITEA_TOKEN=THERE_IS_SOME_TOKEN_HERE
|
||||||
|
```
|
||||||
|
Bootstrap the repo:
|
||||||
|
```
|
||||||
|
❯ flux bootstrap gitea \
|
||||||
|
--token-auth=true \
|
||||||
|
--owner=charles \
|
||||||
|
--repository=flux-5pi5 \
|
||||||
|
--branch=main \
|
||||||
|
--path=./ \
|
||||||
|
--personal \
|
||||||
|
--hostname=git.tipsy.codes
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create the repo in Gitea for you, and define a basic structure:
|
||||||
|
|
||||||
|
```
|
||||||
|
❯ tree
|
||||||
|
.
|
||||||
|
└── cluster
|
||||||
|
└── flux-system
|
||||||
|
├── gotk-components.yaml
|
||||||
|
├── gotk-sync.yaml
|
||||||
|
└── kustomization.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
From here, in the simplest way, you can just start deploying applications.
|
||||||
|
## First deployment
|
||||||
|
In the most simple form, any kustomization in the path pointed to by '--path' will be picked up. Since we set it to '.', adding something should be as simple as dropping it into that folder.
|
||||||
|
|
||||||
|
```
|
||||||
|
❯ git clone ssh://git@git.tipsy.codes:2222/charles/flux-5pi5.git
|
||||||
|
❯ cd flux-5pi5
|
||||||
|
❯ cat <<EOF > nginx.yaml
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx-deployment
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: nginx
|
||||||
|
replicas: 2 # tells deployment to run 2 pods matching the template
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx:1.14.2
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
Then commit, push, and reconcile:
|
||||||
|
```
|
||||||
|
❯ git add .
|
||||||
|
❯ git commit -am 'add: nginx deployment'
|
||||||
|
[main e1e40fb] add: nginx deployment
|
||||||
|
1 file changed, 19 insertions(+)
|
||||||
|
create mode 100644 nginx.yaml
|
||||||
|
❯ git push
|
||||||
|
** WARNING: connection is not using a post-quantum key exchange algorithm.
|
||||||
|
** This session may be vulnerable to "store now, decrypt later" attacks.
|
||||||
|
** The server may need to be upgraded. See https://openssh.com/pq.html
|
||||||
|
Enumerating objects: 4, done.
|
||||||
|
Counting objects: 100% (4/4), done.
|
||||||
|
Delta compression using up to 20 threads
|
||||||
|
Compressing objects: 100% (3/3), done.
|
||||||
|
Writing objects: 100% (3/3), 478 bytes | 478.00 KiB/s, done.
|
||||||
|
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
|
||||||
|
remote: . Processing 1 references
|
||||||
|
remote: Processed 1 references in total
|
||||||
|
To ssh://git.tipsy.codes:2222/charles/flux-5pi5.git
|
||||||
|
43161d8..e1e40fb main -> main
|
||||||
|
```
|
||||||
|
|
||||||
|
If you are impatient, you can trigger a reconciliation with:
|
||||||
|
```
|
||||||
|
flux reconcile source git flux-system
|
||||||
|
```
|
||||||
|
Watch it rollout with:
|
||||||
|
```
|
||||||
|
watch flux get all -A
|
||||||
|
```
|
||||||
|
Then you should be good to go!
|
||||||
|
```
|
||||||
|
❯ kubectl get pods
|
||||||
|
NAME READY STATUS RESTARTS AGE
|
||||||
|
nginx-deployment-647677fc66-cltgn 1/1 Running 0 6m31s
|
||||||
|
nginx-deployment-647677fc66-r6lxj 1/1 Running 0 6m31s
|
||||||
|
```
|
||||||
|
## Some simple things to make it better
|
||||||
|
### Use kustomizations
|
||||||
|
If we use kustomizations, we can track the reconciliation of sets of things.
|
||||||
|
|
||||||
|
Here is a simple example:
|
||||||
|
```
|
||||||
|
❯ head -n 99999 nginx.yaml nginx/*
|
||||||
|
==> nginx.yaml <==
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: nginx-kustomization
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
interval: 10m
|
||||||
|
path: "./nginx"
|
||||||
|
prune: true
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux-system
|
||||||
|
targetNamespace: default
|
||||||
|
wait: true
|
||||||
|
|
||||||
|
==> nginx/deployment.yaml <==
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx-deployment
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: nginx
|
||||||
|
replicas: 2 # tells deployment to run 2 pods matching the template
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx:1.14.2
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
|
||||||
|
==> nginx/kustomization.yaml <==
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: default
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
```
|
||||||
|
The first file (`nginx.yaml`) tells Flux to look into a specific folder, with an update interval and some other settings. The other files are the kustomization; check the Kubernetes docs for that.
|
||||||
@@ -4,6 +4,10 @@ If you are interested in hosting anything, please reach out :). If I you don't k
|
|||||||
|
|
||||||
I also have 5pi5, a Raspberry Pi 5 (16 GiB) that I use to host smaller applications.
|
I also have 5pi5, a Raspberry Pi 5 (16 GiB) that I use to host smaller applications.
|
||||||
|
|
||||||
|
Learnings:
|
||||||
|
|
||||||
|
- [[Simple Flux]]
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
The very strong ARM machine (aka, machop) runs k3s. This allows me to store my configurations in FluxCD, kept in a Git repo. Very helpful in terms of my ability to work on one project a time, when tipsy.
|
The very strong ARM machine (aka, machop) runs k3s. This allows me to store my configurations in FluxCD, kept in a Git repo. Very helpful in terms of my ability to work on one project a time, when tipsy.
|
||||||
|
|||||||
Reference in New Issue
Block a user