From f5733bd045193970c24cad54456911e72e287f19 Mon Sep 17 00:00:00 2001 From: Alessandro Gervaso Date: Wed, 18 Aug 2021 14:53:46 +0200 Subject: [PATCH 1/3] Add kubernetes cronjob manifest Update setup instructions in README --- README.md | 19 +++++++++++++++++++ netbox-vsphere-sync-cronjob.yaml | 25 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 netbox-vsphere-sync-cronjob.yaml diff --git a/README.md b/README.md index 8db33d6..bb404c5 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,25 @@ docker build -t netbox-sync . docker run --rm -it -v $(pwd)/settings.ini:/opt/settings.ini netbox-sync [some args...] ``` +## Kubernetes + +Run the containerized application in a kubernetes cluster + + * Build the container image following the docker instructions above + * Tag and push the image to a container registry you have access to + * Create a secret from the settings.ini + * Update the image field in the manifest + * Deploy the manifest to your k8s cluster and check the job is running + + ``` + docker build -t netbox-vsphere-sync . + docker image tag netbox-vsphere-sync your-registry.host/netbox-vsphere-sync:v1.2.0 + docker image push your-registry.host/netbox-vsphere-sync:v1.2.0 + + kubectl create secret generic netbox-vsphere-sync --from-file=settings.ini + kubectl apply -f netbox-vsphere-sync-cronjob.yaml + ``` + ## Accounts and tokens In order to read data from a vCenter and updated data in NetBox you need credentials in both instances. diff --git a/netbox-vsphere-sync-cronjob.yaml b/netbox-vsphere-sync-cronjob.yaml new file mode 100644 index 0000000..7db758e --- /dev/null +++ b/netbox-vsphere-sync-cronjob.yaml @@ -0,0 +1,25 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: netbox-vsphere-sync + labels: + app: netbox-vsphere-sync +spec: + schedule: "10 7-23 * * *" + jobTemplate: + spec: + template: + spec: + containers: + - name: netbox-vsphere-sync + image: harbor.beantech.cloud/library/netbox-vsphere-sync:latest + imagePullPolicy: IfNotPresent + volumeMounts: + - name: netbox-vsphere-sync + mountPath: /opt/settings.ini + subPath: settings.ini + volumes: + - name: netbox-vsphere-sync + secret: + secretName: netbox-vsphere-sync + restartPolicy: Never \ No newline at end of file From c390b3127cbe6c6e2b4b8dad9a9dbcfcf4cb829a Mon Sep 17 00:00:00 2001 From: Alessandro Gervaso Date: Wed, 18 Aug 2021 14:57:06 +0200 Subject: [PATCH 2/3] add missing newline --- netbox-vsphere-sync-cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox-vsphere-sync-cronjob.yaml b/netbox-vsphere-sync-cronjob.yaml index 7db758e..c772171 100644 --- a/netbox-vsphere-sync-cronjob.yaml +++ b/netbox-vsphere-sync-cronjob.yaml @@ -22,4 +22,4 @@ spec: - name: netbox-vsphere-sync secret: secretName: netbox-vsphere-sync - restartPolicy: Never \ No newline at end of file + restartPolicy: Never From 495979850db33947926c380f2fc9613ace164942 Mon Sep 17 00:00:00 2001 From: Alessandro Gervaso Date: Wed, 18 Aug 2021 15:04:05 +0200 Subject: [PATCH 3/3] Add sample registry and image version in manifest --- netbox-vsphere-sync-cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox-vsphere-sync-cronjob.yaml b/netbox-vsphere-sync-cronjob.yaml index c772171..2f16dac 100644 --- a/netbox-vsphere-sync-cronjob.yaml +++ b/netbox-vsphere-sync-cronjob.yaml @@ -12,7 +12,7 @@ spec: spec: containers: - name: netbox-vsphere-sync - image: harbor.beantech.cloud/library/netbox-vsphere-sync:latest + image: your.container.registry/netbox-vsphere-sync:v1.2.0 imagePullPolicy: IfNotPresent volumeMounts: - name: netbox-vsphere-sync