Using Dcoker and Kubernetes API


Python SDK

  1. Build and run the docker image in the localhost. Mine is running in http://localhost:3001

  2. pip install docker

  3. Sample Python app to call docker api and show the info in a Flask Template

  4. Visit http://localhost:7000

NodeJs Library

  1. Build and run the docker image in the localhost. Mine is running in http://localhost:3001

  2. Make a seperate Node app and Intall Harbor Master : npm install --save harbor-master

  3. Here is the sample code with calling docker client and show the info the browser.

  4. Visit http://localhost:4000

Kubernetes API

  1. First two cases we ran docker as barebone deamon. Here we will run docker image on Kubernetes

  2. Intall docker(if not installed), Intall Virtual Box

  3. install kubectl; Using the Google Cloud SDK: gcloud components install kubectl
    Or, Using Homebrew package manager: brew install kubectl

  4. install minikube. For MAC: brew cask install minikube and start byminikube start

  5. 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

  6. The easiest way to access Kubernetes API is to configure a proxy. The command iskubectl proxy --port=8000
    Visit http://localhost:8000/swagger-ui/ from the browser to access Swagger APIs

  7. However, I would like to use Kubernetes Python Client. I installed by pip install kubernetes

  8. Here is the sample code

  9. 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

  10. Visit localhost with correct port

  11. A good post about using Python client and Here is a post about developing kubernetes friendly containerized application

Post a Comment

0 Comments