-
Notifications
You must be signed in to change notification settings - Fork 0
(DON'T MERGE BEFORE v0.1.x ⚠️) feat: move to k3s from k3d - colony issues purposal #9
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
Draft
jairoFernandez
wants to merge
3
commits into
main
Choose a base branch
from
feat/k3s
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -45,38 +45,61 @@ update_apt() { | |
apt-get update | ||
} | ||
|
||
install_k3d() { | ||
local k3d_Version=$1 | ||
|
||
wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG="$k3d_version" bash | ||
} | ||
|
||
start_k3d() { | ||
echo "Creating the cluster..." | ||
k3d cluster create --network host --no-lb --k3s-arg "--disable=traefik,servicelb" --k3s-arg "--kube-apiserver-arg=feature-gates=MixedProtocolLBService=true" --host-pid-mode | ||
|
||
echo "Waiting for the cluster to be fully operational..." | ||
sleep 10 | ||
|
||
echo "Configuring kubeconfig..." | ||
mkdir -p ~/.kube/ | ||
|
||
k3d kubeconfig get -a > ~/.kube/config || echo "Failed to get kubeconfig" | ||
|
||
echo "Checking nodes..." | ||
until kubectl wait --for=condition=Ready nodes --all --timeout=600s; do | ||
echo "Waiting for nodes to be ready..." | ||
sleep 5 | ||
done | ||
start_k3s() { | ||
local k3s_version=$1 | ||
echo "Creating the cluster..." | ||
|
||
docker run -d --privileged --name ctrlplane-laptop \ | ||
-e K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml \ | ||
-e K3S_KUBECONFIG_MODE=666 \ | ||
-v "$(pwd):/output" \ | ||
-v k3s-server:/var/lib/rancher/k3s \ | ||
--tmpfs=/run --tmpfs=/var/run \ | ||
--network=host \ | ||
rancher/k3s:"$k3s_version" server \ | ||
--disable=traefik,servicelb \ | ||
--tls-san=ctrlplane-laptop \ | ||
--node-label="colony.konstruct.io/node-type=laptop" | ||
|
||
echo "Waiting for the cluster to be fully operational..." | ||
sleep 30 | ||
|
||
echo "Configuring kubeconfig..." | ||
mkdir -p ~/.kube/ | ||
|
||
cp ./kubeconfig.yaml ~/.kube/config || echo "Failed to get kubeconfig" | ||
sed -i 's/127.0.0.1/localhost/g' ~/.kube/config | ||
export KUBECONFIG=~/.kube/config | ||
cat ~/.kube/config | ||
jairoFernandez marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
if [ -f ./kubeconfig.yaml ]; then | ||
cp ./kubeconfig.yaml ~/.kube/config | ||
else | ||
echo "Failed to get kubeconfig: kubeconfig.yaml not found" | ||
exit 1 | ||
fi | ||
|
||
echo "Checking nodes..." | ||
until kubectl wait --for=condition=Ready nodes --all --timeout=600s; do | ||
echo "Waiting for nodes to be ready..." | ||
sleep 5 | ||
done | ||
|
||
echo "All nodes are ready." | ||
echo "Generating join token and storing it in a secret..." | ||
# docker exec -i ctrlplane-laptop k3s token create --print-join-command > token.txt (incompatible) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I consider to maintain this comment, just for informational purposes |
||
docker exec -i ctrlplane-laptop cat /var/lib/rancher/k3s/server/node-token > token.txt | ||
kubectl create secret -n kube-system generic k3s-join-token --from-file=token.txt | ||
} | ||
|
||
kubectl_for_vagrant_user() { | ||
runuser -l vagrant -c "mkdir -p ~/.kube/" | ||
runuser -l vagrant -c "k3d kubeconfig get -a > ~/.kube/config" | ||
echo "**********************************" | ||
runuser -l vagrant -c "mkdir -p /home/vagrant/.kube" | ||
cp ./kubeconfig.yaml /home/vagrant/.kube/config | ||
chown vagrant:vagrant /home/vagrant/.kube/config | ||
|
||
chmod 600 /home/vagrant/.kube/config | ||
echo 'export KUBECONFIG="/home/vagrant/.kube/config"' >> /home/vagrant/.bashrc | ||
echo "**********************************" | ||
} | ||
|
||
helm_install_tink_stack() { | ||
|
@@ -104,13 +127,13 @@ helm_install_tink_stack() { | |
|
||
configure_dnsmasq() { | ||
cat <<-EOF >/etc/dnsmasq.conf | ||
dhcp-range=10.0.10.100,10.0.10.200,255.255.255.0,12h | ||
#dhcp-option=option:router,172.31.0.1 | ||
dhcp-option=option:router,10.0.10.1 | ||
dhcp-option=option:dns-server,1.1.1.1 | ||
dhcp-authoritative | ||
interface=eth1 | ||
port=0 | ||
dhcp-range=10.0.10.100,10.0.10.200,255.255.255.0,12h | ||
#dhcp-option=option:router,172.31.0.1 | ||
dhcp-option=option:router,10.0.10.1 | ||
dhcp-option=option:dns-server,1.1.1.1 | ||
dhcp-authoritative | ||
interface=eth1 | ||
port=0 | ||
EOF | ||
systemctl restart dnsmasq | ||
} | ||
|
@@ -120,24 +143,22 @@ apply_manifests() { | |
local namespace=$2 | ||
|
||
kubectl apply -n "$namespace" -f "$manifests_dir"/ubuntu-download.yaml | ||
kubectl apply -n "$namespace" -f "$manifests_dir"/talos-download.yaml | ||
} | ||
|
||
run_helm() { | ||
local manifests_dir=$1 | ||
local loadbalancer_ip=$2 | ||
local helm_chart_version=$3 | ||
local loadbalancer_interface=$4 | ||
local k3d_version=$5 | ||
local k3s_version=$5 | ||
local namespace="tink-system" | ||
|
||
install_k3d "$k3d_version" | ||
start_k3d | ||
start_k3s "$k3s_version" | ||
install_helm | ||
kubectl get all --all-namespaces | ||
kubectl_for_vagrant_user | ||
helm_install_tink_stack "$namespace" "$helm_chart_version" "$loadbalancer_interface" "$loadbalancer_ip" | ||
apply_manifests "$manifests_dir" "$namespace" | ||
apply_manifests "$manifests_dir" "$namespace" | ||
} | ||
|
||
main() { | ||
|
@@ -147,7 +168,7 @@ main() { | |
local helm_chart_version="0.4.4" | ||
local loadbalancer_interface="eth1" | ||
local kubectl_version="1.28.3" | ||
local k3d_version="v5.6.0" | ||
local k3s_version="v1.30.2-k3s1" | ||
|
||
update_apt | ||
install_docker | ||
|
@@ -156,7 +177,7 @@ main() { | |
# Needed after iPXE increased the default TCP window size to 2MB. | ||
sudo ethtool -K eth1 tx off sg off tso off | ||
install_kubectl "$kubectl_version" | ||
run_helm "$manifests_dir" "$loadbalancer_ip" "$helm_chart_version" "$loadbalancer_interface" "$k3d_version" | ||
run_helm "$manifests_dir" "$loadbalancer_ip" "$helm_chart_version" "$loadbalancer_interface" "$k3s_version" | ||
} | ||
|
||
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then | ||
|
@@ -165,4 +186,4 @@ if [[ ${BASH_SOURCE[0]} == "$0" ]]; then | |
main "$@" | ||
echo loadbalancer_ip="$1" | ||
echo "all done!" | ||
fi | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.