GCloud: unable to listen on the Port defined by env variable - continuous-integration

I am trying to deploy on Google Cloud Platform for the first time using the following two tutorials:
Gcloud build quickstart
Gcloud deploy quickstart
However, when running the final command gcloud builds submit --config cloudbuild.yaml, where cloudbuild.yaml is the name of the yaml file as per tutorial, throws the following error:
Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.

The image created by the build quickstart is not appropriate for the deploy quickstart. The latter, using Cloud Run needs something talking HTTP on port 8080.
If you using the deploy quickstart as-is, that should work. You can test this container image locally using:
docker run \
--interactive --tty \
--publish=8080:8080 \
gcr.io/gcbdocs/hello
and then try browsing or curling the endpoint http://localhost:8080. You should see Hello world!.
The error message from Cloud Run is somewhat generic and means that something went wrong. As a result it's often unhelpful.
If you're confident you're deploying a container image that talks HTTP on port 8080, I recommend you step through the instructions to try to see where you went wrong.

Related

Sequelize migrations - Google cloud build trigger

I am currently trying to host a typescript/sequelize project in Google cloud build.
I am connecting through a unix socket and cloud sql proxy.
The app is deployed and a test running "sequelize.authenticate()" seems to be working.
Migrations to localhost seems to be working aswell.
I have written a cloud build trigger that does the following:
-builds a simple docker image
-pushes the simple docker image
-npm install
-downloads the cloud_sql_proxy
-initiates the cloud_sql_proxy
the next step would be to migrate a simple table to my gcloud database.
please check out my drawing for further details: https://excalidraw.com/#json=LnvpSjngbk7h1F0RzBgUP,HPwtVWgh-sFgrmvfU9JK0A
If i try to run "npx sequelize-cli db:migrate" gcloud gives the following message: [31mERROR:[39m connect ENOENT /cloudsql/xxxxxxx/.s.PGSQL.5432
but if i replace the command with npx sequelize-cli --version, it simply prints out the version and moves on with the rest of the trigger operations.

How can I make sure that Cloud Run waits for my Spring Boot application to start before denying the health check?

I am deploying my Spring Boot application as a compiled jar file running in a docker container deployed to gcp, and deploys it through gcloud cli in my pipeline:
gcloud beta run deploy $SERVICE_NAME --image $IMAGE_NAME --region europe-north1 --project
Which will work and give me the correct response when the application succeeds to start. However, when there's an error and the application fails to start:
Cloud Run error: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable.
The next time the pipeline runs (with the errors fixed), the gcloud beta run deploy command fails and gives the same error as seen above. While the actual application runs without issues in Cloud Run. How can I solve this?
Currently I have to check Cloud Run manually as I cannot trust my pipeline, and I have to run it twice to make it succeed. Any help will be appreciated. Let me know if you want any extra information.

Cloud Run: deploying spring docker image causing error; Failed to start and then listen on the port defined by the PORT environment variable

I am trying to deploy spring boot docker image stored at Docker Registry to Cloud Run.
However, when I deployed the image, I got the error;
Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.
I understand this could be caused by port and address setting, so I fixed these parts referring the official doc, though still experiencing the same error. Concretely, I set these things as below, on application.yml.
server:
port: ${PORT:8080}
address: ${ADDRESS:localhost}
I understand PORT variable would be passed by Cloud Run(in my case, port num is set to 8080 on Cloud Run). And also ADDRESS will be passed to by myself(the value is 0.0.0.0, referring the official doc).
For reference, the below is my Dockerfile building spring boot docker image;
# Stage1 - execute build process
FROM openjdk:14-jdk-alpine as build_process
WORKDIR /back_end
COPY . .
RUN ./gradlew build -x test
# Stage2 - boot app with the build output above
FROM openjdk:14-jdk-alpine
EXPOSE ${PORT}
COPY --from=build_process /back_end/build/libs/back_end-0.0.1-SNAPSHOT.jar ./app.jar
RUN adduser -D user
USER user
ENTRYPOINT ["sh","-c","java -jar app.jar"]
Any help would be really appreciated. Thank you so much for reading!
I figured it out why my docker image had failed Cloud Run's health check. After all, it is not about Port and IP address, but about the timing when the health check process executes.
The health check process seems to start immediately once the image is deployed, though my case it took almost 30 secs to launch spring boot tomcat server after deploying to Cloud Run.
That led to the failure of the health check process, so I fixed settings to launch tomcat server immediately too, which solved the issue I posted.

Deploy API REST IBM Hyperledger Composer Blockchain

I'm developing a POC over IBM HyperLedger Blockchain. I have a business network developed and deployed in IBM Cloud. I can generate a working local API REST, but cannot make it work on cloud, on the deployed IP.
I'm following this guide:
https://ibm-blockchain.github.io/interacting/
You just have to execute the following command:
./create/create_composer-rest-server.sh --business-network-card MY_BIZNET_CARD_NAME
But it doesn't deploy anything, and get the following (more related to kubernetes than blockchain).
Preparing yaml file for create composer-rest-server
Creating composer-rest-server pod
Running: kubectl create -f /Users/sm/jsblock/ibm-container-service/cs-offerings/scripts/../kube-configs/composer-rest-server.yaml
The connection to the server localhost:8080 was refused - did you specify the right host or port?
the server doesn't have a resource type "svc"
Creating composer-rest-server service
Running: kubectl create -f /Users/sm/jsblock/ibm-container-service/cs-offerings/scripts/../kube-configs/composer-rest-server-services-free.yaml
The connection to the server localhost:8080 was refused - did you specify the right host or port?
Composer rest server created successfully
Any ideas? Thanks too much.
You need to ensure you have a correct kube config setup. Step 10 in https://ibm-blockchain.github.io/setup/ provides the details to set up KUBECONFIG as the error suggests that either it is not configured or not configured correctly.
The document you refer to https://ibm-blockchain.github.io/interacting/ is being updated and should be available soon.
When you run the command ./create/create_composer-rest-server.sh --business-network-card MY_BIZNET_CARD_NAME - should be the name of the Network Admin for the network you deployed, NOT the PeerAdmin card so it will be something like ./create/create_composer-rest-server.sh --business-network-card admin#perishable-network
Look like it's an issue of acceess control. You should make sure again you are running with Local Admin configuration.it will help you to run queries

Deploying Lagom Microservices on Kubernetes

I'm trying to deploy Lagom microservices on Kubernetes by following-up the Chirper Lagom example. So According to the provided guide link, I configured a kubernetes cluster by installing Minikube and everything is good.
But when I tried to build Chirper Docker images by using fabric8’s docker-maven-plugin, I got this error:
[ERROR] Failed to execute goal
io.fabric8:docker-maven-plugin:0.20.1:build (default-cli) on project
friend-impl: Execution default-cli of goal
io.fabric8:docker-maven-plugin:0.20.1:build failed: No
given, no DOCKER_HOST environment variable, no read/writable
'/var/run/docker.sock' or '//./pipe/docker_engine' and no external
provider like Docker machine configured -> [Help 1]
Is there anyone that can help me to understand that error? Thanks.
[Updating based on discussions in comments]
The issue here is that the Docker CLI is not able to reach the Docker Engine. Since you are using Minikube, you can point docker CLI to Docker engine inside Minikube. That will ensure that images are built inside minikube VM and also ran there subsequently. You can run command:
eval $(minikube docker-env)
This command will set the parameters required by Docker CLI to communicate with Docker engine in Minikube and it should be able to run command which is failing for you!

Resources