Using Dcoker and Kubernetes API
Python SDK
- Build and run the docker image in the localhost. Mine is running in http://localhost:3001
- pip install docker
- Sample Python app to call docker api and show the info in a Flask Template
- Visit http://localhost:7000
NodeJs Library
- Build and run the docker image in the localhost. Mine is running in http://localhost:3001
- Make a seperate Node app and Intall Harbor Master :
npm install --save harbor-master
- Here is the sample code with calling docker client and show the info the browser.
- Visit http://localhost:4000
Kubernetes API
- First two cases we ran docker as barebone deamon. Here we will run docker image on Kubernetes
- Intall docker(if not installed), Intall Virtual Box
- install kubectl; Using the Google Cloud SDK:
gcloud components install kubectl
Or, Using Homebrew package manager:brew install kubectl
- install minikube. For MAC:
brew cask install minikube
and start byminikube start
- For this blog to run on Minikube in my local machine, I ran
kubectl config use-context minikube
eval $(minikube docker-env)
docker build -t jenkins-react-blog .
kubectl run jenkins-react-blog --image=jenkins-react-blog --image-pull-policy=Never --port=3001
kubectl expose deployment jenkins-react-blog --type=LoadBalancer
minikube service jenkins-react-blog
- The easiest way to access Kubernetes API is to configure a proxy. The command is
kubectl proxy --port=8000
Visit http://localhost:8000/swagger-ui/ from the browser to access Swagger APIs - However, I would like to use Kubernetes Python Client. I installed by
pip install kubernetes
- Here is the sample code
- There are command lines to call Kubernetes API and a Flask template generated UI to show my image info in the browser about the images running on Minikube Kubernetes Cluster
- Visit localhost with correct port
- A good post about using Python client and Here is a post about developing kubernetes friendly containerized application