How can I choose a name for my application on OpenShift - kubernetes

I deployed my application on Openshift using the commands:
oc project <projectname>
Then I navigate to my application's directory and use the command:
mvn fabric8:deploy -Popenshift
This deploys to Openshift perfectly.
The only problem is that it automatically names my application and I am not sure where it is getting the name from. I want to change it to [app-name]-test, [app-name]-dev, etc
So, where does it get the application name from and how can I change it?

It's usually in your fabric8 XML configuration (pom.xml). For example:
<configuration>
<!-- Standard d-m-p configuration which defines how images are build, i.e. how the docker.tar is created -->
<images>
<image>
<name>${image.user}/${project.artifactId}:${project.version}</name>
<!-- "alias" is used to correlate to the containers in the pod spec -->
<alias>camel-service</alias>
<build>
<from>fabric8/java</from>
<assembly>
<basedir>/deployments</basedir>
<descriptorRef>artifact-with-dependencies</descriptorRef>
</assembly>
<env>
<JAVA_LIB_DIR>/deployments</JAVA_LIB_DIR>
<JAVA_MAIN_CLASS>org.apache.camel.cdi.Main</JAVA_MAIN_CLASS>
</env>
</build>
</image>
</images>
<!-- resources to be created -->
<resources>
<!-- Labels that are applied to all created objects -->
<labels>
<group>quickstarts</group>
</labels>
<!-- Definition of the ReplicationController / ReplicaSet. Any better name than "containers" ? -->
<deployment>
<!-- Name of the replication controller, which will have a sane default (container alisa, mvn coords, ..) -->
<!-- Override here -->
<name>${project.artifactId}</name>
...
It defaults to ${project.artifactId} but you can override with whatever you'd like with something like ${project.artifactId}-dev. You can also edit the deployment manually in Kubernetes:
$ kubectl edit deployment ${project.artifactId}

Related

Possibility to access wildfly / app server libraries via jboss-deployment-structure.xml?

I have a web application running on a wildfly app server (22.X). It contains a war file which has the ability (besides the actual functionality) to query the wildfly itself for its active running sessions via JMX and display that number on an simple html page.
Originally the following dependency was added (via maven) to make this work:
<dependency>
<groupId>org.jboss.remotingjmx</groupId>
<artifactId>remoting-jmx</artifactId>
<version>3.0.4.Final</version>
However this dependency brings lots of other transitive dependencies along like jboss-marshalling, xnio, jboss-threads, wildfly-*, (...) - all packages which does exist within the wildfly app server anyway. So I was wondering whether it is possible to use those app server packages instead of bundling it as part of the war. I tried to add the following to the jboss-deployment-structure.xml to the EAR:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.3">
<deployment>
<dependencies>
<system export="true">
<paths>
<path name="sun/reflect"/>
</paths>
</system>
</dependencies>
</deployment>
<sub-deployment name="service.war">
<dependencies>
<module name="org.jboss.remoting3.remoting-jmx" services="import"/>
</dependencies>
</sub-deployment>
However it didn't work - as soon as the dependencies were removed from the war file it stopped working. My question:
Is it possible to specify/configure the deployment structure file to allow access to the necessary packages from the application server? (I know that this is a wildfly specific solution but this is intended)
It looks like this module has moved to org.jboss.remoting-jmx. The org.jboss.remoting3.remoting-jmx does export the org.jboss.remoting-jmx module in WildFly 22, however the services are not exported which could be the issue.
Either way, it's best to use the org.jboss.remoting-jmx.

JBOSS 7.2.2 External Folder Linking

I have been searching around for this specific problem of mine. We have a folder that is on a shared folder on another server "\\server1\shares\web\images" and I want to link this folder into my web application in Jboss 7.2.2. I'm migrating from Jboss 4.2.2 to Jboss 7.2.2.
Here is my server.xml file from Jboss 4.2.2. You'll notice that the <Context> tag handles this link for me.
<Server>
<Service name="jboss.web">
<!-- ... -->
<Engine name="jboss.web" defaultHost="localhost">
<!-- ... -->
<Host name="myApp" autoDeploy="false" deployOnStartup="false"
deployXML="false" configClass="org.jboss.web.tomcat.security.config.JBossContextConfig">
<!-- ... -->
<Context path="/images" appBase="" docBase="\\server1\shares\web\images"
debug="99" reloadable="true" />
<!-- ... -->
</Host>
</Engine>
</Service>
My research has lead me to use modules, but I cannot figure out how to use the modules properly for this problem. Most examples shows how to provide some link to a folder on the same machine as the Jboss server is on.
So, am I suppose to use modules or is there another way of doing this?

Wildfly Maven Plugin ignores deployment name?

I added the name parameter on my deployment using Wildfly Maven Plugin:
mvn wildfly:deploy -Dname=myapp -Dwildfly.hostname=myserver -Dwildfly.username=user -Dwildfly.password=pwd
However, it keeps on deploying with the Maven version and extension.
Here's how it looks in standalone.xml
<deployment name="myapp-1.1-SNAPSHOT.war" runtime-name="myapp-1.1-SNAPSHOT.war">
<content sha1="17e09de2cd8f78ffd033a90b4e82bdb52eb9485b"/>
</deployment>
The reason is to streamline the deployment process. After a Maven release, the deployment name changes to myapp-1.1.war, and the new development becomes myapp-1.2-SNAPSHOT.war. Instead of undeploying release myapp-1.1.war, and deploying myapp-1.2-SNAPSHOT.war, we want to reduce it to a single step - just redeploy myapp, and it should overwrite the old one.
Btw, if I just deploy, I'll have the two versions.
Just to be clear, this is the goal:
<deployment name="myapp" runtime-name="myapp-1.1-SNAPSHOT.war">
<content sha1="17e09de2cd8f78ffd033a90b4e82bdb52eb9485b"/>
</deployment>
This seems like a very simple case, and it should work as per the documentation: https://docs.jboss.org/wildfly/plugins/maven/latest/deploy-mojo.html
You can't override the name parameter on the via the command line. You'd need to add a configuration property for the name configuration parameter and override that on the command line.
...
<properties>
<deployment.name>${project.build.finalName}.${project.packaging}</deployment.name>
</properties>
...
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.1.0.Alpha7</version>
<configuration>
<name>${deployment.name}</name>
</configuration>
</plugin>
...
Then on the command you could use -Ddeployment.name=myapp. One note though is you'll want to use the appropriate file extension, e.g. .war, so the deployment will be processed properly.

How to exclude sub-nodes in an AEM package using filters

I am creating an AEM content package and the resulting zip has the requisite META-INF directory with the filter.xml.
The package has content which is organized like so:
/jcr_root/apps/appgroup/myapp/components
/jcr_root/apps/appgroup/myapp/i18n/en_us.xml
/jcr_root/apps/appgroup/myapp/i18n/es_mx.xml
/jcr_root/apps/appgroup/myapp/templates
The filter.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/apps/appgroup/myapp">
<exclude pattern="/apps/appgroup/myapp/i18n(/.*)?" />
</filter>
</workspaceFilter>
Despite having the exclude pattern, the i18n node still gets deployed into the CRX when the package is installed. Shouldn't the filter exclude the i18n node?
Ultimately, I would like to deploy just the en_us node and have the filters block any other languages.
My understanding is that the filter taken into consideration during install and not during compilation. Is this correct?
Filters are applied when the package is built rather than installed. With an exclusion, it shouldn't get installed by your package, but it also means if already present, it also won't get removed either! It should behave as if the package doesn't touch the area covered by the exclude filter.
From the documentation*:
To include all scripts of my application but the forms component:
Root path: /apps/myapp
Rules: Exclude: /apps/myapp/components/form(/.*)?
The form component is not included in the package. If such a component
already existed when installing the package, CRX would not remove it,
because it is not defined by the filters.
…
When building the package, all the content defined by each filter is included. When extracting the package, all existing content that matches the filter is removed or replaced.
Edit: Working from a Maven bundle, you could use specify elements as excluded using a resource declaration, to avoid the content being added to the Zip e.g.:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>jcr_root/apps/appgroup/myapp/i18n</exclude>
<exclude>jcr_root/apps/appgroup/myapp/i18n/**/*.*</exclude>
</excludes>
</resource>
</resources>
</build>
It's possible that the filter.xml is getting ignored by Maven on build & once the content is in the package, it's getting installed by CQ regardless.
EDIT2: * Initial example is no longer in the documentation now that Day.com is down, but should still hold true. Updated documentation is now available here

Change a file xml with maven plugin

I´m working with maven 3, migrating the old application using hivemind and ant. I need to change The file "Hivemodule.xml" with some properties with information about enviroment, I define with profile but it doesn´t work.
I try using maven-resources-plugin but without success, perhaps it just do with properties files.
Detail: The Hivemodule.xml is inside the file jar and I want to unpack this file to turn the content of internal hivemodule configurations and after, to pack again... I´m in the unpack fase.
Here is my file in Hivemodule.xml and the parameters that I want to turn:
PROVIDER_URL="ormi://localhost:23791/"
APPLICATION_NAME="services_1_11"
SECURITY_PRINCIPAL="oc4jadmin"
SECURITY_CREDENTIAL="welcome"
For use of profiles, I edited this file:
PROVIDER_URL="${PROVIDER_URL}"
APPLICATION_NAME="${APPLICATION_NAME}"
SECURITY_PRINCIPAL="${SECURITY_PRINCIPAL}"
SECURITY_CREDENTIAL="${SECURITY_CREDENTIAL}"
In my pom.xml, the references to profile:
<profiles>
<profile>
<id>local</id>
<properties>
<PROVIDER_URL>ormi://localhost:23791/</PROVIDER_URL>
<APPLICATION_NAME>services_1_11</APPLICATION_NAME>
<SECURITY_PRINCIPAL>oc4jadmin</SECURITY_PRINCIPAL>
<SECURITY_CREDENTIAL>welcome</SECURITY_CREDENTIAL>
</properties>
</profile>
</profiles>
And my resource configurations:
<resources>
<resource>
<directory>${serviceSegPath}/${serviceName}/META-INF/</directory>
<filtering>true</filtering>
</resource>
</resources>
Is there any suggestion to solution this? Another plugin to make changes in xml file?
Perhaps this profile is not active when running maven.
mvn -P local clean install