- Build a custom docker image using Dockerfile:
docker build -t python/server .
- Test the image:
docker run -i -t -p 8000:8000 python/server
curl http://localhost:8000
- Deploy on Kubernetes
kubectl create -f myapp.yaml
- Look around:
[dims@ubuntu-brix 17:30] ~/Downloads ⟩ kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-jxd9f 1/1 Running 0 47s
[dims@ubuntu-brix 17:30] ~/Downloads ⟩ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.0.0.1 <none> 443/TCP 3h
myappsvc 10.0.0.74 nodes 8000/TCP 52s
[dims@ubuntu-brix 17:30] ~/Downloads ⟩ kubectl get replicationcontrollers
NAME DESIRED CURRENT AGE
myapp 1 1 56s
- Test the app:
curl -kvs 10.0.0.74:8000
- Alternate to step #3:
kubectl run myapp-node --image=python/server --port=8000
kubectl expose deployment myapp-node --port=8000 --name=myapp-node-http
kubectl describe pods
Thanks for the gist. This helped a lot.
I encountered
errimagepull
since I wanted to load from worker node but the image was in my master node.I got it working by running a local image register.
and I loaded it with
image: localhost:5000/server
based on this post