diff --git a/prepare-labs/lib/commands.sh b/prepare-labs/lib/commands.sh index 7f6162fd..112054e8 100644 --- a/prepare-labs/lib/commands.sh +++ b/prepare-labs/lib/commands.sh @@ -56,7 +56,7 @@ _cmd_codeserver() { ARCH=${ARCHITECTURE-amd64} CODESERVER_VERSION=4.96.4 - CODESERVER_URL=https://github.com/coder/code-server/releases/download/v${CODESERVER_VERSION}/code-server-${CODESERVER_VERSION}-linux-${ARCH}.tar.gz + CODESERVER_URL=\$GITHUB/coder/code-server/releases/download/v${CODESERVER_VERSION}/code-server-${CODESERVER_VERSION}-linux-${ARCH}.tar.gz pssh " set -e i_am_first_node || exit 0 @@ -375,8 +375,8 @@ _cmd_clusterize() { pssh -I < tags/$TAG/clusters.tsv " grep -w \$PSSH_HOST | tr '\t' '\n' > /tmp/cluster" pssh " - echo \$PSSH_HOST > /tmp/ipv4 - head -n 1 /tmp/cluster | sudo tee /etc/ipv4_of_first_node + echo \$PSSH_HOST > /tmp/ip_address + head -n 1 /tmp/cluster | sudo tee /etc/ip_address_of_first_node echo ${CLUSTERPREFIX}1 | sudo tee /etc/name_of_first_node echo HOSTIP=\$PSSH_HOST | sudo tee -a /etc/environment NODEINDEX=\$((\$PSSH_NODENUM%$CLUSTERSIZE+1)) @@ -459,7 +459,7 @@ _cmd_docker() { set -e ### Install docker-compose. sudo curl -fsSL -o /usr/local/bin/docker-compose \ - https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$COMPOSE_PLATFORM + \$GITHUB/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$COMPOSE_PLATFORM sudo chmod +x /usr/local/bin/docker-compose docker-compose version @@ -467,7 +467,7 @@ _cmd_docker() { ##VERSION## https://github.com/docker/machine/releases MACHINE_VERSION=v0.16.2 sudo curl -fsSL -o /usr/local/bin/docker-machine \ - https://github.com/docker/machine/releases/download/\$MACHINE_VERSION/docker-machine-\$(uname -s)-\$(uname -m) + \$GITHUB/docker/machine/releases/download/\$MACHINE_VERSION/docker-machine-\$(uname -s)-\$(uname -m) sudo chmod +x /usr/local/bin/docker-machine docker-machine version " @@ -500,7 +500,7 @@ _cmd_kubebins() { set -e cd /usr/local/bin if ! [ -x etcd ]; then - curl -L https://github.com/etcd-io/etcd/releases/download/$ETCD_VERSION/etcd-$ETCD_VERSION-linux-$ARCH.tar.gz \ + curl -L \$GITHUB/etcd-io/etcd/releases/download/$ETCD_VERSION/etcd-$ETCD_VERSION-linux-$ARCH.tar.gz \ | sudo tar --strip-components=1 --wildcards -zx '*/etcd' '*/etcdctl' fi if ! [ -x kube-apiserver ]; then @@ -512,7 +512,7 @@ _cmd_kubebins() { sudo mkdir -p /opt/cni/bin cd /opt/cni/bin if ! [ -x bridge ]; then - curl -L https://github.com/containernetworking/plugins/releases/download/$CNI_VERSION/cni-plugins-linux-$ARCH-$CNI_VERSION.tgz \ + curl -L \$GITHUB/containernetworking/plugins/releases/download/$CNI_VERSION/cni-plugins-linux-$ARCH-$CNI_VERSION.tgz \ | sudo tar -zx fi " @@ -565,9 +565,12 @@ EOF" # Install helm early # (so that we can use it to install e.g. Cilium etc.) + ARCH=${ARCHITECTURE-amd64} + HELM_VERSION=3.19.1 pssh " if [ ! -x /usr/local/bin/helm ]; then - curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get-helm-3 | sudo bash && + curl -fsSL https://get.helm.sh/helm-v${HELM_VERSION}-linux-${ARCH}.tar.gz | + sudo tar --strip-components=1 --wildcards -zx -C /usr/local/bin '*/helm' helm completion bash | sudo tee /etc/bash_completion.d/helm helm version fi" @@ -599,6 +602,7 @@ _cmd_kubeadm() { ADVERTISE=\"advertiseAddress: \$IPV6\" SERVICE_SUBNET=\"serviceSubnet: fdff::/112\" touch /tmp/install-cilium-ipv6-only + touch /tmp/ipv6-only else ADVERTISE= SERVICE_SUBNET= @@ -644,7 +648,7 @@ kind: ClusterConfiguration apiVersion: kubeadm.k8s.io/v1beta3 apiServer: certSANs: - - \$(cat /tmp/ipv4) + - \$(cat /tmp/ip_address) networking: \$SERVICE_SUBNET $CLUSTER_CONFIGURATION_KUBERNETESVERSION @@ -666,7 +670,7 @@ EOF pssh " if i_am_first_node; then if [ -f /tmp/install-weave ]; then - curl -fsSL https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s-1.11.yaml | + curl -fsSL \$GITHUB/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s-1.11.yaml | sed s,weaveworks/weave,quay.io/rackspace/weave, | kubectl apply -f- fi @@ -701,13 +705,16 @@ EOF fi # Install metrics server - pssh " + pssh -I <../k8s/metrics-server.yaml " if i_am_first_node; then - kubectl apply -f https://raw.githubusercontent.com/jpetazzo/container.training/master/k8s/metrics-server.yaml + kubectl apply -f- + fi" + # It would be nice to be able to use that helm chart for metrics-server. + # Unfortunately, the charts themselves are on github.com and we want to + # avoid that due to their lack of IPv6 support. #helm upgrade --install metrics-server \ # --repo https://kubernetes-sigs.github.io/metrics-server/ metrics-server \ # --namespace kube-system --set args={--kubelet-insecure-tls} - fi" } _cmd kubetools "Install a bunch of CLI tools for Kubernetes" @@ -734,7 +741,7 @@ _cmd_kubetools() { # Install ArgoCD CLI ##VERSION## https://github.com/argoproj/argo-cd/releases/latest - URL=https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-${ARCH} + URL=\$GITHUB/argoproj/argo-cd/releases/latest/download/argocd-linux-${ARCH} pssh " if [ ! -x /usr/local/bin/argocd ]; then sudo curl -o /usr/local/bin/argocd -fsSL $URL @@ -747,7 +754,7 @@ _cmd_kubetools() { ##VERSION## https://github.com/fluxcd/flux2/releases FLUX_VERSION=2.3.0 FILENAME=flux_${FLUX_VERSION}_linux_${ARCH} - URL=https://github.com/fluxcd/flux2/releases/download/v$FLUX_VERSION/$FILENAME.tar.gz + URL=\$GITHUB/fluxcd/flux2/releases/download/v$FLUX_VERSION/$FILENAME.tar.gz pssh " if [ ! -x /usr/local/bin/flux ]; then curl -fsSL $URL | @@ -762,7 +769,7 @@ _cmd_kubetools() { set -e if ! [ -x /usr/local/bin/kctx ]; then cd /tmp - git clone https://github.com/ahmetb/kubectx + git clone \$GITHUB/ahmetb/kubectx sudo cp kubectx/kubectx /usr/local/bin/kctx sudo cp kubectx/kubens /usr/local/bin/kns sudo cp kubectx/completion/*.bash /etc/bash_completion.d @@ -773,7 +780,7 @@ _cmd_kubetools() { set -e if ! [ -d /opt/kube-ps1 ]; then cd /tmp - git clone https://github.com/jonmosco/kube-ps1 + git clone \$GITHUB/jonmosco/kube-ps1 sudo mv kube-ps1 /opt/kube-ps1 sudo -u $USER_LOGIN sed -i s/docker-prompt/kube_ps1/ /home/$USER_LOGIN/.bashrc && sudo -u $USER_LOGIN tee -a /home/$USER_LOGIN/.bashrc </dev/null; then + echo GITHUB=http://cachttps.internal:3131/https://github.com + else + echo GITHUB=https://github.com + fi | sudo tee -a /etc/environment" } _cmd tailhist "Install history viewer on port 1088" @@ -1177,7 +1197,7 @@ _cmd_tailhist () { pssh " set -e sudo apt-get install unzip -y - wget -c https://github.com/joewalnes/websocketd/releases/download/v0.3.0/websocketd-0.3.0-linux_$ARCH.zip + wget -c \$GITHUB/joewalnes/websocketd/releases/download/v0.3.0/websocketd-0.3.0-linux_$ARCH.zip unzip -o websocketd-0.3.0-linux_$ARCH.zip websocketd sudo mv websocketd /usr/local/bin/websocketd sudo mkdir -p /opt/tailhist @@ -1443,7 +1463,7 @@ _cmd_webssh() { sudo apt-get install python3-tornado python3-paramiko -y" pssh " cd /opt - [ -d webssh ] || sudo git clone https://github.com/jpetazzo/webssh" + [ -d webssh ] || sudo git clone \$GITHUB/jpetazzo/webssh" pssh " for KEYFILE in /etc/ssh/*.pub; do read a b c < \$KEYFILE; echo localhost \$a \$b @@ -1528,7 +1548,7 @@ test_vm() { "whoami" \ "hostname -i" \ "ls -l /usr/local/bin/i_am_first_node" \ - "grep . /etc/name_of_first_node /etc/ipv4_of_first_node" \ + "grep . /etc/name_of_first_node /etc/ip_addres_of_first_node" \ "cat /etc/hosts" \ "hostnamectl status" \ "docker version | grep Version -B1" \