Background • Usage • Docker • Kubernetes • Deploy to GKE • Network Diagram • Contributors
This testbed was created as an "Idiot's Guide" to learning Kubernetes. Kubernetes training can be unnecessarily complicated when it involves building an application, trying to force it into a microservices architecture, and then trying to put features on top of that architecture.
Instead, this testbed allows for the creation of multiple services that talk to each other and only perform simple functions. This testbed can therefore be used to test Kubernetes assumptions and systems without too much added complexity.
This testbed can also be used for new systems (e.g., Helm, service mesh, virtualkubelt). If you want to test any of these additional complexities, please create a fork of this repo.
This testbed includes the following four microservices:
- Add: Takes 2 integers, adds them together, and returns the result.
- Multiply: Takes 2 integers, checks which is smaller, calls Add enough times with the larger integer to get the correct result, decides positive or negative, and returns the result.
- Nest1: Gets Nest2, then returns "Nest2 responded: [Nest2's response]."
- Nest2: Returns the contents of an environment variable.
docker-compose up --build
curl -X POST -G 'http://localhost:8080/add' -d a=3 -d b=36
curl -X POST -G 'http://localhost:8080/multiply' -d a=3 -d b=36
curl localhost:8080/nest1
For local kubernetes setup, see instructions in /localk8ssetup
kubectl apply -f k8s.yml
curl -X POST -G 'http://localhost/add' -d a=3 -d b=36 -H"Content-Length:0"
curl -X POST -G 'http://localhost/multiply' -d a=3 -d b=36 -H"Content-Length:0"
curl http://localhost/nest1
- Follow the instructions here for configuring your shell and deploying / authenticating a cluster.
- Ensure you are using the correct context to address the remote cluster (I use kubectx and kube_ps1 to make this easy).
- Edit the
k8s.yml
file: change theimage:
entries to use the remote registries. - Deploy the YAML as follows:
kubectl apply -f k8s.yml
+----------------+
| |
+------> Frontend |
| | |
| +----------------+
|
| +----------------+
| | |
+----->+ Adder |
| | |
| +----------------+
| ^
| |
| |
+------------+ | +----------------+
| | | | |
| Client +----------->+ Multiplier |
| | | | |
+------------+ | +----------------+
|
| +----------------+ +----------------+
| | | | |
+----->+ Nest1 +----->+ Nest2 |
| | | |
+----------------+ +----------------+