Rails 5, Kubernetes and Google Container Engine

4/28/2017

I'm making tests for a new infrastructure in my company, and I'm stucked.

I have a dockerized spike project with Rails 5.1, that I'm trying to deploy via Google Container Engine. I read everything I could, but I can't get anything out of my IP adress.

The docker image of my rails app is correctly stored in the google cloud registry.

When I launch kubectl get services I get

NAME              CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
spikedocker-web   10.3.244.145   xx.xxx.xx.xxx   80:32021/TCP   17m

When I kubectl get deployments I get

NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
spikedocker-web   2         2         2            2           1h

When I kubectl get pods I get

NAME                              READY     STATUS    RESTARTS   AGE
spikedocker-web-506778213-djwb5   1/1       Running   0          1h
spikedocker-web-506778213-xxbtm   1/1       Running   0          1h

When I kubectl logs spikedocker-web-506778213-djwb5 I get

=> Booting Puma
=> Rails 5.1.0.rc1 application starting in production on 
http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.8.2 (ruby 2.4.1-p111), codename: Sassy Salamander
* Min threads: 5, max threads: 5
* Environment: production
* Listening on tcp://0.0.0.0:80
Use Ctrl-C to stop

For what I know, all of this seems fine. I can ping my IP xx.xxx.xx.xxx, but that's it, nothing to see on port 3000.

My configuration use these two files, web-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: spikedocker-web
  labels:
    app: spikedocker-web
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: http-server
  selector:
    app: spikedocker-web

and web-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: spikedocker-web
  labels:
    app: spikedocker-web
spec:
  replicas: 2
  template:
    metadata:
      labels:
        run: spikedocker-web
    spec:
      containers:
      - name: spikedocker-web
        image: eu.gcr.io/[my-app-id]/spike-docker-web:latest
        imagePullPolicy: Always
        ports:
        - name: http-server
          containerPort: 80

Edit

Return of kubectl describe service:

Name:           kubernetes
Namespace:      default
Labels:         component=apiserver
            provider=kubernetes
Annotations:        <none>
Selector:       <none>
Type:           ClusterIP
IP:         10.3.240.1
Port:           https   443/TCP
Endpoints:      104.199.75.222:443
Session Affinity:   ClientIP
Events:         <none>

Name:           spikedocker-web
Namespace:      default
Labels:         app=spikedocker-web
Annotations:        <none>
Selector:       app=spikedocker-web
Type:           LoadBalancer
IP:         10.3.244.145
LoadBalancer Ingress:   35.187.79.219
Port:           <unset> 80/TCP
NodePort:       <unset> 32021/TCP
Endpoints:      <none>
Session Affinity:   None
Events:         <none>
-- Ruff9
docker
google-kubernetes-engine
kubernetes
ruby
ruby-on-rails

0 Answers