k42s is a full multinode Kubernetes Vagrant cluster with a real load balancer.
- Why “k42s”?
- What is Kubernetes?
- Features
- Installation
- Usage example
- Advanced Usage
- Workshops
- Release History
- Meta
- Contributing
This project is the result of getting my hands dirty with Kubernetes trying to fulfil my innate curiosity to understand how things work in the nitty-gritty details. In the beginning I have started poking around with Minikube, which at that time was quite convenient to run my experiments and demos. However, moving forward I have realised that to have a holistic understanding of Kubernetes ecosystem I had to play with something near running it in a real multinode production cluster where would possible to experiment with network policies, load balancers, ingress controllers, storage and more. Hence, I decided to build my own portable Kubernetes lab and share it with the world.
This is by no means a Kubernetes production grade setup, do not expose ports, services, endpoints to the internet.
According to the official website:
Kubernetes is a portable, extensible open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.
Overlay network: WeaveNet
K8 Package management: Helm
Load LoadBalancer: MetalLB
Service mesh: Istio
Monitoring: Prometheus - Alert Manager - Grafana
DNS Resolution: Nip.io
Vagrant base images and templates.
https://app.vagrantup.com/p0bailey/boxes/k8-stable
https://github.com/p0bailey/packer-templates/tree/master/k8
Requirements
OS X & Linux:
- Ansible - https://www.ansible.com
- Virtualbox - https://www.virtualbox.org
- Vagrant - https://www.vagrantup.com
- Heml - https://helm.sh - v3 :)
- k9s - https://github.com/derailed/k9s
- DirEnv - https://direnv.net
OSX: brew install ansible virtualbox vagrant helm derailed/k9s/k9s direnv kubectl
Other useful tools and plugins
OSX: brew install stern kubectx derailed/popeye/popeye
Setup
Quickstart:
Make sure you add these StrictHostKeyChecking to your ~/.ssh/config otherwise Ansible likely to fail.
Host 192.168.56.*
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
Clone the repo.
git clone git@github.com:p0bailey/k42s.git
Go into k42s directory and run.
direnv allow
make bootstrap
Those commands would set first a convenient KUBECONFIG env variable and second would bootstrap a full cluster with basic components as Istio, Prometheus, Weave-Scope.
At the end of the cluster bootstrap you must get this output showing 1 master and 2 worker nodes along with several pods.
https://weave.192-168-56-240.nip.io
https://prometheus.192-168-56-240.nip.io
https://alertmanager.192-168-56-240.nip.io
https://grafana.192-168-56-240.nip.io
Grafana login admin/prom-operator
https://kiali.192-168-56-240.nip.io
Kiali login admin/admin
This deployment would provide a basic NGINX webserver.
Type: make demo_1_install
Expected output.
namespace/demo1 created
Release "demo1" does not exist. Installing it now.
NAME: demo1
LAST DEPLOYED: Tue Jun 2 11:24:43 2020
NAMESPACE: demo1
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL going to:
https://demo1.192-168-56-240.nip.io/
To delete demo 1 service type:
make demo_1_delete
Expected output.
release "demo1" uninstalled
namespace "demo1" deleted
Useful commands:
List all pods in all namespaces:
kubectl get pods --all-namespaces
List cluster events in all namespace sorted by creationTimestamp.
kubectl get events --all-namespaces --sort-by=.metadata.creationTimestamp
Loads of self paced workshops to follow along
See CHANGELOG.md
Phillip Bailey– @p0bailey – phillip@bailey.st
Distributed under the MIT license. See LICENSE
for more information.
https://github.com/p0bailey/k42s
- Fork it (https://github.com/p0bailey/k42s)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request