Spring Boot + google kubernetes + Google SQL Cloud not working -
i trying push spring boot application in google kubernetes(google container engine).
i have performed step given in below link.
when trying perform step 9 http://:8080 in browser not reachable.
yes got external ip address.
i able ping ip address
let me know if other information require.
in logging not able connect database
error:
com.mysql.jdbc.exceptions.jdbc4.mysqlnontransientconnectionexception: not create connection database server.
i hope have created cluster in google container engine
follow first 5 step given in link
https://cloud.google.com/sql/docs/mysql/connect-container-engine
change database configuration in application
hostname: 127.0.0.1 port: 3306 or mysql port username: proxyuser
should same link step - 3
- mvn package -dmaven.test.skip=true
create file name "dockerfile" , below content
from openjdk:8 copy target/springbootwithdb-0.0.1-snapshot.jar /app.jar expose 8080/tcp entrypoint ["java", "-jar", "/app.jar"]
docker build -t gcr.io//springbootdb-java:v1 .
docker run -ti --rm -p 8080:8080 gcr.io//springbootdb-java:v1
gcloud docker -- push gcr.io//springbootdb-java:v1
follow 6th step given in link , create yaml file
kubectl create -f cloudsql_deployment.yaml
run kubectl deployment , copy name of deployment
kubectl expose deployment --type=loadbalancer
my yaml file
apiversion: extensions/v1beta1 kind: deployment metadata: name: conversationally spec: replicas: 1 template: metadata: labels: app: conversationally spec: containers: - image: gcr.io/<project id>/springbootdb-java:v1 name: web env: - name: db_host # connect sql proxy on local network on fixed port. # change [port] port number used database # (e.g. 3306). value: 127.0.0.1:3306 # these secrets required start 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 include gcp # project, region of cloud sql instance , name # of cloud sql instance. format # $project:$region:$instance # insert port number used database. # [start proxy_container] - image: gcr.io/cloudsql-docker/gce-proxy:1.09 name: cloudsql-proxy command: ["/cloud_sql_proxy", "--dir=/cloudsql", "-instances=<instance name>=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]
===========
Comments
Post a Comment