I have a simple NodeJS app I've created an image of. I can start it and talk to it locally: docker run -p 80:80 -it --rm --name test gcr.io/XXX/XXX:0.1
$ curl docker => Unauthorized
As expected.
webservice-replication-controller.yml:
apiVersion: v1
kind: ReplicationController
metadata:
name: harvester-webservice
spec:
replicas: 2
selector:
app: harvester-webservice
template:
metadata:
labels:
app: harvester-webservice
spec:
containers:
- name: harvester-webservice
image: gcr.io/XXX/XXX
ports:
- containerPort: 80
webservice-service.yml
apiVersion: v1
kind: Service
metadata:
name: harvester-webservice
labels:
name: harvester-webservice
spec:
type: LoadBalancer
ports:
-
port: 80
targetPort: 80
protocol: TCP
selector:
name: harvester-webservice
I've started the cluster as following:
$ kubectl create -f webservice-service.yml
$ kubectl create -f webservice-replication-controller.yml
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
harvester-webservice-controller-8qmkl 1/1 Running 0 11m
harvester-webservice-controller-chnky 1/1 Running 0 11m
$ kubectl get services
NAME LABELS SELECTOR IP(S) PORT(S)
harvester-webservice name=harvester-webservice name=harvester-webservice 10.NN.NN.NN 80/TCP
104.NN.NN.NN
kubernetes component=apiserver,provider=kubernetes <none> 10.NN.NN.NN 443/TCP
$ kubectl get rc
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
harvester-webservice-controller harvester-webservice gcr.io/XXX/XXX app=harvester-webservice 2
curl 104.NNN.NNN.NNN
returns: curl: (56) Recv failure: Connection reset by peer
curl 10.NNN.NNN.NNN
just hangs
The logs are as they should when I ssh into the container and do a docker logs
on the Node app.
All tips or suggestions are highly appreaciated!
$ kubectl get endpoints
NAME ENDPOINTS
harvester-webservice <none>
kubernetes 104.NN.NN.NN:443
Best, Martin
Change the selector in webservice-service.yml
to app: harvester-webservice
so that it matches the label in webservice-replication-controller.yml
.
See also Services in Kubernetes.