fix(bootstrap): add systemd-networkd DHCP, standalone flux install, non-root kubeconfig, and clean cluster kustomization (#29)
### Summary of Changes 1. **Systemd-Networkd DHCP & Base System**: - Added `/etc/systemd/network/10-eth.network` with `Name=eth* en*` and `DHCP=yes`. - Enabled `systemd-networkd` and `systemd-resolved` so all ethernet interfaces get DHCP automatically on first boot. - Added `git` package to base image. 2. **Flux v2 Standalone Installation**: - Replaced `kubectl apply -k` with standalone `kubectl apply -f https://github.com/fluxcd/flux2/releases/download/v2.4.0/install.yaml` so Flux installs in 2 seconds without git dependencies. 3. **Kubectl Access for Non-Root Users**: - Copies `/etc/rancher/k3s/k3s.yaml` into `/home/<user>/.kube/config` with `0600` permissions and proper user ownership. 4. **Cluster Kustomization Cleanliness**: - Removed self-referential `- flux-system` from `ci/k8s/clusters/production/kustomization.yaml`.
This commit is contained in:
1 parent
342f0071f6
commit
082e33d530
3 files changed
+26
-3
No files matched your search
@@ -161,7 +161,18 @@ write_files:
|
||||
fi
|
||||
|
||||
echo "=== [Bootstrap] Installing Flux Operator / Custom Resources ==="
|
||||
kubectl apply -k https://github.com/fluxcd/flux2/manifests/install?ref=v2.4.0 || true
|
||||
kubectl apply -f https://github.com/fluxcd/flux2/releases/download/v2.4.0/install.yaml
|
||||
|
||||
echo "=== [Bootstrap] Setting up Kubectl access for non-root users ==="
|
||||
for home_dir in /home/*; do
|
||||
if [ -d "$home_dir" ]; then
|
||||
user_name=$(basename "$home_dir")
|
||||
mkdir -p "$home_dir/.kube"
|
||||
cp /etc/rancher/k3s/k3s.yaml "$home_dir/.kube/config"
|
||||
chown -R "$user_name:$user_name" "$home_dir/.kube"
|
||||
chmod 600 "$home_dir/.kube/config"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "=== [Bootstrap] Applying initial GitOps root sync ==="
|
||||
kubectl apply -f - << 'EOF_GITOPS'
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- flux-system
|
||||
- ../../base/namespaces
|
||||
- ../../infrastructure/cert-manager
|
||||
- ../../infrastructure/networking
|
||||
|
||||
@@ -16,6 +16,7 @@ apt-get install -y --no-install-recommends \
|
||||
unattended-upgrades \
|
||||
curl \
|
||||
ca-certificates \
|
||||
git \
|
||||
tar \
|
||||
gzip
|
||||
|
||||
@@ -53,9 +54,21 @@ EOF
|
||||
# Configure cloud-init to support all standard cloud datasources (OpenStack, Ec2, NoCloud, ConfigDrive)
|
||||
cat << 'EOF' > /etc/cloud/cloud.cfg.d/99-cloud-init.cfg
|
||||
datasource_list: [ NoCloud, ConfigDrive, OpenStack, Ec2, None ]
|
||||
disable_vm_template: false
|
||||
EOF
|
||||
|
||||
# Ensure DHCP on eth0
|
||||
# Ensure automatic DHCP via systemd-networkd and ifupdown
|
||||
mkdir -p /etc/systemd/network
|
||||
cat << 'EOF' > /etc/systemd/network/10-eth.network
|
||||
[Match]
|
||||
Name=eth* en*
|
||||
|
||||
[Network]
|
||||
DHCP=yes
|
||||
EOF
|
||||
systemctl enable systemd-networkd systemd-resolved || true
|
||||
|
||||
# Ensure DHCP on eth0 for legacy ifupdown
|
||||
mkdir -p /etc/network/interfaces.d
|
||||
cat << 'EOF' > /etc/network/interfaces.d/eth0
|
||||
auto eth0
|
||||
|
||||
Reference in new issue
Block a user