Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
697 lines (671 sloc) 28.2 KB

dev cycle

checkout-existing-PR/branch-from-src

git clone https://github.com/kubemacs/kubemacs
# be sure and fork to your own user
cd kubemacs
git remote add dev git@github.com:bernokl/kubemacs.git
# to work on a branch based on a PR
git fetch origin refs/pull/6/head
git checkout -b devcycle FETCH_HEAD
# submodules point to other repos and mounth them within our repo
# google cloud builds (for our PRs) are not supported... yet
git submodule init
git submodule update

Now you can work on your the existing PR in a local branch.

ensure the IP:PORTS you want to use locally are available

tcp

ss --listening --numeric --tcp | grep -v :: | awk '{print $1, $4}' | sort

udp

ss --listening --numeric --udp | grep -v :: | awk '{print $1, $4}' | sort

kind.nodes.hostPort entres

grep hostPort: kind-cluster-config.yaml

setting up local-registry

# create registry container unless it already exists
KIND_LOCAL_REGISTRY_NAME="kind-registry"
KIND_LOCAL_REGISTRY_PORT="5000"
docker pull registry:2
running="$(docker inspect -f '{{.State.Running}}' "${KIND_LOCAL_REGIESTRY_NAME}" 2>/dev/null || true)"
if [ "${running}" != 'true' ]; then
  docker run \
    -d --restart=always -p "${KIND_LOCAL_REGISTRY_PORT}:5000" --name "${KIND_LOCAL_REGISTRY_NAME}" \
    registry:2
fi

dev-cycle

# needs another var to not ask questions
KUBEMACS_USER=berno
KUBEMACS_IMAGE=gcr.io/kubemacs/kubemacs:${KUBEMACS_USER}-dev
docker build -t $KUBEMACS_IMAGE .
# KUBEMACS_IMAGE=gcr.io/kubemacs/kubemacs:pr-N # for any kubemacs/kubemacs PR
 # -e KUBEMACS_DOCKER_INIT_CONTAINER_NAME="kubemacs-docker-init" \
docker run \
 --name kubemacs-docker-init \
 -e HOST_UID="$(id -u)" \
 -e KUBEMACS_GIT_EMAIL='hhii@ii.coop' \
 -e KUBEMACS_GIT_NAME='Hippie Hacker (ii)' \
 -e KUBEMACS_TIMEZONE='Pacific/Auckland' \
 -e KUBEMACS_IMAGE=$KUBEMACS_IMAGE \
 -e KUBEMACS_HOST_KUBECONFIG_NAME="kind-${KUBEMACS_USER}.kubemacs.configname" \
 -e KIND_LOCAL_REGISTRY_ENABLE="true" \
 -e KIND_LOCAL_REGISTRY_NAME="kind-registry" \
 -e KIND_LOCAL_REGISTRY_PORT="5000" \
 -e KUBEMACS_KIND_NAME="${KUBEMACS_USER}.kubemacs.kindname" \
 -e KUBEMACS_INIT_DEFAULT_REPOS='https://github.com/cncf/apisnoop git@gitlab.ii.coop:ii/hours.git' \
 -e KUBEMACS_INIT_DEFAULT_REPOS_FOLDER='Projects' \
 -e KUBEMACS_INIT_DEFAULT_DIR='Projects/apisnoop' \
 -e KUBEMACS_INIT_ORG_FILE='Projects/apisnoop/deployment/k8s/local/tilt.org' \
 -e KUBEMACS_INIT_DEBUG=true \
 --user root \
 --network host \
 -it \
 --rm \
 --privileged \
 -v "$HOME/.kube":/tmp/.kube \
 -v /var/run/docker.sock:/var/run/docker.sock \
$KUBEMACS_IMAGE \
 docker-init.sh

##+begin_src tmate :session foo:bar

aoeu

kubectl exec -it kubemacs-0 -- tmate -S /tmp/ii.default.target.iisocket at

get pod/kubemacs-0

docker exec hh-kubemacs-control-plane kubectl get pod/kubemacs-0 --kubeconfig=/etc/kubernetes/admin.conf -o yaml

Describe pod/kubemacs-0

docker exec hh-kubemacs-control-plane kubectl describe pod/kubemacs-0 --kubeconfig=/etc/kubernetes/admin.conf 

Four nested levels of KUBECONFIGs

within the kubemacs-init docker container

docker exec kubemacs-init kubectl config view
# docker exec kubemacs-init cat /root/.kube/config

within the kind control-plane node

KIND_CLUSTER_NAME=$(kind get clusters | tail -1) # assuming we only have one
docker exec ${KIND_CLUSTER_NAME}-control-plane kubectl config view --kubeconfig /etc/kubernetes/admin.conf

within k8s kubemacs-0 pod/container

export KUBECONFIG=~/.kube/kind-berno.kubemacs.configname
kubectl exec kubemacs-0 kubectl config view

the one copied out of the container to the outer host

export KUBECONFIG=~/.kube/kind-berno.kubemacs.configname
kubectl config view

Logs

docker exec hh-kubemacs-control-plane kubectl logs kubemacs-0 --kubeconfig=/etc/kubernetes/admin.conf 

You can’t perform that action at this time.