Install geoip2 python library for Odoo 15 on Kubernetes - kubernetes

Hi I have installed Odoo 15 on Kubernetes (using Bitnami chart) and I would like to use the geoip database functionality. To do so, I need to install the geoip2 python library in my Odoo containners before the Odoo server starts.
Installing the geoip2 library is as simple as running pip install geoip2 (or pip3). The problem is that this needs to be done before the Odoo server starts and without ssh-ing into the container (we would like deployments to be entirely automated - no manual interaction).
I've tried InitContainers but they're not a solution because they run in their own container and any library installed in the InitContainer will not be installed in the Odoo container (I am guessing that sidecars would be the same).
Using Lifecyle -> poststart in the deployment yaml does not work either and I suspect that this is because the poststart is executed after the Odoo server is started.
I've tried to use the command: element of the deployment yaml file to first run the install of geoip2 and then the entrypoint of the Odoo image but for some reason this does not seem to work. Maybe this could be a solution if someone can get this to work?
Would anyone have a simple solution, ideally that does not require creating our own image for installing Odoo.
Thanks

Like what David Maze suggested, the simplest and easiest way to get this done is creating a new container image or editing your current container image because all solutions like kubectl or kube jobs or CICD will execute commands inside the container only once the container is brought up. One more option is that you can install geoip2 package and then restart the dependent odoo service but you are saying that this is not working. So, you can edit the existing container image and install geoip2, input your config and commit the image to the registry for creating your deployment.

Related

Deploy magento2 on a kubernet cluster

I run magento 2 on my local with docker.
It works like a charm.
But now I would like to pass the next step, and deploying a registry image of my magento2 (gitlab registry with gitlab-ci in my case) in a k3d cluster in my personal server.
I don't have any problems to generate the image in the registry of gitlab and to deploy the service, the node, the pod with kube in my server. To train myself and to be sure that what I did was correct, I have tried to deploy an other image in my cluster from the gitlab registry from a little simple HTML and a Dockerfile and it works like a charm.
But the magento 2 image no. The problem is that we must play the setup / compile / etc. When I try to play composer install in my entrypoint it says in the logs pod that there is no composer.json in the folder where composer is supposed to be. So I guess I must configure ingress.yaml, services and deployment with a specific way. I don't know where to start and how.
My question is just, if someone know a good tuto or some documentations links I would be pleased to see that.
I have heard about helm, the hooks etc...but I don't handle it at all. I even don't know what it is...
Thank you
Thanks

How to run docker image in Kubernetes (v1.21) pod for CI/CD scenario?

We're investigating using an AKS cluster to run our Azure Pipeline Agents.
I've looked into tools like Kaniko for building docker images, which should work fine, however some of our pipelines run docker commands, e.g. we run checkov using the docker image, but I've struggled to find any solution that seems to work, given the deprecation of the docker shim in kubernetes.
The obvious solution would be add those tools that we currently run from docker into our agent image but this isn't a great solution as it will mean that any time a developer wants to run a tool like that we would need to modify the new image, which is less than ideal.
Any suggestions?
Thanks
You could just use nerdctl or crictl for your commands and even create an alias for that (specially wiht nerdctl) = alias docker="nerdctl"
As docker images or better said container images using the OCI image format you will have no issues running them with containerd or cri-o.

Persistence volume change: Restart a service in Kubernetes container

I have an HTTP application (Odoo). This app support install/updating modules(addons) dynamically.
I would like to run this app in a Kubernetes cluster. And I would like to dynamically install/update the modules.
I have 2 solutions for this problem. However, I was wondering if there are other solutions.
Solution 1:
Include the custom modules with the app in the Docker image
Every time I made a change in the custom module and push it to a git repository. Jinkins pull the changes and create a new image and then apply the new changes to the Kubernetes cluster.
Advantages: I can manage the docker image version and restart an image if something happens
Drawbacks: This solution is not bad for production however the list of all custom module repositories should all be included in the docker file. Suppose that I have two custom modules each in its repository a change to one of them will lead to a rebuild of the whole docker image.
Solution 2:
Have a persistent volume that contains only the custom modules.
If a change is made to a custom module it is updated in the persistent volume.
The changes need to apply to each pod running the app (I don't know maybe doing a restart)
Advantages: Small changes don't trigger image build. We don't need to recreate the pods each time.
Drawbacks: Controlling the versions of each update is difficult (I don't know if we have version control for persistent volume in Kubernetes).
Questions:
Is there another solution to solve this problem?
For both methods, there is a command that should be executed in order to take the module changes into consideration odoo --update "module_name". This command should include the module name. For solution 2, How to execute a command in each pod?
For solution 2 is it better to restart the app service(odoo) instead of restarting all the nodes? Meaning, if we can execute a command on each pod we can just restart the service of the app.
Thank you very much.
You will probably be better off with your first solution. Specially if you already have all the toolchain to rebuild and deploy images. It will be easier for you to rollback to previous versions and also to troubleshoot (since you know exactly which version is running in each pod).
There is an alternative solution that is sometime used to provision static assets on web servers: You can add an emptyDir volume and a sidecar container to the pod. The sidecar pull the changes from your plugins repositories into the emptyDir at fixed interval. Finally your app container, sharing the same emptyDir volume will have access to the plugins.
In any case running the command to update the plugin is going to be complicated. You could do it at fixed interval but your app might not like it.

creating a proper kubeconfig file for a 2 node gentoo linux kubernetes cluster

I have two servers at my home with Gentoo Linux ~amd64.I would like to install Kubernetes on them to play with it a bit.
Gentoo now packages all the Kubernetes related dependencies under one package called sys-cluster/kubernetes and the latest version available at the moment is 1.18.3.
the last time I played with Kubernetes was several years ago and I think I completely forgot everything.
so I installed kubernetes on both servers. since I use systemd and the package contains only kubelet systemd service I created systemd init scripts for also kube-apiserver, kube-controller-manager, kube-proxy and kube-scheduler.
now this package also comes with kubeadm but I would like to know how to install and configure kubernetes manually.
now I want to create a kubeconfig file for my cluster configuration.
I googled and found the following url: http://docs.shippable.com/deploy/tutorial/create-kubeconfig-for-self-hosted-kubernetes-cluster/
the first step is Make sure you can access the cluster but I thought I wanted to create kubeconfig in order for the services to properly know how to access my cluster!
this web site already talks about secrets that where already configured which aren't.. i'm starting from scratch and this is not probably the way to go.
In general I want to know how to properly create a kubeconfig file for my setup, then i'll configure the services to use this kubeconfig file and go on from there.
so any information regarding this issue would be greatly appreciated.
so I asked this also in Kubernetes slack channel and they provided me this project: https://github.com/kelseyhightower/kubernetes-the-hard-way
it's a documentation project on how to configure kubernetes the hard way, in the documentation they set it up in google cloud, but it's easy to understand what they did on cloud and how to configure the same on your network.

We are deploying Open Loyalty on to Google Cloud and we are receiving a Yarn error?

We are installing Open Loyalty Program on to the Google Cloud. Please Google Open Loyalty by Divante Ltd.
We have been trying to deploy this application on google cloud using Kubernetes.
The instance used to deploy this application contains Debian v4.9 as its OS. And we installed Docker, GCloud, Kubernetes and Kompose as the tools for deployment. We built two docker images for the frontend and backend and linked them to the docker-compose file. Now in frontend image, we used (node:5) image from docker hub in Dockerfile of the frontend.
We also changed the docker-compose file as seen below:
enter image description here
After changing the docker-compose file, we ran “kompose up” within the same directory.
which created the deployment and service ‘yaml’ file and then proceeded to run it.
We have pods as given below, but the frontend pod shows some error and some logs.enter image description here
It says yarn not found. When we execute the same process on a local machine, it works as expected.
We are also trying to seek help from Google Support but your help and suggestions will also be highly appreciated.
Yarn is available from node:6. Your front-end image is too old.