diff --git a/.bashrc b/.bashrc index ac64b3c..293c09d 100644 --- a/.bashrc +++ b/.bashrc @@ -50,6 +50,9 @@ export DISPLAY=:0.0 # Configure docker host export DOCKER_HOST=tcp://localhost:2375 +# Configure kubeconfig default +export KUBECONFIG=$KUBECONFIG:/c/Users/$USER/.kube/config + # Setup prompt function color_my_prompt { local __user_and_host="\[\033[01;32m\]\u@\h" diff --git a/kubemacs/kubemacs.env b/kubemacs/kubemacs.env new file mode 100644 index 0000000..e443e30 --- /dev/null +++ b/kubemacs/kubemacs.env @@ -0,0 +1,37 @@ +# Pin your image +# KUBEMACS_IMAGE=kubemacs/kubemacs:2020.04.02 +# Or not +# KUBEMACS_IMAGE=kubemacs/kubemacs:latest +KUBEMACS_IMAGE=kubemacs/kubemacs:2020.04.02 + +# $(id -u) / mainly for ~/.kube/config permissions +HOST_UID="1000" + +# Vars for git commits +KUBEMACS_GIT_EMAIL="mail@jamesblair.net" +KUBEMACS_GIT_NAME="James Blair" +KUBEMACS_TIMEZONE=Pacific/Auckland + +# This is the kind cluster name, maybe we should rename +# for some reason we can't used kind as the name +KUBEMACS_KIND_NAME=cncf.conformance + +# ~/.kube/$KUBEMACS_HOSTCONFIG_NAME +KUBEMACS_HOST_KUBECONFIG_NAME=config + +# Using a docker registry alongside kind +KIND_LOCAL_REGISTRY_ENABLE=true +KIND_LOCAL_REGISTRY_NAME=local-registry +KIND_LOCAL_REGISTRY_PORT=5000 + +# The repositories to check out +KUBEMACS_INIT_DEFAULT_REPOS='https://github.com/cncf/apisnoop.git' +# The folder to start tmate/emacs in + +KUBEMACS_INIT_DEFAULT_REPOS_FOLDER="/home/projects" + +# The first file you want emacs to open +KUBEMACS_INIT_ORG_FILE="apisnoop/README.org" + +# If you want to see lots of information, set this to true +KUBEMACS_INIT_DEBUG=false diff --git a/kubemacs/kubemacs.sh b/kubemacs/kubemacs.sh new file mode 100755 index 0000000..7659833 --- /dev/null +++ b/kubemacs/kubemacs.sh @@ -0,0 +1,15 @@ +# kubemacs.sh +ENV_FILE=kubemacs.env +. $ENV_FILE +docker run \ + --env-file $ENV_FILE \ + --name kubemacs-docker-init \ + --user root \ + --privileged \ + --network host \ + --rm \ + -it \ + -v "/c/Users/$USER/.kube:/tmp/.kube" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + $KUBEMACS_IMAGE \ + docker-init.sh diff --git a/start-session.sh b/kubemacs/start-session.sh similarity index 100% rename from start-session.sh rename to kubemacs/start-session.sh diff --git a/wsl-setup.org b/wsl-setup.org index 6751358..a762a4b 100644 --- a/wsl-setup.org +++ b/wsl-setup.org @@ -365,6 +365,36 @@ An integral part of our pair development workflow is [[https://github.com/kubema *** Option 2 - Install via docker +For this method we need to set some variables in the included ~kubemacs.env~ file, then run the included ~kubemacs.sh~ script. + +#+NAME: Update environment file +#+begin_src shell +sed -i 's/KUBEMACS_GIT_EMAIL.*/KUBEMACS_GIT_EMAIL="mail@jamesblair.net"/g' kubemacs/kubemacs.env +sed -i 's/KUBEMACS_GIT_NAME.*/KUBEMACS_GIT_NAME="James Blair"/g' kubemacs/kubemacs.env +#+end_src + +Next we create a folder ~.kube~ folder in windows that can be mounted through into docker for windows. Currently we cannot mount wsl folders into docker for windows. + +#+NAME: Setup kubeconfig mount +#+begin_src shell +# Make the windows folder for out kubeconfig +mkdir -p /c/Users/$USER/.kube + +# Set that folder to the volume mount +sed -i 's|^.*[.]kube| -v "/c/Users/$USER/.kube:/tmp/.kube|g' kubemacs/kubemacs.sh + +# Export that folder for kubeconfig +export KUBECONFIG=$KUBECONFIG:/c/Users/$USER/.kube/config +#+end_src + +After updating the environment file and preparing the kubeconfig mount we are ready to launch kubemacs in a kind cluster by running the script :) + +Do this in your left eye terminal as this will pop you straight into kubemacs. + +#+NAME: Launch kubemacs left eye +#+begin_src shell +./kubemacs/kubemacs.sh +#+end_src ** Step 5 - Setup mutt email client