Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (flux) add flux bundle #53

Merged
merged 8 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 72 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<h1 align="center">
<br>
<img width="184" alt="kairos-white-column 5bc2fe34" src="https://user-images.githubusercontent.com/2420543/193010398-72d4ba6e-7efe-4c2e-b7ba-d3a826a55b7d.png">
Expand All @@ -10,7 +9,6 @@

<hr>


Welcome to the community-bundles repository! This repository builds and pushes Kairos community bundles that can be consumed by Kairos core or derivative images (such as [provider-kairos](https://github.com/kairos-io/provider-kairos) ) to extend Kairos configurations and settings, and to add cloud-config keywords.

Please note that these community bundles are not officially supported and are provided on a best-effort basis by the community.
Expand All @@ -36,29 +34,29 @@ To use a community bundle, you can load it with the bundles block in the Kairos

```yaml
bundles:
- targets:
- run://quay.io/kairos/community-bundles:<bundle-name>
- targets:
- run://quay.io/kairos/community-bundles:<bundle-name>
```

Here is an example of how you might use a community bundle in a Kairos core image:

```yaml
#cloud-config
install:
device: "auto"
auto: true
reboot: true
image: "docker:quay.io/kairos/kairos-opensuse:v1.4.0-k3sv1.26.0-k3s1"
device: "auto"
auto: true
reboot: true
image: "docker:quay.io/kairos/kairos-opensuse:v1.4.0-k3sv1.26.0-k3s1"

users:
- name: "kairos"
passwd: "kairos"
ssh_authorized_keys:
- ...
- name: "kairos"
passwd: "kairos"
ssh_authorized_keys:
- ...

bundles:
- targets:
- run://quay.io/kairos/community-bundles:kubevirt
- targets:
- run://quay.io/kairos/community-bundles:kubevirt

k3s:
enabled: true
Expand All @@ -77,8 +75,8 @@ To configure the bundle, use the `calico` block:

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:calico_latest
- targets:
- run://quay.io/kairos/community-bundles:calico_latest

# Specify calico settings
calico:
Expand All @@ -94,7 +92,7 @@ calico:
version: 3.25.0
```

Note that specifying `values` and `version` are optional. Specifying `values` allows you to
Note that specifying `values` and `version` are optional. Specifying `values` allows you to
[customize the Helm Chart](https://docs.tigera.io/calico/latest/getting-started/kubernetes/helm#customize-the-helm-chart).

### Cert-manager
Expand All @@ -108,14 +106,45 @@ The bundle does add a `certManager` block, that allow to change the version (cur

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:cert-manager_latest
- targets:
- run://quay.io/kairos/community-bundles:cert-manager_latest

# Specify cert-manager settings
certManager:
version: v1.11.0
```

### Flux

This installs [FluxCD](https://fluxcd.io/flux/cmd/flux_bootstrap/) and supports
automatically bootstrapping the cluster. Only one node will do the bootstrap.
It will time out after trying for 30 minutes and it requires `systemd`.

```yaml
#cloud-config
tyzbit marked this conversation as resolved.
Show resolved Hide resolved

k3s:
enabled: true

bundles:
- targets:
- run://quay.io/kairos/community-bundles:flux_latest

# Specify command-line arguments as keys under a key of `bitbucket_server`,
# `git`, `github` or `gitlab` for the provider to boostrap from. An example for
# `github` is shown below.
flux:
env:
# Override default $KUBECONFIG of /etc/rancher/k3s/k3s.yaml if needed
# KUBECONFIG: /home/csagan/.kube/config
GITHUB_TOKEN: abcde1234
github:
owner: csagan
repository: fleet-infra
path: clusters/cosmos
components-extra: image-reflector-controller,image-automation-controller
```

### Kairos

The Kairos bundle deploys the [Kairos helm-charts](https://github.com/kairos-io/helm-charts). It installs the `kairos-crds` chart, and allows to enable [entangle-proxy](https://kairos.io/docs/reference/entangle/), [osbuilder](https://kairos.io/docs/advanced/build/), and [entangle](https://kairos.io/docs/reference/entangle/).
Expand All @@ -127,8 +156,8 @@ By default the bundle will install only the CRDs, components needs to be explici

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:kairos_latest
- targets:
- run://quay.io/kairos/community-bundles:kairos_latest

# Specify kairos bundle setting
kairos:
Expand All @@ -154,33 +183,31 @@ To configure the bundle, use the `kyverno` block:

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:kyverno_latest
- targets:
- run://quay.io/kairos/community-bundles:kyverno_latest

# Specify kyverno settings
kyverno:
values:
....
values: ....
version: ...
```

Note that specifying `values` and `version` are optional. Specifying `values` allows you to
Note that specifying `values` and `version` are optional. Specifying `values` allows you to
[customize the Helm Chart](https://github.com/kyverno/kyverno/blob/main/charts/kyverno/values.yaml).

### Kubevirt

The Kubevirt bundle deploys [Kubevirt](https://github.com/kubevirt/kubevirt) and optionally [kubevirt-manager](https://kubevirt-manager.io/)


The bundle does add a `kubevirt` block, that allow to enable `kubevirt-manager`:

```yaml
#cloud-config

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:kubevirt_latest
- targets:
- run://quay.io/kairos/community-bundles:kubevirt_latest

# Specify kubevirt settings
kubevirt:
Expand All @@ -198,8 +225,8 @@ To configure the bundle, use the `longhorn` block:

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:longhorn_latest
- targets:
- run://quay.io/kairos/community-bundles:longhorn_latest

# Specify longhorn settings
longhorn:
Expand All @@ -209,7 +236,7 @@ longhorn:
version: 1.4.0
```

Note that specifying `values` and `version` are optional. Specifying `values` allows you to
Note that specifying `values` and `version` are optional. Specifying `values` allows you to
[customize the Helm Chart](https://longhorn.io/docs/latest/advanced-resources/deploy/customizing-default-settings/#using-helm).

### MetalLB
Expand All @@ -223,8 +250,8 @@ The bundle does add a `metallb` block, that allow to set up the MetalLB version

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:metallb_latest
- targets:
- run://quay.io/kairos/community-bundles:metallb_latest

# Specify metallb settings
metallb:
Expand All @@ -239,20 +266,20 @@ Note, you might want to disable the default LoadBalancer of k3s, a full example

hostname: kairoslab-{{ trunc 4 .MachineID }}
users:
- name: kairos
ssh_authorized_keys:
# Add your github user here!
- github:mudler
- name: kairos
ssh_authorized_keys:
# Add your github user here!
- github:mudler

k3s:
enable: true
args:
- --disable=servicelb
- --disable=servicelb

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:metallb_latest
- targets:
- run://quay.io/kairos/community-bundles:metallb_latest

# Specify metallb settings
metallb:
Expand All @@ -271,8 +298,8 @@ To configure the bundle, use the `multus` block:
```yaml
# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:multus_latest
- targets:
- run://quay.io/kairos/community-bundles:multus_latest

# Specify multus settings. Here are the defaults:
multus:
Expand Down Expand Up @@ -326,8 +353,8 @@ The bundle does add a `suc` block, that allow to change the version:

# Specify the bundle to use
bundles:
- targets:
- run://quay.io/kairos/community-bundles:system-upgrade-controller_latest
- targets:
- run://quay.io/kairos/community-bundles:system-upgrade-controller_latest

# Specify system-upgrade-controller settings
suc:
Expand Down
19 changes: 19 additions & 0 deletions flux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM alpine as build
ENV VERSION=2.1.2
ENV CHECKSUM=61b360b50d6cfc34410730b1cebeb75f5eda2b484e47b9a083412f51ad56de68

ADD https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_amd64.tar.gz /tmp
RUN DOWNLOAD_FILE="/tmp/flux_${VERSION}_linux_amd64.tar.gz" && \
DOWNLOAD_CHECKSUM=$(sha256sum "${DOWNLOAD_FILE}" | awk '{print $1}') && \
if [[ ${DOWNLOAD_CHECKSUM} != ${CHECKSUM} ]]; then \
echo "Checksum does not match"; \
exit 1; \
fi && \
tar xzf "${DOWNLOAD_FILE}" -C / && \
rm "${DOWNLOAD_FILE}"

FROM scratch
COPY --from=build flux .
COPY flux-bootstrap.service .
COPY flux-bootstrap.sh .
COPY run.sh .
15 changes: 15 additions & 0 deletions flux/flux-bootstrap.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Bootstrap cluster with Flux
Documentation=https://github.com/kairos-io/community-bundles/blob/main/README.md#flux
After=k3s.service

[Service]
Type=oneshot
Restart=no
ExecStart=/usr/local/bin/flux-bootstrap.sh
User=root
Group=root
RemainAfterExit=yes

[Install]
WantedBy=k3s.service
Loading