Using http proxies in openshift java projects

To use http proxies with java in openshift you should know:

– that tools like maven don’t honor http_proxy & co environment variables
– that each container image has its own build script (assemble) that does or does NOT take http_proxy into account.

Always check the image documentation if you need proxies:

– https://docs.openshift.com/online/using_images/s2i_images/java.html
– https://access.redhat.com/solutions/1758313
– https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/red_hat_jboss_enterprise_application_platform_for_openshift/configuring_eap_openshift_image#configuring_eap_env_vars

A general and flexible solution is:

– to provide a configuration/settings.xml in your project, eg.

github.com/ioggstream/java-project.git
– pom.xml
– src/
– configuration/settings.xml
– add in settings.xml

openshift interpolates every *PROXY* environment variable stripping stuff, so you may not always be able to do


${env.HTTP_PROXY_HOST}

JBoss images support the following variables via the `assemble` script:

– HTTP*_PROXY_HOST
– HTTP*_PROXY_PORT

Another solution is to:

– get the assemble from the given image you’re using (different images, different assemble)
– customize it so that it uses environment variables to build a custom settings.xml to be used within the build
– add it to .s2i/bin/assemble

Here’s an example assemble supporting proxies https://github.com/ivanthelad/openshift-jee-sample/blob/jws/.sti/bin/assemble

February 25 2018 | Politica | Comments Off on Using http proxies in openshift java projects

Smoke testing openshift with ansible-galaxy

The ansible-galaxy ioggstream.ocp_health role can run a smoke test on openshift in minutes:

– etcd consistency
– rhn subscriptions
– master status
– registry, ipfailover and router instances

NOTE: it’s not a replacement of oadm diagnostics 😉

ansible-galaxy install ioggstream.ocp_health
# eventually tweak parameters
# vi /root/.ansible/roles/ioggstream.ocp_health/tests/ocp_health.yml
ansible-playbook –check /root/.ansible/roles/ioggstream.ocp_health/tests/ocp_health.yml

If you want to create a test project with two apps, one with a PVC and one with an ephemeral, set create_test_project.

ansible-playbook -v -e create_test_project=yes /root/.ansible/roles/ioggstream.ocp_health/tests/ocp_health.yml

November 25 2017 | Politica | Comments Off on Smoke testing openshift with ansible-galaxy

Brief Openshift troubleshooting

If you have issues after an automagic openshift-on-openstack deployment:

1. Remember: every buildconfig created *before* the registry is not authorized to push the images

2. Remember: hawkular is a java application. Startup is slow. Just click there and wait for the startup

3. Ansible is your friend. To get container logs, just

ansible all -m shell -a ‘ls /var/log/containers/CONTAINER_NAME*’

ansible all -m shell -a ‘cat /var/log/containers/CONTAINER_NAME*’ > CONTAINER_NAME.log

4. If a container don’t startup during the deployment, a broken image may have been downloaded

Jun 1 23:30:36 dev-7-infra-0 atomic-openshift-node: I0601 23:30:36.234103 32913 server.go:608] Event(api.ObjectReference{Kind:”Pod”, Namespace:”default”, Name:”router-1-deploy”, UID:”033670a9-470e-11e7-878f-fa163eac2bf7″, APIVersion:”v1″, ResourceVersion:”936″, FieldPath:””}): type: ‘Warning’ reason: ‘FailedSync’ Error syncing pod, skipping: failed to “StartContainer” for “POD” with RunContainerError: “runContainer: Error response from daemon: {\”message\”:\”invalid header field value \\\”oci runtime error: container_linux.go:247: starting container process caused \\\\\\\”exec: \\\\\\\\\\\\\\\”/pod\\\\\\\\\\\\\\\”: stat /pod: no such file or directory\\\\\\\”\\\\n\\\”\”}”

Cleanup docker repo

docker ps -aq | xargs docker rm
docker rmi 90e9207f44f0 –force

5. Run oadm diagnostics on the master 😉

6. Check #oc get hostsubnet

June 01 2017 | Politica | Commenta per primo! »