• Stars
    star
    134
  • Rank 264,588 (Top 6 %)
  • Language
    Dockerfile
  • Created over 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Container image to get a consistent training environment to work on Kubernetes.

shpod

TL,DR: curl https://shpod.sh | sh

If you are looking for an image that works on the ARM architecture (like the Raspberry Pi or the Apple M1), have a look at BretFisher/shpod instead. Bret's fork is also a state-of-the-art example of a multi-arch Dockerfile!

What's this?

shpod is a container image based on the Alpine distribution and embarking a bunch of tools useful when working with containers, Docker, and Kubernetes.

It includes:

  • ab (ApacheBench)
  • bash
  • crane
  • curl
  • Docker CLI
  • Docker Compose
  • envsubst
  • git
  • Helm
  • jid
  • jq
  • kubectl
  • kubectx + kubens
  • kube-linter
  • kube-ps1
  • kubeseal
  • kustomize
  • ngrok
  • popeye
  • regctl
  • ship
  • skaffold
  • skopeo
  • SSH
  • stern
  • tilt
  • tmux
  • yq

It also includes completion for most of these tools.

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, you need a Kubernetes cluster. You can use Minikube, microk8s, Docker Desktop, AKS, EKS, GKE, anything you like, really.

If it runs with a pseudo-terminal, it will spawn a shell, and you can attach to that shell. If it runs without a pseudo-terminal, it will start an SSH server, and you can connect to that SSH server to obtain the shell.

Using with a pseudo-terminal

Run it in a Pod and attach directly to it:

kubectl run shpod --restart=Never --rm -it --image=jpetazzo/shpod

This should give you a shell in a pod, with all the tools installed. Most Kubernetes commands won't work (you will get permission errors) until you create an appropriate RoleBinding or ClusterRoleBinding (see below for details).

Using without a pseudo-terminal

Run as a Pod (or Deployment), then expose (or port-forward) to port 22 in that Pod, and connect with an SSH client:

kubectl run shpod --image=jpetazzo/shpod
kubectl wait pod shpod --for=condition=ready
kubectl port-forward pod/shpod 2222:22
ssh -l k8s -p 2222 localhost # the default password is "k8s"

Note: you can change the password by setting the PASSWORD environment variable.

Granting permissions

By default, shpod uses the ServiceAccount of the Pod that it's running in; and by default (on most clusters) that ServiceAccount won't have much permissions, meaning that you will get errors like the following one:

$ kubectl get pods
Error from server (Forbidden): pods is forbidden: User "system:serviceaccount:default:default" cannot list resource "pods" in API group "" in the namespace "default"

If you want to use Kubernetes commands within shpod, you need to give permissions to that ServiceAccount.

Assuming that you are running shpod in the default namespace and with the default ServiceAccount, you can run the following command to give cluster-admin privileges (=all privileges) to the commands running in shpod:

kubectl create clusterrolebinding shpod \
        --clusterrole=shpod \
        --serviceaccount=default:default

You can also use the one-liner below.

One-liner usage

The shpod.sh script will:

  • apply the shpod.yaml manifest to your cluster,
  • wait for the pod shpod to be ready,
  • attach to that pod,
  • delete resources created by the manifest when you exit the pod.

The manifest will:

  • create the shpod Namespace,
  • create the shpod ServiceAccount in that Namespace,
  • create the shpod ClusterRoleBinding giving cluster-admin privileges to that ServiceAccount,
  • create a Pod named shpod, using that ServiceAccount, with a terminal (so that you can attach to that Pod and get a shell).

To execute it:

curl https://raw.githubusercontent.com/jpetazzo/shpod/main/shpod.sh | sh

It's also available with short URLs:

curl https://shpod.sh | sh
curl https://shpod.me | sh

If you don't like curl|sh, and/or if you want to execute things step by step, check the next section.

Step-by-step usage

  1. Deploy the shpod pod:

    kubectl apply -f https://raw.githubusercontent.com/jpetazzo/shpod/main/shpod.yaml
    
  2. Attach to the shpod pod:

    kubectl attach --namespace=shpod -ti shpod
    
  3. Enjoy!

Clean up

If you are using the shell script above, when you exit shpod, the script will delete the resources that were created.

If you want to delete the resources manually, you can use kubectl delete -f shpod.yaml, or delete the namespace shpod and the ClusterRoleBinding with the same name:

kubectl delete clusterrolebinding,ns shpod

Opening multiple sessions

Shpod tries to detect if it is already running; and if it's the case, it will try to start another process using kubectl exec. Note that if the first shpod process exits, Kubernetes will terminate all the other processes.

Special handling of kubeconfig

If you have a ConfigMap named kubeconfig in the Namespace where shpod is running, it will extract the first file from that ConfigMap and use it to populate ~/.kube/config.

This lets you inject a custom kubeconfig file into shpod.

Support for other architectures

As of November 2021, the Dockerfile in this repository should be able to build images for other architectures. However, when trying to install a compiled binary that is not available for another architecture, a dummy placeholder will be installed instead.

More Repositories

1

pipework

Software-Defined Networking tools for LXC (LinuX Containers)
Shell
4,139
star
2

container.training

Slides and code samples for training, tutorials, and workshops about Docker, containers, and Kubernetes.
Shell
3,559
star
3

nsenter

Shell
2,582
star
4

ampernetacle

HCL
2,519
star
5

dind

Docker in Docker
Shell
2,474
star
6

dockvpn

Recipe to build an OpenVPN image for Docker
Shell
833
star
7

squid-in-a-can

Python
357
star
8

pxe

Dockerfile to build a PXE server in a Docker container
Shell
250
star
9

minimage

Minimal Docker images: a collection of Dockerfiles illustrating how to reduce container image size.
Shell
206
star
10

griode

Griode + Novation Launchpad + Raspberry Pi = a music instrument!
Python
139
star
11

registrish

Dirty hack to run a read-only, public Docker registry on almost any static file hosting service (e.g. NGINX, Netlify, S3...)
Shell
136
star
12

critmux

Docker + CRIU + tmux = magic!
Dockerfile
117
star
13

dockercoins

Python
98
star
14

docker-busybox

Busybox for Stackbrew
Shell
94
star
15

sekexe

Separate Kernel Execution: execute a process within user-mode-linux and retrieve its output and status code
Shell
79
star
16

dessine-moi-un-cluster

Instructions to build a Kubernetes control plane one piece at a time, for learning purposes.
Shell
78
star
17

gunsub

Get your github notifications under control!
Python
74
star
18

syslogdocker

70
star
19

stevedore

Containerize your development environments
Shell
68
star
20

hamba

Shell
67
star
21

obs-docker

OBS-Studio (and a few extra tools) in containers
Python
62
star
22

docker2docker

Shell
26
star
23

wordsmith

Java
23
star
24

intro-to-docker

CSS
23
star
25

jpetazzo.github.io

HTML
22
star
26

go-docker-

20
star
27

trainingwheels

HTML
18
star
28

snakedeck

Elgato StreamDeck controller for Linux, in Python.
Python
17
star
29

nsplease

Tiny Kubernetes operator to create Namespaces on demand (for CI/CD, for instance)
Shell
16
star
30

django

Django on DotCloud tutorial
Python
16
star
31

whisperfiles

A bunch of Dockerfiles for OpenAI Whisper, to illustrate various image optimization techniques
Shell
15
star
32

foundation-example

Shell
14
star
33

httpenv

Tiny HTTP server showing the environment variables
Go
14
star
34

buildkit-demos

Dockerfile
13
star
35

dctrl

Shell
13
star
36

orchestration-workshop

We have moved! We are now at โ†’ https://github.com/jpetazzo/container.training
HTML
12
star
37

decoup

Python
11
star
38

layeremove

Surgically remove layers from a Docker image (with a chainsaw)
Python
11
star
39

znc-on-dotcloud

Shell
11
star
40

tilestream-on-dotcloud

Python
10
star
41

littleboxes

Just for fun scripts to manage local cloud-like VMs with KVM
Shell
10
star
42

django-and-mongodb-on-dotcloud

Django on DotCloud tutorial, using MongoDB to store objects!
Python
10
star
43

kubercoins

8
star
44

sstk

Shell
8
star
45

geodjango-on-dotcloud

Python
7
star
46

meteor-on-dotcloud

7
star
47

solr-on-dotcloud

JavaScript
7
star
48

seleterm

Selenium for terminal applications
Python
6
star
49

snap-on-dotcloud

Shell
6
star
50

httplat

Minimalist Prometheus exporter to collect the latency of an HTTP target
Go
6
star
51

boggle

Solver for the Boggle Word Game
Python
6
star
52

mume

Python
6
star
53

gitorial

(Ab)use git history to write tutorials!
Python
6
star
54

postgresql-on-dotcloud

Python
5
star
55

django-on-gpaas

Django on GANDI PAAS
Python
5
star
56

scangraph

Retrieve point coordinates from a raster plot
JavaScript
5
star
57

hano

Online IDE for Node.js on dotCloud
Shell
5
star
58

pyramid-on-dotcloud

Python
5
star
59

traefik-compose

Quick demo showing how to run web sites (like Wordpress) on Docker with Traefik
4
star
60

plumber

Shell
4
star
61

consul

jpetazzo's Consul image
Shell
4
star
62

zwave-exporter

Prometheus exporter for Z-Wave sensors
JavaScript
4
star
63

jenkins-on-dotcloud

Shell
4
star
64

color

Go
4
star
65

busyhttp

A trivial HTTP server that eats CPU cycles at each request.
Python
4
star
66

tinydocgen

Tiny document generator using Jinja2, Markdown, and WeasyPrint.
Makefile
3
star
67

ngrok

3
star
68

charliebot

Python
3
star
69

prettypictures

3
star
70

usb-webcam-analyzer

Python
3
star
71

rickroll-in-docker

HTML
3
star
72

dnc

Domain Name Command-line tool
Python
3
star
73

python-simple-logging

Python
3
star
74

replay.container.training

Shell
3
star
75

riak-on-dotcloud-ALPHA

Shell
3
star
76

ucengine-on-dotcloud-ALPHA

Shell
3
star
77

django-r2d2

R2D2 (RRDDashboard) is a Django application to draw graphs from metrics coming from e.g. collectd.
Python
3
star
78

pieuvre

Distributed HTTP proxy in Node.js
JavaScript
2
star
79

tmp-sealedsecret-juin-2022

2
star
80

couchdb-on-dotcloud-ALPHA

Shell
2
star
81

escapehash

Python
2
star
82

dockerhubratelimit

Shell
2
star
83

workflows

2
star
84

python-worker-on-dotcloud

Shell
2
star
85

tcl-on-dotcloud-ALPHA

Shell
2
star
86

elastic-gke

HCL
2
star
87

dampmam

Docker-Apache-MySQL-PHP but without Apache and MySQL
JavaScript
2
star
88

watchdns

Shell
2
star
89

highfive

Dockerfile
2
star
90

memcached-on-dotcloud

2
star
91

pawd

PulseAudio Web Daemon
2
star
92

pingr

HTTP server to ping other servers and report their status
Go
2
star
93

dotfiles-old

Config files for various environments
Shell
2
star
94

pgpool-II-on-dotcloud

2
star
95

ls

An ls image for the Docker Fundamentals training
Shell
2
star
96

jetty-on-dotcloud

Reimplementation of dotCloud java service using the custom build API
Shell
2
star
97

dockage

Shell
2
star
98

jira-on-dotcloud

Shell
2
star
99

tornado-on-dotcloud

Python
2
star
100

aiguillage

Nginx
2
star