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

Improve cluster-template so to use some options #43

Merged
merged 3 commits into from
Jul 19, 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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export NODE_URL=node.ssh.url:22
export NODE_USER=node-ssh-user
export NODE_PASSWORD=node-ssh-password

# generate manifests
clusterctl generate cluster cappx-test --infrastructure=proxmox:v0.2.2 --config https://raw.githubusercontent.com/sp-yduck/cluster-api-provider-proxmox/main/clusterctl.yaml > cappx-test.yaml
# generate manifests (available flags: --target-namespace, --kubernetes-version, --worker-machine-count)
clusterctl generate cluster cappx-test --worker-machine-count=3 --infrastructure=proxmox:v0.2.2 --config https://raw.githubusercontent.com/sp-yduck/cluster-api-provider-proxmox/main/clusterctl.yaml > cappx-test.yaml

# inspect and edit
vi cappx-test.yaml
Expand Down Expand Up @@ -86,8 +86,8 @@ CAPPX is tested with `pve-manager/7.4-3/9002ab8a (running kernel: 5.15.102-1-pve

### Cluster API

| | Cluster API v1alpha4 | Cluster API v1beta1 |
| --------------------- | :------------------: | :-----------------: |
| | Cluster API v1alpha4 | Cluster API v1beta1 |
| ---------------------- | :------------------: | :-----------------: |
| CAPPX v1beta1 `(v0.x)` | ? | ✓ |

### ControlPlane & Bootstrap provider
Expand Down
93 changes: 79 additions & 14 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: Cluster
metadata:
name: "${CLUSTER_NAME}"
namespace: "${NAMESPACE}"
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
spec:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
Expand All @@ -23,6 +25,8 @@ kind: ProxmoxCluster
metadata:
name: "${CLUSTER_NAME}"
namespace: "${NAMESPACE}"
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
spec:
controlPlaneEndpoint:
host: "${CONTROLPLANE_HOST}"
Expand All @@ -46,6 +50,8 @@ kind: KubeadmControlPlane
metadata:
name: "${CLUSTER_NAME}"
namespace: "${NAMESPACE}"
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
spec:
kubeadmConfigSpec:
clusterConfiguration:
Expand All @@ -61,7 +67,7 @@ spec:
networking:
dnsDomain: cluster.local
serviceSubnet: 10.96.0.0/12
podSubnet: 10.98.0.0/16
podSubnet: 10.244.0.0/16
initConfiguration:
localAPIEndpoint:
advertiseAddress: "${CONTROLPLANE_HOST}"
Expand All @@ -81,7 +87,7 @@ spec:
kind: ProxmoxMachineTemplate
name: ${CLUSTER_NAME}-controlplane
replicas: 1
version: v1.26.5
version: ${KUBERNETES_VERSION:=v1.27.3}

---

Expand All @@ -90,6 +96,8 @@ kind: ProxmoxMachineTemplate
metadata:
name: ${CLUSTER_NAME}-controlplane
namespace: "${NAMESPACE}"
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
spec:
template:
spec:
Expand Down Expand Up @@ -140,9 +148,9 @@ spec:
- "mkdir -p /opt/cni/bin"
- curl -L "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz" | tar -C "/opt/cni/bin" -xz
- curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.27.0/crictl-v1.27.0-linux-amd64.tar.gz" | tar -C "/usr/local/bin" -xz
- curl -L --remote-name-all https://dl.k8s.io/release/v1.26.5/bin/linux/amd64/kubeadm -o /usr/local/bin/kubeadm
- curl -L --remote-name-all https://dl.k8s.io/release/${KUBERNETES_VERSION:=v1.27.3}/bin/linux/amd64/kubeadm -o /usr/local/bin/kubeadm
- chmod +x /usr/local/bin/kubeadm
- curl -L --remote-name-all https://dl.k8s.io/release/v1.26.5/bin/linux/amd64/kubelet -o /usr/local/bin/kubelet
- curl -L --remote-name-all https://dl.k8s.io/release/${KUBERNETES_VERSION:=v1.27.3}/bin/linux/amd64/kubelet -o /usr/local/bin/kubelet
- chmod +x /usr/local/bin/kubelet
- curl -sSL "https://raw.githubusercontent.com/kubernetes/release/v0.15.1/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service" | sed "s:/usr/bin:/usr/local/bin:g" | tee /etc/systemd/system/kubelet.service
- mkdir -p /etc/systemd/system/kubelet.service.d
Expand All @@ -155,34 +163,44 @@ apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: ${CLUSTER_NAME}-md-0
namespace: ${NAMESPACE}
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
spec:
clusterName: "${CLUSTER_NAME}"
replicas: 1
replicas: ${WORKER_MACHINE_COUNT}
selector:
matchLabels: null
matchLabels: {}
template:
spec:
clusterName: ${CLUSTER_NAME}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: worker
clusterName: "${CLUSTER_NAME}-md-0"
name: ${CLUSTER_NAME}-md-0
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: ProxmoxMachineTemplate
name: ${CLUSTER_NAME}-md-0
version: v1.26.5
version: ${KUBERNETES_VERSION:=v1.27.3}

---

apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
namespace: ${NAMESPACE}
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
spec:
template:
spec:
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
cloud-provider: external
postKubeadmCommands:
- "curl -L https://dl.k8s.io/release/v1.27.3/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl"
- "chmod +x /usr/local/bin/kubectl"
Expand All @@ -194,14 +212,59 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: ProxmoxMachineTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
namespace: ${NAMESPACE}
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
spec:
template:
spec:
image:
url: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-disk-kvm.img
hardware:
cpu: 4
memory: 4096
checksum: 86e996f35732d26cd8b0888c46c4309d4d3b04eb6980378cf82b4d3eb2796549
checksumType: sha256
cloudInit:
user:
packages:
- socat
- conntrack
writeFiles:
- path: /etc/modules-load.d/k8s.conf
owner: root:root
permissions: "0640"
content: overlay\nbr_netfilter
- path: /etc/sysctl.d/k8s.conf
owner: root:root
permissions: "0640"
content: |
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
runCmd:
- "modprobe overlay"
- "modprobe br_netfilter"
- "sysctl --system"
- "mkdir -p /usr/local/bin"
- curl -L "https://github.com/containerd/containerd/releases/download/v1.7.2/containerd-1.7.2-linux-amd64.tar.gz" | tar Cxvz "/usr/local"
- curl -L "https://raw.githubusercontent.com/containerd/containerd/main/containerd.service" -o /etc/systemd/system/containerd.service
- "mkdir -p /etc/containerd"
- "containerd config default > /etc/containerd/config.toml"
- "sed 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml -i"
- "systemctl daemon-reload"
- "systemctl enable --now containerd"
- "mkdir -p /usr/local/sbin"
- curl -L "https://github.com/opencontainers/runc/releases/download/v1.1.7/runc.amd64" -o /usr/local/sbin/runc
- "chmod 755 /usr/local/sbin/runc"
- "mkdir -p /opt/cni/bin"
- curl -L "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz" | tar -C "/opt/cni/bin" -xz
- curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.27.0/crictl-v1.27.0-linux-amd64.tar.gz" | tar -C "/usr/local/bin" -xz
- curl -L --remote-name-all https://dl.k8s.io/release/${KUBERNETES_VERSION:=v1.27.3}/bin/linux/amd64/kubeadm -o /usr/local/bin/kubeadm
- chmod +x /usr/local/bin/kubeadm
- curl -L --remote-name-all https://dl.k8s.io/release/${KUBERNETES_VERSION:=v1.27.3}/bin/linux/amd64/kubelet -o /usr/local/bin/kubelet
- chmod +x /usr/local/bin/kubelet
- curl -sSL "https://raw.githubusercontent.com/kubernetes/release/v0.15.1/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service" | sed "s:/usr/bin:/usr/local/bin:g" | tee /etc/systemd/system/kubelet.service
- mkdir -p /etc/systemd/system/kubelet.service.d
- curl -sSL "https://raw.githubusercontent.com/kubernetes/release/v0.15.1/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf" | sed "s:/usr/bin:/usr/local/bin:g" | tee /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
- "systemctl enable kubelet.service"

---

Expand All @@ -216,17 +279,19 @@ kind: Secret
metadata:
name: "${CLUSTER_NAME}"
namespace: "${NAMESPACE}"
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
type: Opaque

---

apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: ${CLUSTER_NAME}-crs-0
namespace: "${NAMESPACE}"
labels:
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}'
name: ${CLUSTER_NAME}-crs-1
namespace: "${NAMESPACE}"
spec:
clusterSelector:
matchLabels:
Expand Down