mirror of
https://github.com/BretFisher/shpod.git
synced 2026-05-06 18:06:33 +00:00
🥇✍🏻
This commit is contained in:
60
Dockerfile
Normal file
60
Dockerfile
Normal file
@@ -0,0 +1,60 @@
|
||||
FROM alpine
|
||||
ENV \
|
||||
COMPOSE_VERSION=1.24.1 \
|
||||
HELM_VERSION=3.0.0-rc.1 \
|
||||
KUBECTL_VERSION=1.16.2 \
|
||||
SHIP_VERSION=0.40.0 \
|
||||
STERN_VERSION=1.11.0
|
||||
## Alpine base ##
|
||||
ENV COMPLETIONS=/usr/share/bash-completion/completions
|
||||
RUN apk add bash bash-completion curl git jq libintl ncurses tmux vim
|
||||
RUN sed -i s,/bin/ash,/bin/bash, /etc/passwd
|
||||
## Ubuntu base ##
|
||||
#ENV COMPLETIONS=/etc/bash_completion.d
|
||||
#RUN apt-get update \
|
||||
# && apt-get install -y curl git jq vim
|
||||
## Install a bunch of binaries
|
||||
RUN curl -L -o /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-Linux-x86_64 \
|
||||
&& chmod +x /usr/local/bin/docker-compose
|
||||
RUN curl -L -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl \
|
||||
&& chmod +x /usr/local/bin/kubectl
|
||||
RUN kubectl completion bash > $COMPLETIONS/kubectl.bash
|
||||
RUN curl -L -o /usr/local/bin/stern https://github.com/wercker/stern/releases/download/${STERN_VERSION}/stern_linux_amd64 \
|
||||
&& chmod +x /usr/local/bin/stern
|
||||
RUN stern --completion bash > $COMPLETIONS/stern.bash
|
||||
RUN curl -L https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz \
|
||||
| tar zx -C /usr/local/bin --strip-components=1 linux-amd64/helm
|
||||
RUN helm completion bash > $COMPLETIONS/helm.bash
|
||||
RUN curl -L https://github.com/replicatedhq/ship/releases/download/v${SHIP_VERSION}/ship_${SHIP_VERSION}_linux_amd64.tar.gz \
|
||||
| tar zx -C /usr/local/bin ship
|
||||
# This is embarrassing, but I can't get httping to compile correctly with musl.
|
||||
# It reports negative times. So, I found this random binary here. Shrug.
|
||||
RUN curl -L https://github.com/static-linux/static-binaries-i386/raw/4266c69990ae11315bad7b928f85b6c8e605ef14/httping-2.4.tar.gz \
|
||||
| tar zx -C /usr/local/bin --strip-components=1 httping-2.4/httping
|
||||
RUN cd /tmp \
|
||||
&& git clone https://github.com/ahmetb/kubectx \
|
||||
&& cd kubectx \
|
||||
&& mv kubectx /usr/local/bin/kctx \
|
||||
&& mv kubens /usr/local/bin/kns \
|
||||
&& mv completion/*.bash $COMPLETIONS \
|
||||
&& cd .. \
|
||||
&& rm -rf kubectx
|
||||
RUN cd /tmp \
|
||||
&& git clone https://github.com/jonmosco/kube-ps1 \
|
||||
&& cp kube-ps1/kube-ps1.sh /etc/profile.d/ \
|
||||
&& rm -rf kube-ps1
|
||||
RUN kubectl config set-context kubernetes --namespace=default \
|
||||
&& kubectl config use-context kubernetes
|
||||
WORKDIR /root
|
||||
RUN echo trap exit TERM > /etc/profile.d/trapterm.sh
|
||||
RUN sed -i "s/export PS1=/#export PS1=/" /etc/profile
|
||||
ENV \
|
||||
HOSTIP="0.0.0.0" \
|
||||
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[32m(\$(kube_ps1)) \e[34m\u@\h\e[35m \w\e[0m\n$ "
|
||||
ENTRYPOINT ["bash", "-l"]
|
||||
|
||||
56
README.md
Normal file
56
README.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# shpod
|
||||
|
||||
`shpod` is a container image based on the Alpine distribution
|
||||
and embarking a bunch of tools useful when working with Kubernetes:
|
||||
|
||||
- kubectl
|
||||
- helm
|
||||
- ship
|
||||
- kubectx + kubens
|
||||
- kube-ps1
|
||||
- stern
|
||||
- compose
|
||||
|
||||
It also includes tmux, a custom prompt, and completion for
|
||||
all of the above.
|
||||
|
||||
Its goal is to provide a normalized environment, to go
|
||||
with the training materials at https://container.training/,
|
||||
so that you can get all the tools you need regardless
|
||||
of your exact Kubernetes setup.
|
||||
|
||||
To use it:
|
||||
|
||||
1. Get a Kubernetes cluster. You can use Minikube, microk8s,
|
||||
Docker Desktop, AKS, EKS, GKE, anything you like, really.
|
||||
|
||||
2. Deploy the shpod pod:
|
||||
```
|
||||
kubectl apply -f https://raw.githubusercontent.com/jpetazzo/shpod/master/shpod.yaml
|
||||
```
|
||||
|
||||
3. Attach to the shpod pod:
|
||||
```
|
||||
kubecth attach --namespace=shpod -ti shpod
|
||||
```
|
||||
|
||||
4. Enjoy!
|
||||
|
||||
To remove it, you can do a `kubectl delete` on that URL above.
|
||||
|
||||
You can also delete the namespace `shpod` and the ClusterRoleBinding
|
||||
with the same name:
|
||||
|
||||
```
|
||||
kubectl delete clusterrolebinding,ns shpod
|
||||
```
|
||||
|
||||
|
||||
## Internal details
|
||||
|
||||
This repository (https://github.com/jpetazzo/shpod) is linked
|
||||
to a Docker Hub repository (https://hub.docker.com/r/jpetazzo/shpod).
|
||||
|
||||
The YAML file is a Kubernetes manifest for a Pod, a ServiceAccount,
|
||||
a ClusterRoleBinding, and a Namespace to hold the Pod and ServiceAccount.
|
||||
|
||||
42
shpod.yaml
Normal file
42
shpod.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: shpod
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: shpod
|
||||
namespace: shpod
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: shpod
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: cluster-admin
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: shpod
|
||||
namespace: shpod
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: shpod
|
||||
namespace: shpod
|
||||
spec:
|
||||
serviceAccountName: shpod
|
||||
containers:
|
||||
- name: shpod
|
||||
image: jpetazzo/shpod
|
||||
imagePullPolicy: IfNotPresent
|
||||
stdin: true
|
||||
tty: true
|
||||
env:
|
||||
- name: HOSTIP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.hostIP
|
||||
Reference in New Issue
Block a user