Create a local kubernetes cluster. Create two separate namespaces ping and pong. Deploy a redis container on a pong namespace and a container with a simple python script to send ping request redis container.
- Mac OSX
- VirtualBox
- Minikube
- Docker
To setup minikube kubernetes cluster, follow the official documentation at https://minikube.sigs.k8s.io/docs/start/
Follow the below steps to run this project on a Minikube cluster.
- Download Git:
- Clone this repository:
git clone https://github.com/srtimsina/k8slab.git
- Enter the repo directory:
cd k8slab
- Run
docker build -t sti.local/alpine-python:3.8 .. - Run
kubectl apply -f .. - Output should be something like:
namespace/ping created
namespace/pong created
deployment.apps/redis created
persistentvolumeclaim/redis-data created
service/redis created
deployment.apps/redis-client created
- Get the list of namespaces
$ kubectl get ns -A
NAME STATUS AGE
default Active 147d
kube-node-lease Active 147d
kube-public Active 147d
kube-system Active 147d
kubernetes-dashboard Active 147d
ping Active 3m32s
pong Active 3m32s
- Check the logs for ping response.
$ kubectl logs redis-client-75dffdb8b5-5dhxv
True
response from host "redis.pong.svc.cluster.local"
True
response from host "redis.pong.svc.cluster.local"
True
response from host "redis.pong.svc.cluster.local"
True
response from host "redis.pong.svc.cluster.local"
True
response from host "redis.pong.svc.cluster.local"
True
- To delete, run
kubectl delete -f ..