Camel K With local Maven Repository - apache-camel

I am looking to setup the settings for using my settings.xml. from the documentation I have done the following steps:
kubectl create configmap maven-settings --from-file=settings.xml
I have verified that this is in the dashboard.
My issue then becomes when I use Modeline or -d mvn:package:name:ver it can't find the JAR and from the logging of the camel-k-operator I am not seeing anything obvious as to which repository it is using.
is there an additional setting I need to be using to get it to use the maven-settings attribute when doing the following command:
kamel run -d mvn:org.project:fakeProject:1.0.0 TestFile.java --dev
the above just gets into an infinite loop of retrying to build/deploy.

You also need to configure Camel-K to use the configmap created (I don't see it in your steps).
After creating the config map, you either need to specify the name of the configmap when using kamel install:
kamel install --maven-settings=configmap:<configmap name>/<key in the configmap with settings>
for example:
kamel install --maven-settings=configmap:maven-settings/settings.xml
Or if you have Camel-K already installed, you need to reference the configmap in the IntegrationPlatform object (path: .spec.build.maven.settings.configMapKeyRef). This integration platform object is created when there is no other integration platform in the namespace when you run the first integration, so if it doesn't exist in your namespace, you can create it and camel-k operator will pick it up, for example:
apiVersion: camel.apache.org/v1
kind: IntegrationPlatform
metadata:
labels:
app: camel-k
name: camel-k
spec:
build:
maven:
settings:
configMapKeyRef:
key: settings.xml (key in your config map)
name: maven-settings (name of your config map)

A simple way to configure a maven repository is to do it when installing the Camel K operator, ie:
kamel install --maven-repository http://my-repo
Please, have a look at the kamel install --help options to see how to better configure it. The full list of possibilities is available in the official doc at https://camel.apache.org/camel-k/next/configuration/maven.html

Related

How do i build deploy and server a React application locally using Ansible?

I would like to install, configure, deploy and serve a local react application using Ansible but i cannot get any valuable information to do it.
Is there anybody who can guide me on how to achieve this?
Thanks in advance.
First off, ansible has a REALLY extensive wiki here. That will show you the many modules that can be used to do specific tasks. However, this is not where I would start for writing your first playbook, it gets rather daunting.
However, I started and would recommend you start on this tutorial on how to make your first playbook. you would make a yaml file and run it using the 'ansible-playbook' command on a host that has ssh enabled, ansible installed, and a key pair setup (easily done with ssh-copy-id user#hostname). If you need a way to quickly provision these machines, I personally use Hashicorp's Vagrant to quickly make simple Virtual Machines, however it is possible to use Docker or something else.
As for the specifics for installing specific applications using apt; use the apt module in ansible should serve you right. If you need to install NPM or something of the sort, chances are there's a module for that too. As for copying configs you would want the copy module. Things are pretty straight forward. a good way to structure the google searches to find specific modules would be something like "ansible copy files" and find something from docs.ansible
I realize that this is rather vague; however, I'm not completely sure on your use case in this scenario simply because of the broadness of the question.
Thanks a lot for your input, it was very helpful.
I finally achieved what i was looking for, and for reference here's how i made it. Hope this is useful for other users.
Assuming you have already installed Ansible in your machine, the following should do the job.
vim inventory
[appserver]
127.0.0.1 ansible_connection=local
vim playbook.yml
---
- hosts: appserver
tasks:
- name: Installing nodejs
apt: name=nodejs update_cache=yes
- name: Installing npm
apt: name=npm update_cache=yes
- name: Installing dependencies
command: npm install
- name: Building
command: npm run build
- name: Installing web server
command: npm install serve
- name: Running app on http://localhost:8080
command: chdir=./build serve -p 8080
To run it, just place the following in your CLI
sudo ansible-playbook -i inventory playbook.yml

How to allow App Engine to authenticate and download private Go modules

My project uses Go modules hosted in private GitHub repositories.
Those are listed in my go.mod file, among the public ones.
On my local computer, I have no issue authenticating to the private repositories, by using the proper SSH key or API token in the project’s local git configuration file. The project compiles fine here.
Neither the git configuration nor the .netrc file are taken into account during the deployment (gcloud app deploy) and the build phase in the cloud, so my project compilation fails there with an authentication error for the private modules.
What is the best way to fix that? I would like to avoid a workaround which would consist in including the private modules’ source code in the deployed files, and have rather find a way to make the remote go or git use credentials I can provide.
You could try to deploy it directly from a build. According to the Accessing private GitHub repositories, you can set up git with key and domain on one of the build steps.
After that you can specify a step to run the gcloud app deploy command, as suggested in the Quickstart for automating App Engine deployments with Cloud Build.
An example of the cloudbuild.yaml necessary to do this would be:
# Decrypt the file containing the key
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- kms
- decrypt
- --ciphertext-file=id_rsa.enc
- --plaintext-file=/root/.ssh/id_rsa
- --location=global
- --keyring=my-keyring
- --key=github-key
volumes:
- name: 'ssh'
path: /root/.ssh
# Set up git with key and domain.
- name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- '-c'
- |
chmod 600 /root/.ssh/id_rsa
cat <<EOF >/root/.ssh/config
Hostname github.com
IdentityFile /root/.ssh/id_rsa
EOF
mv known_hosts /root/.ssh/known_hosts
volumes:
- name: 'ssh'
path: /root/.ssh
# Deploy app
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
timeout: "16000s"

How to have dynamic version name at run time when deploying google app engine in Travis CI?

I am studying to automate the build and deployment of my google app engine application in Travis, so far it allows me to have static or predefined version name during deployment in .travis.yml.
Is there any way to make it dynamically generated at runtime? Like for example below in my .travis.yml file, I have deployment for production and staging version of the application, both are named or labeled as production and qa-staging, and I would like to suffix the version names with a timestamp or anything as long as it would be unique every successful build and deployment.
language: node_js
node_js:
- "10"
before_install:
- openssl aes-256-cbc -K $encrypted_c423808ed406_key -iv $encrypted_c423808ed406_iv
-in gae-creds.json.enc -out gae-creds.json -d
- chmod +x test.sh
- cat gae-creds.json
install:
- npm install
script:
- "./test.sh"
deploy:
- provider: gae
skip_cleanup: true
keyfile: gae-creds.json
project: traviscicd
no_promote: true
version: qa-staging
on:
branch: staging
- provider: gae
skip_cleanup: true
keyfile: gae-creds.json
project: traviscicd
version: production
on:
branch: master
Have you tried with https://yaml.org/type/timestamp.html ?
Im not sure if the context is the correct but seems a good and elegant option for your yaml file.
Perhaps you can use go generate to generate a version string that can be included? You need to run go generate as part of the build process for it to work, though.

does appengine cloudbuild.yaml requires a custom runtime?

Build errors out with below output (Using a Rails app)
ERROR: (gcloud.app.deploy) There is a cloudbuild.yaml in the current directory, and the runtime field in /workspace/app.yaml is currently set to [runtime: ruby]. To use your cloudbuild.yaml to build a custom runtime, set the runtime field to [runtime: custom]. To continue using the [ruby] runtime, please remove the cloudbuild.yaml from this directory.
One way to deal with this is to change the name of the cloudbuild.yaml file to say cloud_build.yaml (you can also just move the file) and then go to your triggers in Cloud Build:
And change it from Autodetected to choosing your Cloud Build configuration file manually:
See this Github issue for some more information
Cloudbuild.yaml should work with App Engine Flexible without the need to use a custom runtime. As detailed in the error message, you cannot have the app.yaml and the cloudbuild.yaml in the same directory if you are deploying in a non-custom runtime, to remedy the situation, follow these steps:
Move the app.yaml and other ruby files into a subdirectory (use your original app.yaml, no need to use custom runtime)
Under your cloudbuild.yaml steps, modify the argument for app deploy by adding a third one specifying the app.yaml path.
Below is an example:
==================FROM:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy']
timeout: '1600s'
===================TO:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy', '[SUBDIRECTORY/app.yaml]']
timeout: '1600s'

Passwordless continuous deployment from CircleCI to AppEngine

The CircleCI appengine documentation suggests using a password to do deployment. How can I use the oauth2 flow instead of using passwords? I don't want to share my Google password.
Do I generate a ~/.appcfg_oauth2_tokens_java file, from token data stored as environment variables in CircleCI? Is there a simpler way?
I solved the issue this way:
deployment:
appengine:
branch: master
commands:
- erb .appcfg_oauth2_tokens_java.json > ~/.appcfg_oauth2_tokens_java # requires ENV in circle ci
- mvn -DskipTests=true appengine:update # tests have already been run
.appcfg_oauth2_tokens_java.json:
{
"credentials": {
"ubuntu": {
"access_token": "<%= ENV["GOOGLE_ACCESS_TOKEN"] %>",
"expiration_time_millis": 1431552739090,
"refresh_token": "<%= ENV["GOOGLE_REFRESH_TOKEN"] %>"
}
}
}
Then in CircleCI, configure the ENV variables for the two tokens. I got the tokens by locally running mvn appengine:update and going through the oAuth2 dance. Note: You may have to remove your existing ~/.appcfg_oauth2_tokens_java file first.
Reading the AppEngine SDK docs, it sounds like that would be a good approach. There is not a built-in way to do that on CircleCI.
If you don't want to use any user-related credential, you can leverage service accounts, like mentioned in this blog post:
Continuous Deployment with Google App Engine and CircleCI
I solved it this way on the latest GAE SDK 1.9.34 for Java.
Assuming you have a Base64 encoded ENV Variable with your JSON key for a service account you've created on the GCloud project:
dependencies:
pre:
- echo $GOOGLE_CLIENT_SECRET | base64 --decode > ${HOME}/client-secret.json
And then in the deployment section:
- $HOME/appengine-java-sdk-$APP_ENGINE_VERSION/bin/appcfg.sh -A $GCLOUD_PROJECT -M $GCLOUD_MODULE -V $BUILD_VERSION --service_account_json_key_file=$HOME/client-secret.json update $WAR_FOLDER
The --service_account_json_key_file doesn't seem to appear as an option when you use appcfg.sh help but it is there, and does work.

Resources