Files
shpod/bash_profile
Bret Fisher 097e3df462 Merge in upstream refactor for multiplatform awesomesauce (#42)
* Changes stern to point to stern/stern

* ♻️ Update Stern to use stern/stern; get it from the GHCR image; update curl commands

* Update README to mention Bret's fork which supports ARM

* ♻️ Bump up versions and fix krew missing from PATH

Fixes #12

* Add alias k=kubectl + completion

Closes #11

* Update shpod.yaml

Remove `imagePullPolicy`; it will default to `Always` since we're using the `:latest` tag.

* ✏️  Change default editor (for kubectl edit) to vim

*  Update krew install URL

* ⚙️  Add GHA workflow to build+push to GHCR and Docker Hub

* 🏭️ Refactor Dockerfile to log as non-root

Multiple improvements here:
- start a shell with the k8s user instead of root
- when running without a tty, start an SSH server instead of a login shell
- move shell setup to bash_profile instead of Dockerfile
- add a helper script to set up tailhist
- add motd support

*  Add 'tree' and 'kustomize'

*  Upgrade to Compose v2 and add completion for a bunch of tools

* 🔧 Minor fixes and tweaks

*  Add regclient tools (regbot, regctl, regsync)

* 📃 Generate kubeconfig + update docs

*  Add kube-linter

* ♻️  Refactor Dockerfile to leverage BuildKit parallelism

* 🧹 Build httping instead of using a sketchy binary

* 🧹 Move jid version to an env var

* 🏭️ Rewrite Dockerfile to support multi-arch and cross-compilation

*  Add Docker CLI

* ♻️  Move version numbers to their individual build stage for better caching

* 🐞 Fix multi-arch support for krew

* 📃 Update documentation

*  Add crane, ngrok, and skopeo

*  Add yq and switch versions to ARG instead of ENV

Thanks @soulshake for the suggestion!

*  Update kubeseal

* 🐞 Fix kubeconfig download logic

*  Remove fftw (it's huge and doesn't bring much benefit to httping)

* 🐞 Tiny typo fix in motd

*  Add k9s; rollback kubeseal version

* 📃 Add info to install packages in motd

* ✂️  Remove skopeo (it's rarely used and it's juse one 'apk add' away)

*  Add iputils so that ping runs without sudo

* 🔑 Increase MaxAuthTries in SSH for folks with many keys

* push on pr

* auth on pr's

* only latest if on default branch

Co-authored-by: onlinejudge95 <onlinejudge95@gmail.com>
Co-authored-by: Jérôme Petazzoni <jerome.petazzoni@gmail.com>
2022-01-14 17:30:06 -05:00

65 lines
2.1 KiB
Bash

# If we don't have a kubeconfig file, let's create one.
# (This is necessary for kube_ps1 to operate correctly.)
if ! [ -f ~/.kube/config ]; then
# If there is a ConfigMap named 'kubeconfig',
# extract the kubeconfig file from there.
# We need to access the Kubernetes API, so we'll do it
# using the well-known endpoint.
(
export KUBERNETES_SERVICE_HOST=kubernetes.default.svc
export KUBERNETES_SERVICE_PORT=443
if kubectl get configmap kubeconfig >&/dev/null; then
echo "✏️ Downloading ConfigMap kubeconfig to .kube/config."
kubectl get configmap kubeconfig -o json |
jq -r '.data | to_entries | .[0].value' > ~/.kube/config
else
SADIR=/var/run/secrets/kubernetes.io/serviceaccount
# If we have a ServiceAccount token, use it.
if [ -r $SADIR/token ]; then
echo "✏️ Generating .kube/config using ServiceAccount token."
kubectl config set-cluster shpod \
--server=https://kubernetes.default.svc \
--certificate-authority=/$SADIR/ca.crt
kubectl config set-credentials shpod \
--token=$(cat $SADIR/token )
kubectl config set-context shpod \
--cluster=shpod \
--user=shpod
kubectl config use-context shpod
fi
fi
)
fi
# Note that we could also just set the following variables:
#export KUBERNETES_SERVICE_HOST=kubernetes.default.svc
#export KUBERNETES_SERVICE_PORT=443
# ...But for some reason, that doesn't work with impersonation.
# (i.e. using "kubectl get pods --as=someone.else")
if [ -f /etc/HOSTIP ]; then
HOSTIP=$(cat /etc/HOSTIP)
else
HOSTIP="0.0.0.0"
fi
KUBE_PS1_PREFIX=""
KUBE_PS1_SUFFIX=""
KUBE_PS1_SYMBOL_ENABLE="false"
KUBE_PS1_CTX_COLOR="green"
KUBE_PS1_NS_COLOR="green"
PS1="\e[1m\e[31m[\$HOSTIP] \e[0m(\$(kube_ps1)) \e[34m\u@\h\e[35m \w\e[0m\n$ "
export EDITOR=vim
export PATH="$HOME/.krew/bin:$PATH"
alias k=kubectl
complete -F __start_kubectl k
. /usr/share/bash-completion/completions/kubectl.bash
export HISTSIZE=9999
export HISTFILESIZE=9999
shopt -s histappend
trap 'history -a' DEBUG
export HISTFILE=~/.history
trap exit TERM