-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4c1a1da
Showing
9 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |