I have deployed a docker application onto my docker hub https://hub.docker.com/r/leexha/nodejsapp/.
I verfiied this by doing a docker pull and did a docker run docker run -p 8000:3000 index.docker.io/leexha/nodejsapp:latest
I am trying to deploy this into kubernetes. This is my deploy.yml
file:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: secondapp
spec:
replicas: 3
template:
metadata:
labels:
app: webapp
spec:
containers:
- name: webapp
image: index.docker.io/leexha/nodejsapp
ports:
- containerPort: 3000
resources:
requests:
memory: 500Mi
cpu: 0.5
limits:
memory: 500Mi
cpu: 0.5
imagePullPolicy: Always
I then exposed the deployment as a service:
C:\Users\adrlee\Desktop\oracle\Web_projects>kubectl get nodes
NAME STATUS ROLES AGE VERSION
xxxxxxxxxxx Ready node 1d v1.8.11
yyyyyyyyyyy NotReady node 1d v1.8.11
zzzzzzzzzzz Ready node 1d v1.8.11
C:\Users\adrlee\Desktop\oracle\Web_projects>kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
firstapp 3 3 3 3 6m
C:\Users\adrlee\Desktop\oracle\Web_projects>kubectl expose deployment/firstapp --type="NodePort" --port 3000
service "firstapp" exposed
C:\Users\adrlee\Desktop\oracle\Web_projects>kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
firstapp NodePort 10.96.156.3 <none> 3000:31872/TCP 10s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1d
It seems everything is in order however when I try to access my application on the cluster (:3000) it can't be access.
So I tried to do a bit of debugging.
I did:
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}} {{.metadata.name}}{{"\n"}}{{end}}')
and I did a curl
curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/
I notice this response:
}
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0cu rl: (6) Could not resolve host: firstapp-f85d8f76c-bqsst
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0cu rl: (6) Could not resolve host: firstapp-f85d8f76c-txlng
Little lost what to do now. Would appreciate any help?
If you set the type field to NodePort, the Kubernetes master will allocate a port from a range specified by --service-node-port-range
flag (default: 30000-32767) in kube-apiserver
Try with a port in this default range or check the kube-apiserver service on your master for the specific custom range.