0

I've followed the GKE ruby bookshelf example and referenced the kubernetes examples. While I have resources deployed, I cannot ping my rails frontend node. I implemented a simple ping route to test the most basic connectivity.

I have decreased replicas to 1 to simplify things, and grabbed the logs from the node to confirm that it is up and running without any errors present.

> wget http://104.154.128.169/ping
--2017-09-15 14:14:54--  http://104.154.128.169/ping
Connecting to 104.154.128.169:80... failed: Connection refused.

Config

apiVersion: v1
kind: Service
metadata:
  name: foo-frontend
  labels:
    app: foo
    tier: frontend
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: foo
    tier: frontend
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: foo-frontend
  labels:
    app: foo
    tier: frontend
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: foo
        tier: frontend
    spec:
      containers:
      - name: foo-app
        image: us.gcr.io/foo/api:latest
        imagePullPolicy: Always
        env:
        - name: FORMATION
          value: web=1
        - name: RAILS_ENV
          value: production
        - name: RACK_ENV
          value: production
        - name: RAILS_LOG_TO_STDOUT
          value: enabled
        - name: RAILS_SERVE_STATIC_FILES
          value: "true"
        - name: SECRET_KEY_BASE
          valueFrom:
            secretKeyRef:
              name: production-secrets
              key: SECRET_KEY_BASE
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: production-secrets
              key: DB_PASSWORD
        ports:
        - containerPort: 8080

Dockerfile

snippet

EXPOSE 8080/tcp

CMD bundle exec foreman start --formation "$FORMATION"

Procfile

web: bundle exec rackup --port 8080
worker: bundle exec rake run_worker

Status

> kubectl get pods; kubectl get services

NAME                                READY     STATUS    RESTARTS   AGE
foo-frontend-284775361-4pzk3   1/1       Running   0          9m
NAME                CLUSTER-IP      EXTERNAL-IP       PORT(S)        AGE
foo-frontend   10.15.246.177   104.154.128.169   80:30917/TCP   9m
kubernetes          10.15.240.1     <none>            443/TCP        22h

And

> kubectl describe service
Name:           foo-frontend
Namespace:      default
Labels:         app=foo
            tier=frontend
Annotations:        <none>
Selector:       app=foo,tier=frontend
Type:           LoadBalancer
IP:         10.15.246.177
LoadBalancer Ingress:   104.154.128.169
Port:           <unset> 80/TCP
NodePort:       <unset> 30917/TCP
Endpoints:      10.12.2.13:80
Session Affinity:   None
Events:
  FirstSeen LastSeen    Count   From            SubObjectPath   Type        Reason          Message
  --------- --------    -----   ----            -------------   --------    ------          -------
  10m       9m      2   service-controller          Normal      CreatingLoadBalancer    Creating load balancer
  9m        9m      2   service-controller          Normal      CreatedLoadBalancer Created load balancer


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

TL;DR

  1. Can you spot any errors in my config?
  2. What is the best next step in debugging? (or any other advice)
kross
  • 133

1 Answers1

2

I believe the key problem was I did not specify a targetPort in the service. I setup a compute static ip as well with gcloud compute addresses create foo-frontend-ip --region=us-central1, so either way, it was one of the two.

apiVersion: v1
kind: Service
metadata:
  name: foo-frontend
  labels:
    app: foo
    tier: frontend
spec:
  type: LoadBalancer
  # use your external IP here
  loadBalancerIP: x.x.x.x
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
  selector:
    app: foo
    tier: frontend
kross
  • 133