-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignition service for bootstrapping kubeadm and kubelet. (#8)
* Ignition service for bootstrapping kubeadm and kubelet. * Provide containerd config. * Deploy more stuff from Ansible. * Typo * Install as binary, GPG does not work easily without tty.
- Loading branch information
Showing
12 changed files
with
222 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
egress: | ||
- comment: allow outgoing traffic for HTTP and HTTPS and DNS | ||
ports: | ||
- 443 | ||
- 80 | ||
- 53 | ||
protocol: TCP | ||
to: | ||
- 0.0.0.0/0 | ||
- comment: allow outgoing DNS and NTP via UDP | ||
ports: | ||
- 53 | ||
- 123 | ||
protocol: UDP | ||
to: | ||
- 0.0.0.0/0 | ||
ingress: | ||
- comment: allow incoming HTTPS to kube-apiserver | ||
ports: | ||
- 443 | ||
protocol: TCP | ||
from: | ||
- 0.0.0.0/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
capi-lab/roles/firewall-controller-manager/defaults/main.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
firewall_controller_manager_namespace: "firewall-controller-manager" |
29 changes: 29 additions & 0 deletions
29
capi-lab/roles/firewall-controller-manager/tasks/main.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Gather release versions | ||
setup_yaml: | ||
|
||
- name: Create namespace | ||
k8s: | ||
definition: | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: "{{ firewall_controller_manager_namespace }}" | ||
labels: | ||
name: "{{ firewall_controller_manager_namespace }}" | ||
|
||
- name: Deploy firewall-controller-manager CRDs | ||
k8s: | ||
definition: "{{ lookup('url', 'https://raw.githubusercontent.com/metal-stack/firewall-controller-manager/refs/tags/' + firewall_controller_manager_image_tag + '/config/crds/' + item, split_lines=False) }}" | ||
namespace: "{{ firewall_controller_manager_namespace }}" | ||
loop: | ||
- firewall.metal-stack.io_firewalldeployments.yaml | ||
- firewall.metal-stack.io_firewallmonitors.yaml | ||
- firewall.metal-stack.io_firewalls.yaml | ||
- firewall.metal-stack.io_firewallsets.yaml | ||
|
||
# - name: Deploy firewall-controller-manager | ||
# k8s: | ||
# definition: | ||
|
||
# namespace: "{{ firewall_controller_manager_namespace }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
prometheus_namespace: prometheus | ||
prometheus_helm_chart_version: "66.2.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: Create namespace | ||
k8s: | ||
definition: | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: "{{ prometheus_namespace }}" | ||
labels: | ||
name: "{{ prometheus_namespace }}" | ||
|
||
- name: Deploy Prometheus | ||
include_role: | ||
name: ansible-common/roles/helm-chart | ||
vars: | ||
helm_chart: kube-prometheus-stack | ||
helm_repo: https://prometheus-community.github.io/helm-charts | ||
helm_force: false | ||
helm_release_name: kube-prometheus-stack | ||
helm_target_namespace: "{{ prometheus_namespace }}" | ||
helm_chart_version: "{{ prometheus_helm_chart_version }}" | ||
# helm_value_file_template: values.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: Cluster | ||
metadata: | ||
name: metal-test | ||
spec: | ||
clusterNetwork: | ||
pods: | ||
cidrBlocks: ["192.168.0.0/16"] | ||
controlPlaneRef: | ||
apiVersion: controlplane.cluster.x-k8s.io/v1beta1 | ||
kind: KubeadmControlPlane | ||
name: metal-test-controlplane | ||
infrastructureRef: | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 | ||
kind: MetalStackCluster | ||
name: metal-test | ||
--- | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 | ||
kind: MetalStackCluster | ||
metadata: | ||
name: metal-test | ||
spec: | ||
projectID: 00000000-0000-0000-0000-000000000001 | ||
partition: mini-lab | ||
firewall: | ||
size: v1-small-x86 | ||
image: firewall-ubuntu-3.0 | ||
networks: | ||
- internet-mini-lab | ||
--- | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 | ||
kind: MetalStackMachineTemplate | ||
metadata: | ||
name: metal-test-controlplane | ||
spec: | ||
template: | ||
spec: | ||
image: ubuntu-24.04 | ||
size: v1-small-x86 | ||
--- | ||
kind: KubeadmControlPlane | ||
apiVersion: controlplane.cluster.x-k8s.io/v1beta1 | ||
metadata: | ||
name: metal-test-controlplane | ||
spec: | ||
replicas: 1 | ||
version: v1.30.6 | ||
machineTemplate: | ||
nodeDrainTimeout: 10m | ||
infrastructureRef: | ||
kind: MetalStackMachineTemplate | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 | ||
name: metal-test-controlplane | ||
kubeadmConfigSpec: | ||
format: ignition | ||
clusterConfiguration: | ||
controlPlaneEndpoint: 203.0.113.129:443 | ||
initConfiguration: | ||
localAPIEndpoint: | ||
advertiseAddress: 10.0.0.2 | ||
bindPort: 443 | ||
nodeRegistration: {} | ||
joinConfiguration: | ||
controlPlane: {} | ||
nodeRegistration: {} | ||
ignition: | ||
containerLinuxConfig: | ||
additionalConfig: | | ||
systemd: | ||
units: | ||
- name: cluster-api-init.service | ||
enable: true | ||
contents: |- | ||
[Unit] | ||
Description=Prepares the node for bootstrapping with cluster-api kubeadm | ||
Before=kubeadm.service | ||
After=network-online.target | ||
Wants=network-online.target | ||
[Service] | ||
Type=oneshot | ||
Restart=on-failure | ||
RestartSec=5 | ||
StartLimitBurst=0 | ||
EnvironmentFile=/etc/environment | ||
ExecStart=/var/lib/cluster-api-init/bootstrap.sh | ||
[Install] | ||
WantedBy=multi-user.target | ||
files: | ||
- path: /var/lib/cluster-api-init/bootstrap.sh | ||
owner: "root:root" | ||
permissions: "0744" | ||
content: | | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
set +x | ||
apt update | ||
apt install conntrack | ||
CNI_PLUGINS_VERSION="v1.3.0" | ||
DEST="/opt/cni/bin" | ||
mkdir -p "$DEST" | ||
curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_PLUGINS_VERSION}/cni-plugins-linux-amd64-${CNI_PLUGINS_VERSION}.tgz" | sudo tar -C "$DEST" -xz | ||
RELEASE="v1.30.6" | ||
cd /usr/local/bin | ||
sudo curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/amd64/{kubeadm,kubelet,kubectl} | ||
sudo chmod +x {kubeadm,kubelet,kubectl} | ||
RELEASE_VERSION="v0.16.2" | ||
curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/krel/templates/latest/kubelet/kubelet.service" | sed "s:/usr/bin:/usr/local/bin:g" | sudo tee /usr/lib/systemd/system/kubelet.service | ||
sudo mkdir -p /usr/lib/systemd/system/kubelet.service.d | ||
curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf" | sed "s:/usr/bin:/usr/local/bin:g" | sudo tee /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf | ||
systemctl enable kubelet.service | ||
- path: /etc/containerd/config.toml | ||
owner: "root:root" | ||
permissions: "0644" | ||
content: | | ||
disabled_plugins = [] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters