Google Container Engine (Kubernetes) and OAuth2 Callback

8/28/2017

I am deploying the sample bookshelf node app (https://cloud.google.com/nodejs/tutorials/bookshelf-on-container-engine). This app does OAUTH2 callback.

My question is where do I get the IP Address of the Load Balancer and does it change every time I push a new docker image? Can I specify a DNS Entry for the LB and use that to register in the Google Oauth2 callback.

  "OAUTH2_CALLBACK": "http://<service ip address>/auth/google/callback",

Here is my service.yaml file

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

Thanks,

-- Rajesh Jain
google-kubernetes-engine
google-oauth2
kubernetes

1 Answer

8/28/2017

If you already have kubectl configured to access your cluster, you should be able to find the ip address of the service with:

$ kubectl get services

A Service is separate from actual Deployment. The cluster-ip of the service will not change unless you make changes to the Service.

If you are accessing a service internally, you can specify the service name rather than cluster-ip address.

E.g,

$ kubectl get services
NAME                      CLUSTER-IP     EXTERNAL-IP      PORT(S)                      AGE
elasticsearch             10.3.247.13    <none>           9200/TCP                     9d

A deployment config accessing this service:

output {
    elasticsearch {
        hosts => "elasticsearch:9200"
    }
}
-- PoorBob
Source: StackOverflow