-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document Airgap Setup for Maven #15503
Comments
Here, I am describing how we could setup Maven to use a private Artifact repository in the case where Che could not access the internet and Maven Central. There are several options:
Setup the environmentSetup NexusHere, I will describe how I install Nexus to test my configuration. The Nexus will be installed through an operator in Openshift 4.2. Install the operatorFrom the the openshift 4.2 console, as an admin,
Upload artifacts of our project.
Start the test workspaceStart a workspace from this devfile: https://gist.githubusercontent.com/sunix/4bcef770db4985b5b768a6c81ab9f82c/raw/devfile.yaml This devfile will set user.home to /project for the quarkus-backend-dev container. Disconnect from central.My cluster is connected to the internet, to fake disconnection from the internet, I am disabling central repo in the project pom.xml. Edit the pom.xml and add: [...]
</profile>
</profiles>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://nowhere</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://nowhere</url>
</repository>
</repositories>
</project> That will disable central Clean the folder /project/.m2/repository from the quarkus-backend-dev container:
Now if you run the command Same opening Configure Maven to use a remote repositoryDefine repositories in pom.xmlThe first way to setup our internal nexus repo to be used by our project is to set the repo in the pom.xml file (could also be a parent pom.xml). Copy the </profiles>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://nowhere</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>my-nexus-snapshots</id>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>http://nexus3-airgap.apps.acme.com/repository/maven-snapshots/</url>
</pluginRepository>
<pluginRepository>
<id>my-nexus-releases</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://nexus3-airgap.apps.acme.com/repository/maven-releases/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://nowhere</url>
</repository>
<repository>
<id>my-nexus-snapshots</id>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>http://nexus3-airgap.apps.acme.com/repository/maven-snapshots/</url>
</repository>
<repository>
<id>my-nexus-releases</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://nexus3-airgap.apps.acme.com/repository/maven-releases/</url>
</repository>
</repositories>
</project> Checking Language ServerAdding these lines to the Checking Maven command lineClean the folder
Now if you run the command Define repositories in settings.xmlThe second way to setup our internal nexus repo to be used by our project is to set the repo in the Revert the changes done in the previous section (keep the override of maven central). Clean the folder
Make sure errors appears again when running the package command or openning the Create a cat <<EOF > /project/.m2/settings.xml
<settings>
<profiles>
<profile>
<id>my-nexus</id>
<pluginRepositories>
<pluginRepository>
<id>my-nexus-snapshots</id>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>http://nexus3-airgap.apps.acme.com/repository/maven-snapshots/</url>
</pluginRepository>
<pluginRepository>
<id>my-nexus-releases</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://nexus3-airgap.apps.acme.com/repository/maven-releases/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>my-nexus-snapshots</id>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>http://nexus3-airgap.apps.acme.com/repository/maven-snapshots/</url>
</repository>
<repository>
<id>my-nexus-releases</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://nexus3-airgap.apps.acme.com/repository/maven-releases/</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>my-nexus</activeProfile>
</activeProfiles>
</settings>
EOF Checking Language ServerClean the folder
Open Checking Maven command lineClean the folder
Now if you run the command Setup TLS with self signed certificate for NexusConfigure Nexus with TLS and self-signed certificateWe are going to add a new route with tls and a self signed certificate that we create: Create the certificate (adapt the CN with your hostname)
or if openssl version < 1.1.1
Notes:
Create a new route in the project where the nexus operator cluster is deployed: $ oc project airgap
$ oc create route edge snexus --service=nexus3 --cert=tls.crt --key=tls.key
$ oc describe Route snexus
Name: snexus
Namespace: airgap
Created: 14 seconds ago
Labels: app=nexus3
Annotations: openshift.io/host.generated=true
Requested Host: snexus-airgap.apps.acme.com
exposed on router default (host apps.acme.com) 14 seconds ago
Path: <none>
TLS Termination: edge
Insecure Policy: <none>
Endpoint Port: http
Service: nexus3
Weight: 100 (100%)
Endpoints: 10.128.2.18:8081
Change in Executing a build after having cleaned up the repo should fail: Configure Maven to use the Secured Nexus (with self-signed certificate)Steps to configure maven to trust our certificate:
Create truststore
Once created upload it in Checking command lineTo have it working from our env:
- value: '-Duser.home=/project -Djavax.net.ssl.trustStore=/projects/truststore.jks'
name: MAVEN_OPTS And restarting the workspace, it works: Checking Language ServerThe embedded maven does not seem to rely on MAVEN_OPTS. I have tried to add the option in the preferences. [...]
- alias: java
type: chePlugin
id: redhat/java/latest
memoryLimit: 1536M
preferences:
java.jdt.ls.vmargs: >-
-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication
-Djavax.net.ssl.trustStore=/projects/truststore.jks
[...] Related issue: redhat-developer/vscode-java#455 Concerns and issuesTo summarize:
Injecting settings.xmlUnfortunately, there is no way to inject a settings.xml file from the devfile. eclipse-che/che-theia#429 is not usable: it only deals with one external mirror where most of the customers may have more than just mirrors to configure their airgap in settings.xml:
Che should allow injecting such files or environment variable through the devfile with secrets maybe. This kind of config files may need to be shared across an organisation (team, BU). Some other files would be more personal Related issue that may need to be reprioritized: Self signed certificateAt some point we would need to inject the truststore. Maybe #15218 and/or kubernetes secrets #14680 are good starting points. #14680 would be nice. It could also be secrets that would be shared by several users of the same organisation. I would NOT recommend adding the file contents in the devfile (though it would be useful for testing purposes). These files would generally contain token, password, sensitive information that should not be shared in a git repo. So a devfile is not appropriate. However in the devfile defining which secret should be used to inject some files or environment variable would be nice. Also being able to set the secrets from a UI like the user dashboard would be nice. VSCode extension preferences: in devfile our in the user preferences ?I am not sure vscode extension preferences is something the user would like to configure in the devfile. Instead, user may want to configure that once in the user preferences. Working devfile sampleThis devfile: https://gist.github.com/sunix/00f890965f04620139e616fbcba75444, is setting up a workspace with a maven project that would work with a private nexus repository.
|
Thanks, I have updated the previous doc |
@rkratky : We need to put this into the documentation. Would you be able to take that into account for 7.9 ? |
@rhopp and @dmytro-ndp : This is important capabilities. we should have automated tests for this. Is that something you can work on? |
Test and document the process of setting up an airgap solution for Maven. In particular, configure a workspace based on our default maven devfile to use a Maven repository that uses a self-signed certificate.
The following issues are related and we need to document how to solve them manuall in this issue:
The text was updated successfully, but these errors were encountered: