Created
September 17, 2019 17:56
-
-
Save frimik/85f587c093b35f26d028bf3bb0ebff3e to your computer and use it in GitHub Desktop.
Local K3D (k3s) cluster base
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
#!/bin/bash | |
CLUSTER_NAME="k3s-default" | |
# Install k3d | |
k3d --version || wget -q -O - https://raw.githubusercontent.com/rancher/k3d/master/install.sh | bash | |
# verify it | |
k3d check-tools | |
# create a volume and cluster | |
docker volume create kube-volume | |
k3d create --name "${CLUSTER_NAME}" --workers 3 --volume kube-volume:/opt/local-path-provisioner --wait 0 | |
KUBECONFIG=$(k3d get-kubeconfig --name "${CLUSTER_NAME}") | |
echo "Replacing 'default' with '$CLUSTER_NAME' in $KUBECONFIG ..." | |
sed -i "s/\bdefault\b/${CLUSTER_NAME}/" "${KUBECONFIG}" | |
kubectl cluster-info | |
kustomize build --enable_alpha_plugins environments/dev | kubectl apply -f - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For me kubectl only started working after exporting $KUBECONFIG with
export KUBECONFIG=$(k3d get-kubeconfig --name "${CLUSTER_NAME}")