Add bootstrapper base
This commit is contained in:
commit
88d112b47b
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.env
|
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Clank bootstrapper
|
||||||
|
|
||||||
|
- Links:
|
||||||
|
[preparations](https://github.com/syself/cluster-api-provider-hetzner/blob/main/docs/topics/preparation.md)
|
4
clusterapi/.gitignore
vendored
Executable file
4
clusterapi/.gitignore
vendored
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
variables.sh
|
||||||
|
keys/
|
||||||
|
manifest.json
|
||||||
|
output/
|
16
clusterapi/add-ccm.sh
Executable file
16
clusterapi/add-ccm.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
helm repo add syself https://charts.syself.com
|
||||||
|
helm repo update syself
|
||||||
|
|
||||||
|
CILIUM_VERSION=1.12.2
|
||||||
|
|
||||||
|
KUBECONFIG=$CAPH_WORKER_CLUSTER_KUBECONFIG helm upgrade --install ccm syself/ccm-hcloud --version 1.0.11 \
|
||||||
|
--namespace kube-system \
|
||||||
|
--set secret.name=hetzner \
|
||||||
|
--set secret.tokenKeyName=hcloud \
|
||||||
|
--set privateNetwork.enabled=false
|
13
clusterapi/add-cni.sh
Executable file
13
clusterapi/add-cni.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
helm repo add cilium https://helm.cilium.io/
|
||||||
|
|
||||||
|
CILIUM_VERSION=1.12.2
|
||||||
|
|
||||||
|
KUBECONFIG=$CAPH_WORKER_CLUSTER_KUBECONFIG helm upgrade --install cilium cilium/cilium --version "$CILIUM_VERSION" \
|
||||||
|
--namespace kube-system \
|
||||||
|
-f https://raw.githubusercontent.com/syself/cluster-api-provider-hetzner/main/templates/cilium/cilium.yaml
|
15
clusterapi/add-csi.sh
Executable file
15
clusterapi/add-csi.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
cat << EOF > output/csi-values.yaml
|
||||||
|
storageClasses:
|
||||||
|
- name: hcloud-volumes
|
||||||
|
defaultStorageClass: true
|
||||||
|
reclaimPolicy: Retain
|
||||||
|
EOF
|
||||||
|
|
||||||
|
KUBECONFIG=$CAPH_WORKER_CLUSTER_KUBECONFIG helm upgrade --install csi syself/csi-hcloud --version 0.2.0 \
|
||||||
|
--namespace kube-system -f output/csi-values.yaml
|
9
clusterapi/get-config.sh
Executable file
9
clusterapi/get-config.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
mkdir -p output/
|
||||||
|
|
||||||
|
clusterctl get kubeconfig "$CLUSTER_NAME" > $CAPH_WORKER_CLUSTER_KUBECONFIG
|
31
clusterapi/initialize-hetzner.sh
Executable file
31
clusterapi/initialize-hetzner.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
sleep 20
|
||||||
|
|
||||||
|
OUTPUT_TEMPLATE=/tmp/clusterapi/clank-management.yaml
|
||||||
|
|
||||||
|
rm -rf "/tmp/clusterapi/" || true
|
||||||
|
|
||||||
|
echo "templating management cluster"
|
||||||
|
mkdir -p /tmp/clusterapi/
|
||||||
|
clusterctl generate cluster "$CLUSTER_NAME" > "$OUTPUT_TEMPLATE"
|
||||||
|
|
||||||
|
nvim /tmp/clusterapi/clank-management.yaml
|
||||||
|
|
||||||
|
read -p "Continue? (N/y) " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||||
|
then
|
||||||
|
echo "aborting"
|
||||||
|
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
kubectl apply -f "$OUTPUT_TEMPLATE"
|
||||||
|
|
||||||
|
kubectl wait --for=jsonpath='{.status.phase}'=Provisioned "cluster/$CLUSTER_NAME"
|
||||||
|
|
||||||
|
echo "cluster has been provisioned"
|
7
clusterapi/initialize.sh
Executable file
7
clusterapi/initialize.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
rm -rf output
|
||||||
|
|
||||||
|
clusterctl init --core cluster-api --bootstrap kubeadm --control-plane kubeadm --infrastructure hetzner
|
15
clusterapi/latest-releases.sh
Executable file
15
clusterapi/latest-releases.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PROVIDER_OWNER=syself
|
||||||
|
PROVIDER_REPO=cluster-api-provider-hetzner
|
||||||
|
PROVIDER="$PROVIDER_OWNER/$PROVIDER_REPO"
|
||||||
|
|
||||||
|
echo "listing newest releases (includes pre-releases)"
|
||||||
|
gh release list -R "$PROVIDER"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "view the most recent release"
|
||||||
|
newest=$(gh release list -R syself/cluster-api-provider-hetzner -L 1 | tail -n +1 | awk '{print $1}')
|
||||||
|
gh release view "$newest" -R "$PROVIDER"
|
11
clusterapi/load-secret.sh
Executable file
11
clusterapi/load-secret.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
echo "loading HCLOUD_TOKEN"
|
||||||
|
|
||||||
|
kubectl create secret generic hetzner --from-literal=hcloud=$HCLOUD_TOKEN
|
||||||
|
|
||||||
|
kubectl patch secret hetzner -p '{"metadata":{"labels":{"clusterctl.cluster.x-k8s.io/move":""}}}'
|
17
clusterapi/move-cluster.sh
Executable file
17
clusterapi/move-cluster.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
echo "initializing cluster api in management cluster"
|
||||||
|
export KUBECONFIG=output/workload-kubeconfig
|
||||||
|
|
||||||
|
clusterctl init --core cluster-api --bootstrap kubeadm --control-plane kubeadm --infrastructure hetzner
|
||||||
|
|
||||||
|
echo "switching back to helm"
|
||||||
|
export KUBECONFIG=~/.kube/config
|
||||||
|
|
||||||
|
clusterctl move --to-kubeconfig $CAPH_WORKER_CLUSTER_KUBECONFIG
|
||||||
|
|
||||||
|
echo "move done"
|
27
clusterapi/pack-image.sh
Executable file
27
clusterapi/pack-image.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
RELEASE_VERSION="1.0.0-beta.10"
|
||||||
|
TEMPLATE_VERSION=$KUBERNETES_VERSION-ubuntu-22-04-containerd
|
||||||
|
PROVIDER_OWNER=syself
|
||||||
|
PROVIDER_REPO=cluster-api-provider-hetzner
|
||||||
|
OUTPUT_DIR=/tmp/clusterapi
|
||||||
|
|
||||||
|
PROVIDER="$PROVIDER_OWNER/$PROVIDER_REPO"
|
||||||
|
OUTPUT_FILE=output.tar.gz
|
||||||
|
OUTPUT="$OUTPUT_DIR/$OUTPUT_FILE"
|
||||||
|
|
||||||
|
rm -rf "$OUTPUT_DIR" || true
|
||||||
|
|
||||||
|
gh release download "v$RELEASE_VERSION" \
|
||||||
|
-R "$PROVIDER" \
|
||||||
|
--archive tar.gz \
|
||||||
|
-O "$OUTPUT"
|
||||||
|
|
||||||
|
(cd $OUTPUT_DIR ; tar -xzf "$OUTPUT_FILE")
|
||||||
|
|
||||||
|
|
||||||
|
packer build "$OUTPUT_DIR/$PROVIDER_REPO-$RELEASE_VERSION/templates/node-image/$TEMPLATE_VERSION/image.json"
|
2
flux/.gitignore
vendored
Executable file
2
flux/.gitignore
vendored
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
keys/
|
||||||
|
variables.sh
|
18
flux/bootstrap.sh
Executable file
18
flux/bootstrap.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. variables.sh
|
||||||
|
|
||||||
|
#eval "$(ssh-agent -s)"
|
||||||
|
#ssh-add keys/id_clank_management
|
||||||
|
|
||||||
|
flux bootstrap git \
|
||||||
|
--url="https://$MANAGEMENT_GITOPS_REPO" \
|
||||||
|
--branch="main" \
|
||||||
|
--path="clusters/clank-management" \
|
||||||
|
--kubeconfig="$CAPH_WORKER_CLUSTER_KUBECONFIG" \
|
||||||
|
--username="kjuulh" \
|
||||||
|
--password="$GITEA_TOKEN" \
|
||||||
|
--token-auth=true
|
||||||
|
|
7
flux/generate-keypair.sh
Executable file
7
flux/generate-keypair.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mkdir -p keys/
|
||||||
|
|
||||||
|
ssh-keygen -t ed25519 -C "clank_management@kjuulh.io" -f "keys/id_clank_management"
|
16
kind/create-kind.sh
Executable file
16
kind/create-kind.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
. kind.sh
|
||||||
|
|
||||||
|
kind create cluster --name "$CLUSTER_NAME"
|
||||||
|
|
||||||
|
until kubectl cluster-info --context "kind-$CLUSTER_NAME"
|
||||||
|
do
|
||||||
|
echo "waiting for cluster to come online..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "checking nodes"
|
||||||
|
kubectl get nodes
|
||||||
|
|
||||||
|
kubectl wait --for=condition=ready nodes/clank-boostrap-control-plane
|
5
kind/delete-kind.sh
Executable file
5
kind/delete-kind.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. kind.sh
|
||||||
|
|
||||||
|
kind delete cluster --name "$CLUSTER_NAME"
|
3
kind/kind.sh
Executable file
3
kind/kind.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CLUSTER_NAME=clank-boostrap
|
37
run.sh
Executable file
37
run.sh
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "setting up kind"
|
||||||
|
pushd kind
|
||||||
|
|
||||||
|
./delete-kind.sh || true
|
||||||
|
./create-kind.sh
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
|
echo "setting up boostrap cluster api"
|
||||||
|
|
||||||
|
pushd clusterapi
|
||||||
|
|
||||||
|
./initialize.sh
|
||||||
|
./load-secret.sh
|
||||||
|
./initialize-hetzner.sh
|
||||||
|
|
||||||
|
./get-config.sh
|
||||||
|
./add-cni.sh
|
||||||
|
./add-ccm.sh
|
||||||
|
./add-csi.sh
|
||||||
|
./move-clusters.sh
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
|
echo "installing flux"
|
||||||
|
|
||||||
|
pushd flux
|
||||||
|
|
||||||
|
./bootstrap.sh
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user