Skip to content

Commit

Permalink
Import init
Browse files Browse the repository at this point in the history
  • Loading branch information
gmembre-zenika committed May 6, 2024
0 parents commit 4c1a1da
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: build-all push-all
images=k8s-training-tools k8s-training-stress

build-all:
for image in $(images) ; do \
cd $$image && make build && cd .. ; \
done ; \
cd k8s-training-deploy && make build-v1 && make build-v2

push-all:
for image in $(images) ; do \
cd $$image && make push && cd .. ; \
done ; \
cd k8s-training-deploy && make push-v1 && make push-v2
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In trainings, we used some of the following images:

- [`zenika/k8s-training-deploy`](k8s-training-deploy/): image of an HTTP server that returns its version, used for labs on Deployments
- [`zenika/k8s-training-tools`](k8s-training-tools/): Debian-based image that embeds the necessary tools for labs such as the `curl`, `dnsutils`, `httping`, `procps`, `kubectl`, `jwt-cli`
- [`zenika/k8s-training-stress`](k8s-training-stress/): image of a binary to consume memory or CPU.
9 changes: 9 additions & 0 deletions k8s-training-deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM gcr.io/distroless/python3

ARG VERSION=v0

ENV VERSION=${VERSION}

ADD app.py /app.py

ENTRYPOINT ["python3", "-u", "/app.py"]
20 changes: 20 additions & 0 deletions k8s-training-deploy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: build-v1 push-v1 build-v2 push-v2 build push
image_name=zenika/k8s-training-deploy

build-v1: version=v1
build-v1: build

push-v1: version=v1
push-v1: build push

build-v2: version=v2
build-v2: build

push-v2: version=v2
push-v2: build push

build:
docker image build --build-arg VERSION=$(version) -t $(image_name):$(version) .

push:
docker image push $(image_name):$(version)
43 changes: 43 additions & 0 deletions k8s-training-deploy/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
# coding: utf-8

import os
import signal
import socket
import sys
from http.server import BaseHTTPRequestHandler, HTTPServer


class RequestHandler(BaseHTTPRequestHandler):

def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
version = os.environ.get('VERSION', 'v0')
hostname = socket.gethostname()
if version == "v1":
version = "v1 *🔵 🔵 *"
elif version == "v2":
version = "v2 #🟩 🟩 #"
message = 'Hello from {} and version {}\n'.format(hostname, version)
self.wfile.write(bytes(message, 'utf8'))


def run():
host = '0.0.0.0'
port = 8080
server_address = (host, port)
httpd = HTTPServer(server_address, RequestHandler)
print('Server is listening on http://{}:{}'.format(host, port))
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
finally:
httpd.server_close()
print('Stopped')


signal.signal(signal.SIGTERM, lambda s, f: sys.exit(0))
run()
10 changes: 10 additions & 0 deletions k8s-training-stress/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM debian:11-slim

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
stress \
; \
rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["stress"]
8 changes: 8 additions & 0 deletions k8s-training-stress/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.PHONY: build push
image_name=zenika/k8s-training-stress:v3

build:
docker image build -t $(image_name) .

push: build
docker image push $(image_name)
24 changes: 24 additions & 0 deletions k8s-training-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM debian:12-slim

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
curl \
dnsutils \
iputils-ping \
iproute2 \
httping \
procps \
ca-certificates \
vim \
; \
rm -rf /var/lib/apt/lists/*

ENV JWT_VERSION=6.0.0
RUN curl -fSsLO https://github.com/mike-engel/jwt-cli/releases/download/${JWT_VERSION}/jwt-linux.tar.gz && \
tar zxf jwt-linux.tar.gz && \
mv jwt /usr/bin

ENV KUBECTL_VERSION=1.29.0
RUN curl -fsSLo /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl \
&& chmod +x /usr/local/bin/kubectl
8 changes: 8 additions & 0 deletions k8s-training-tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.PHONY: build push
image_name=zenika/k8s-training-tools:v4

build:
docker image build -t $(image_name) .

push: build
docker image push $(image_name)

0 comments on commit 4c1a1da

Please sign in to comment.