Background
When deploying applications to kubernetes, we should restrict access to resources like databases, queues, cache, etc. From a security prospective, we should not be able to connect to storage/database from outside the kubernetes deployment(applications). Only applications deployed to kubernetes cluster should be allowed access to databases,queues, etc.
Problem
But for debugging purpose its essential to be able to connect to such resources. For e.g. we might need to check some data in the database or verify if an item is getting stored in redis cache, etc
Solution
For that purpose we may want to deploy a pod in the dev cluster to be able to debug applications.
We may call it a bastion pod or a pod shell which gets deployed to the kubernetes cluster which is allowed to access cloud resources like database, etc. The pod behaves as a proxy in the k8s cluster.
Such a pod may support following use cases:
- connect to database like sql, cache, queues,topics, etc
- able to run HTTP requests from inside the cluster
- be able to debug dns issues
Build image
Sample Dockerfile to build a container image: ravikrsingh20/bastion:0.1
.
The Dockerfile contains utilities that may be required for debugging purpose.
|
|
If needed we may add more utilites for improving debugging and trouble shooting.
Kubernetes deployment
Sample bastion pod deployment
|
|
- To create the pod
|
|
- To delete the pod
|
|
Usage example
- Connect to Database
|
|
- Open a bash shell in the pod
|
|