From 4e51f0ab807897ff9ee9c8d9a7c3c1613dfed5e5 Mon Sep 17 00:00:00 2001 From: Cedric Verstraeten Date: Thu, 12 Dec 2024 16:50:11 +0100 Subject: [PATCH 1/3] add kubernetes job + update readme --- README.md | 13 +++++++++++-- kubernetes-job.yaml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 kubernetes-job.yaml diff --git a/README.md b/README.md index 75aebfc..ca7a89c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ This repository contains CLI tools for performing specific automations. ## Run -To be written +You can run the migration as a Kubernetes job in your cluster. The benefit is that you do not need to expose anything, and use the internal Kubernetes dns. + +kubectl apply -f kubernetes-job.yaml ## Installation and contributing @@ -48,12 +50,14 @@ This tool migrates data from a Vault database to a Hub database. - `-mongodb-username`: The MongoDB username (optional). - `-mongodb-password`: The MongoDB password (optional). - `-username`: The username to filter data (required). +- `-queue`: The integration used to transfer events to the hub pipeline. - `-start-timestamp`: The start timestamp for filtering data (required). - `-end-timestamp`: The end timestamp for filtering data (required). - `-timezone`: The timezone for converting timestamps (optional, default is `UTC`). - `-pipeline`: The pipeline to execute (optional, default is `monitor,sequence`). - `-batch-size`: The size of each batch (optional, default is `10`). - `-batch-delay`: The delay between batches in milliseconds (optional, default is `1000`). +- `-mode`: You can choose to run a `dry-run` or `live`. #### Example @@ -64,10 +68,15 @@ go run main.go -action vault-to-hub-migration \ -mongodb-uri "mongodb+srv://:@/?retryWrites=true&w=majority&appName=" \ -mongodb-source-database= \ -mongodb-destination-database= \ + -queue \ -username \ -start-timestamp \ -end-timestamp \ - -timezone + -timezone \ + -pipeline 'monitor,sequence,analysis' \ + -mode 'dry-run' \ + -batch-size 100 \ + -batch-delay 1000 ``` #### Output diff --git a/kubernetes-job.yaml b/kubernetes-job.yaml new file mode 100644 index 0000000..efa2d98 --- /dev/null +++ b/kubernetes-job.yaml @@ -0,0 +1,34 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: uugai-cli-vault-to-hub-migration +spec: + template: + spec: + containers: + - name: init-container + image: uugai/cli:latest + command: ['/main', '-action', 'vault-to-hub-migration', + '-mongodb-uri', 'mongodb+srv://:@/?retryWrites=true&w=majority&appName=', + #'-mongodb-host', '', + #'-mongodb-port', '27017', + #'-mongodb-username', '', + #'-mongodb-password', '', + '-mongodb-source-database', 'KerberosStorage', + '-mongodb-destination-database', 'Kerberos', + '-mongodb-destination-database', 'admin', + '-username', '', + '-queue', ' Date: Thu, 12 Dec 2024 16:52:30 +0100 Subject: [PATCH 2/3] Fix typo in queue parameter in YAML --- kubernetes-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes-job.yaml b/kubernetes-job.yaml index efa2d98..53b2f95 100644 --- a/kubernetes-job.yaml +++ b/kubernetes-job.yaml @@ -18,7 +18,7 @@ spec: '-mongodb-destination-database', 'Kerberos', '-mongodb-destination-database', 'admin', '-username', '', - '-queue', '', '-start-timestamp', '1733425260', '-end-timestamp', '1753952373', '-timezone', 'UTC', From 608d2ecd43642da21b657b63d5854cb43789a80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Verstraeten?= Date: Thu, 12 Dec 2024 16:53:33 +0100 Subject: [PATCH 3/3] Fix MongoDB database credentials parameter --- kubernetes-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes-job.yaml b/kubernetes-job.yaml index 53b2f95..594e0dc 100644 --- a/kubernetes-job.yaml +++ b/kubernetes-job.yaml @@ -16,7 +16,7 @@ spec: #'-mongodb-password', '', '-mongodb-source-database', 'KerberosStorage', '-mongodb-destination-database', 'Kerberos', - '-mongodb-destination-database', 'admin', + '-mongodb-database-credentials', 'admin', '-username', '', '-queue', '', '-start-timestamp', '1733425260',