<p>I am trying to push spring boot application in google kubernetes(Google Container Engine).</p>

<p>I have performed all the step which given in below link.</p>

<p><a href="https://codelabs.developers.google.com/codelabs/cloud-springboot-kubernetes/index.html?index=..%2F..%2Findex#0" rel="nofollow noreferrer">https://codelabs.developers.google.com/codelabs/cloud-springboot-kubernetes/index.html?index=..%2F..%2Findex#0</a></p>

<p>When i am trying to perform step 9 http://:8080 in browser that is not reachable.</p>

<p>Yes i got external ip address.</p>

<p>I am able to ping that ip address</p>

<p>let me know if any other information is require.</p>

<p>In Logging that does not able to connect database</p>

<p>Error: </p>

<p><code>com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.</code></p>

<p><strong>I hope you have created cluster in google container engine</strong></p>

<p>Follow the first 5 step given in this link </p>

<p><a href="https://cloud.google.com/sql/docs/mysql/connect-container-engine" rel="nofollow noreferrer">https://cloud.google.com/sql/docs/mysql/connect-container-engine</a></p>

<p>change database configuration in your application</p>

<p><code>hostname: 127.0.0.1
port: 3306 or your mysql port
username: proxyuser</code></p>

<p> should be same as link step - 3</p>

<ol>
<li>mvn package -Dmaven.test.skip=true</li>
<li><p>Create File with name "Dockerfile" and below content</p>

<p><code>FROM openjdk:8
COPY target/SpringBootWithDB-0.0.1-SNAPSHOT.jar /app.jar
EXPOSE 8080/tcp
ENTRYPOINT ["java", "-jar", "/app.jar"]</code></p></li>
<li><p>docker build -t gcr.io//springbootdb-java:v1 .</p></li>
<li><p>docker run -ti --rm -p 8080:8080 gcr.io//springbootdb-java:v1</p></li>
<li><p>gcloud docker -- push gcr.io//springbootdb-java:v1</p>

<p><strong>Follow the 6th step given in link and create yaml file</strong></p></li>
<li><p>kubectl create -f cloudsql_deployment.yaml</p>

<p><strong>run kubectl get deployment and copy name of deployment</strong> </p></li>
<li><p>kubectl expose deployment  --type=LoadBalancer</p></li>
</ol>

<hr>

<p>My Yaml File</p>

<p><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: conversationally
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: conversationally
    spec:
      containers:
        - image: gcr.io/&lt;project ID&gt;/springbootdb-java:v1
          name: web
          env:
            - name: DB_HOST
              # Connect to the SQL proxy over the local network on a fixed port.
              # Change the [PORT] to the port number used by your database
              # (e.g. 3306).
              value: 127.0.0.1:3306
            # These secrets are required to start the pod.
            # [START cloudsql_secrets]
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: password
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: username
            # [END cloudsql_secrets]
          ports:
            - containerPort: 8080
              name: conv-cluster
        # Change [INSTANCE_CONNECTION_NAME] here to include your GCP
        # project, the region of your Cloud SQL instance and the name
        # of your Cloud SQL instance. The format is
        # $PROJECT:$REGION:$INSTANCE
        # Insert the port number used by your database.
        # [START proxy_container]
        - image: gcr.io/cloudsql-docker/gce-proxy:1.09
          name: cloudsql-proxy
          command: ["/cloud_sql_proxy", "--dir=/cloudsql",
                    "-instances=&lt;instance name&gt;=tcp:3306",
                    "-credential_file=/secrets/cloudsql/credentials.json"]
          volumeMounts:
            - name: cloudsql-instance-credentials
              mountPath: /secrets/cloudsql
              readOnly: true
            - name: ssl-certs
              mountPath: /etc/ssl/certs
            - name: cloudsql
              mountPath: /cloudsql
        # [END proxy_container]
      # [START volumes]
      volumes:
        - name: cloudsql-instance-credentials
          secret:
            secretName: cloudsql-instance-credentials
        - name: ssl-certs
          hostPath:
            path: /etc/ssl/certs
        - name: cloudsql
          emptyDir:
      # [END volumes]
</code></p>

<p>===========</p>
