Search This Blog

Showing posts with label cloud. Show all posts
Showing posts with label cloud. Show all posts

Thursday, March 7, 2019

cloud foundry resource exhaustion event

If you are trying to push a simple java app using java build pack which uses openjdk 8
and you are facing an issue of resource exhaustion it could be because of bad memory
paramters. try increasing the XX:MaxMetaspaceSize if your Jar is big in size.

for e.g your Jar is 90 mb it should be atleast 200 mb, i wasted lot of time on this.
This parameter you can set in app setttings on pcf , under user environment variables.
restage and it should not give you resource exhausted warnings...

symtom logs

//////////////

 Internal Error (javaCalls.cpp:53), pid=xx, tid=xxxxxxxxxxxxxxxxxxxxx
2017-10-11T17:05:31.80+0200 [APP/PROC/WEB/3]OUT # JRE version: OpenJDK Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
2017-10-11T17:05:31.80+0200 [APP/PROC/WEB/3]OUT # Java VM: OpenJDK 64-Bit Server VM (25.144-b01 mixed mode linux-amd64 compressed oops)
2017-10-11T17:05:31.80+0200 [APP/PROC/WEB/3]OUT # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
2017-10-11T17:05:31.80+0200 [APP/PROC/WEB/3]OUT #

pcf tcp routing ... will make you cry..

tcp routing in pcf can be a pain in the A*** believe me..
here is what you can do .. if you app spring or whatever is listening on a port like 8080 
exposed from SERVER_PORT=$PORT via buildpack .. which can also be configured in application.properties 
of boot like server.port = 9080 or whatever.

Point is , if http app then pcf will directly route traffic via route to your app on 80/443 else you will have to create
tcp domain and route and a router group , can use default tcp router group and get the traffic on non tcp port.

also you can see if you can run your non http app on 443 if thats possible.
if you are bound to use some other port, you gotta configure all th is.

you can ssh in the cf app using cf ssh app name and do a netstat -an and ps-ef to see which 
port your app is listening to also you directly run java via the /app/.java_buildpack/.././java -cp and your main file name 
if you have a normal java app and you are listening to a port inside your code..

i tried to curl from outside container  to a spring hello world and it will let me curl the https endpoint even 
though the boot was running on 8008 on container.. and when i was trying to run a java jar listening on 9877 
it will let me curl the end point https one but it will give 502 bad gateway.. i guess because the endpoint is expecting 
non http traffic ,, i mean tcp traffic .. and cf router gives bad gateway error..

point is... get the admin rights and configure tcp routing.. or find if your app can run on 443/80 even if tcp traffic.. try it.. 



Tuesday, March 5, 2019

How to configure pivotal cloud foundry onperm/laptop

If you have trial limitation with pcf trial account and you are not able to host anything due to resource constraints
you can configure the pivotal onperm single node virtual machine using the pcfdev.

Prerequisites 
Windows laptop 8 Gb ram and Virtual box 5.2 and  pcfdev plugin download from pivotal
make sure you get 30 version , lot of bugs are fixed in it. also cf cli is required

Now go to folder where pcfdev downloaded extracted // do not run pcfdev on a VM else it wont work
and run the powershell in admin mode before starting dev 
cf install-plugin cfdev
cf dev start // it will take ages like an hour or so let all services run 
if all is well you should see 58 of 58 services started , hello message else break your head 
cf dev ssh will land you inside the machine , it will provision in VB 
To debug ssh to dev using cf dev ssh -- /var/vcap/monit folder and sudo tail the monit.log 
also you can grep the drain and other libraries in the /var/pcfdev/run.log
check here  /var/vcap/sys/log/syslog_drain_binder/syslog_drain_binder.log
admin/admin is the cred to login to the api end point 
cf login -a  api.local.pcfdev.io  --skip-ssl-validation // user and pass should work .. 
you will be able to see org/quota/space 
cf create-space myspace -o orgname
cf target -s myspace
now push
create a space and push you app by cf push -f manifest.yml 
sample manifest.yml 
applications:  - name: fixserver    memory: 1024M    buildpack: https://github.com/cloudfoundry/java-buildpack.git    path: server.jar    hostname: fixserver    health-check-type: process  
health check type of process will help your app to boot atleast else it will check that port 
and mark your app as failure.

It should push you app to pcf cloud , now you can login to dash of pcf and see the logs 
also from command line 
cf logs fixserver // you can also ssh to app container by cf ssh appname

docker push appname --docker-image url  from hub
cf enable-feature-flag diego_docker    

Heroku clone a running up and update it with cli

Download the heroku cli and change the ssh keys if you have a previous installation of keys from some other account
 $heroku auth:logout
$heroku auth:login 
 Openweb page and authenticate with your creds, it will log you in.

download your code from a running app with 

heroku git:clone -a APP-NAME

Do a  git add .   // if you have changed a file
git commit -m "dfd"
git push heroku master.

You can see your updated app after the push is complete 

Tuesday, January 8, 2019

How to run a jar file as an image in openshift.

Boot your docker host, it will be a boot to docker iso booted over virtual box.

Get the jar first, either make a runnable jar in eclipse or create one with jar -cfm commands.

Once jar is ready make a simple docker file but make sure you have right permissions of
the mounts else it will work fine in docker bu tnot in openshift.


sample docker file.
FROM java:8
WORKDIR /app
RUN chgrp -R 0 /app && \
    chmod -R g=u /app
ADD server.jar server.jar
EXPOSE 9877
CMD java -jar server.jar


now using winscp on 22 transfer this docker file jar to the docker host / username docker/tcuser (default)
Now run a build  from that directory

docker buid -t fixserver .

now try to run
docker run -i -t -p 9877:9877 fixserver


if it runs fine , push it to docker, just login and push but make
sure tag is as per standard docker.io/uname/image:latest

Now run minishift in c drive , i mean open cmd and run minishift --vm-drive virtualbox start
make nodosfilewarning flag also if using cygwin.

now open the console, minishift console enter.. usually 

Now add to project , deploy an image , take second opotion 
search for the image url in docker.io/uname/imagename

it will give warning for root, continue with the deployment ..
and expose it via route or as external service on the node port

e.g $ oc expose dc mariadb --type=LoadBalancer --name=mariadb-ingress

$ oc export svc mariadb-ingressit will open a port on the node some random port, and it will start routing to pod port

check the binding on oc get svc

do a telnet from laptop to to the minishift vm host ip on that random port

it should listen to your service on that port and will rout it to any of the pod.


Ref.

sudo docker exec -i -t b359ba5cb67f  /bin/bash   loginto a container


















docker image not running on openshift giving file not found

If your docker image which was running earlier on raw container fails to boot
on openshift and starts giving file not found error or directory not found error.

You need to check the permissions, your root account enabled image
will not work on openshift and you will have to rewrite docker file with 
approppriate user/directories and permissions. 

The mounts will have to be writable, this kind of problems are not there
when running under root inside docker.

Monday, March 19, 2018

Run a docker image on Openshift training environment from dockerhub

Get the client VM and the shared environment access, we will use client VM only to connect to the Openshift environment.

Note. IF you dont use shared environment access, you won't see an option to create the project in the console.

Create a new project from the console and search the image from the deploy image option.
Create the image in the openshift environment.
Create the route and map the application port, check route YAML for more information.
Access the application , make sure you use it directly and don't specify the port.

E.g if you bound 8001-->8001 of container try the http://routeurl:contextroot only