Build and Deploy Multiple Docker images to kubernetes - docker

I have an application such as below structure which multiple services has their own Dockerfile.ı would like to deploy my application via Jenkins using Helm to kubernetes but I can not decide what is the best way to handle this?
Should I try to use multi-stage builds if yes how can I handle this?
Should I create two helm charts for each of them or any way to handle this with one helm chart?
└── app-images-dashboard
├── Readme.md
├── cors-proxy
│ ├── Dockerfile
│ ├── lib
│ │ ├── cors-anywhere.js
│ │ ├── help.txt
│ │ ├── rate-limit.js
│ │ └── regexp-top-level-domain.js
│ ├── package.json
│ └── server.js
└── app-images-dashboard
├── Dockerfile
├── components
│ └── image_item.js
├── images
│ └── beta.png
├── index.html
├── main.js
└── stylesheets
└── style.css

A helm chart represent a whole application. You have 1 application with 2 slices. So you need only 1 helm chart.

Related

How to generate html Docs for openapi components schema files

Here is the file structure. And I would like to generate html documentation for components/schemas/.. not for openapi.yaml which has endpoints.
├── code samples
│ └── C#
│ └── postundefined
│ └── PHP
│ └── postundefined
├── components
│ └── headers
│ └── ExpiresAfter.yaml
│ └── responses
│ └── Problem.yaml
│ └── schemas
│ └── Email.yaml
│ └── Problem.yaml
│ └── Schema.yaml
│ └── User.yaml
├── paths
│ └── echo.yaml
│ └── pathItem.yaml
│ └── pathItemWithExamples.yaml
│ └── users#{username}.yaml
└── openapi.yaml
Here is a git hub page openapi-starter. It has a folder structure components/schemas/..
Using redocly redocly build-docs openapi.yaml it generates it only generate redoc-static.html and it has all the documentation for rest endpoints but not for schemas.
In my case, I would like to generate documentation/html pages only for the schemas and in this particular case Email.yaml, User.yaml, Schema.yaml, User.yaml
Is there any tool that can accomplish this ?

Copy all files of sub and nested sub directories

This is my project file structure:
java-project/
├── docker.compose.yml
├── pom.xml
└── services/
├── a/
│ ├── Dockerfile
│ ├── pom.xml
│ ├── src/
│ │ ├── pom.xml
│ │ ├── xxx
│ │ └── xxx
│ └── target/
│ ├── pom.xml
│ └── xxxx
└── b/
├── Dockerfile
├── pom.xml
├── src/
│ ├── pom.xml
│ ├── xxx
│ └── xxx
└── target/
├── pom.xml
└── xxxx
I want to copy all of the contents of the services folder of the project (including all the subfolders inside the services). Basically, I want to replicate the current project structure with every file and folder in the docker image as well for the mvn build to execute successfully.
I am doing the following in the Dockerfile, but I don't see all of the contents:
COPY services/**/pom.xml ./services/
What am I doing wrong here? TIA
Let's look at your COPY instruction:
# <src> <dest>
COPY services/**/pom.xml ./services/
Under the hood, Docker reads the <src> using Go's filepath.Match method. This means that the instruction doesn't use the globstar (**) the way glob patterns do. However, your question suggests you want to copy everything inside services — not only pom.xml files.
You can copy everything inside your local services directory using:
COPY services ./services/
If you want to exclude certain subdirectories or files, you can specify this using a .dockerignore.

How to create multiple containers in same pods which have separate deployment.yaml files?

tldr: in docker-compose, intercontainer communication is possible via localhost. I want to do the same in k8s, however, I have separate deployment.yaml files for each component. How to link them ?
I have a kubernetes helm package in which there are sub helm packages. The folder structure is as follows ::
A
├── Chart.yaml
├── values.yaml
├── charts
│ ├── component1
│ │ ├── Chart.yaml
│ │ ├── templates
│ │ │ ├── configmap.yaml
│ │ │ ├── deployment.yaml
│ │ │ ├── hpa.yaml
│ │ │ ├── ingress.yaml
│ │ │ ├── service.yaml
│ │ │ ├── serviceaccount.yaml
│ │ └── values.yaml
│ ├── component2
│ │ ├── Chart.yaml
│ │ ├── templates
│ │ │ ├── certs.yaml
│ │ │ ├── configmap.yaml
│ │ │ ├── pdb.yaml
│ │ │ ├── role.yaml
│ │ │ ├── statefulset.yaml
│ │ │ ├── pvc.yaml
│ │ │ └── svc.yaml
│ │ ├── values-production.yaml
│ │ └── values.yaml
In docker-compose, I was able to communicate between component1 and component2 via ports using localhost.
However, in this architecture, I have separate deployment.yaml files for those components. I know that if I keep them as containers in a single deployment.yaml file, I can communicate via localhost.
Question: How do I put these containers in same pod, provided that they are present in separate deployment.yaml files ?
That's not possible. Pods are the smallest deployable unit in kubernetes that consist of one or more containers. All containers inside the pod share the same network namespace (beside others). The containers can only be reached via fqdn or ip. For each container outside a pod "localhost" means something completely different. Similar to running docker compose on different hosts, they can not connect using localhost.
You can use the service's name to have a similar behaviour. Instead of calling http://localhost:8080 you can simple use http://component1:8080 to reach component1 from component2, supposing the service in component1/templates/service.yaml is named component1 and both are in the same namespace. Generally there is a dns record for every service with the schema <service>.<namespace>, e.g. component1.default for component1 running in the default namespace. If component2 where in a different namespace you would use http://component1.default:8080.

Docker mosquitto - Error unable to load auth plugin

I really need your help !
I'm encountering a problem with the loading of a plugin in a docker mosquitto.
I tried to load it on a local version of mosquitto and it worked well.
The error return in the docker console is:
dev_instance_mosquitto_1 exited with code 13
The errors return in the log file of mosquitto are:
1626352342: Loading plugin: /mosquitto/config/mosquitto_message_timestamp.so
1626352342: Error: Unable to load auth plugin "/mosquitto/config/mosquitto_message_timestamp.so".
1626352342: Load error: Error relocating /mosquitto/config/mosquitto_message_timestamp.so: __sprintf_chk: symbol not found
Here is a tree output of the project:
mosquitto/
├── Dockerfile
├── config
│ ├── acl
│ ├── ca_certificates
│ │ ├── README
│ │ ├── broker_CA.crt
│ │ ├── mqtt.test.perax.com.p12
│ │ ├── private_key.key
│ │ └── server_ca.crt
│ ├── certs
│ │ ├── CA_broker_mqtt.crt
│ │ ├── README
│ │ ├── serveur_broker.crt
│ │ └── serveur_broker.key
│ ├── conf.d
│ │ └── default.conf
│ ├── mosquitto.conf
│ ├── mosquitto_message_timestamp.so
│ └── pwfile
├── data
│ └── mosquitto.db
└── log
└── mosquitto.log
Here is the Dockerfile:
FROM eclipse-mosquitto
COPY config/ /mosquitto/config
COPY config/mosquitto_message_timestamp.so /usr/lib/mosquitto_message_timestamp.so
RUN install /usr/lib/mosquitto_message_timestamp.so /mosquitto/config/
here is the docker-compose.yml:
mosquitto:
restart: always
build: ./mosquitto/
image: "eclipse-mosquitto/latests"
ports:
- "1883:1883"
- "9001:9001"
volumes:
- ./mosquitto/config/:/mosquitto/config/
- ./mosquitto/data/:/mosquitto/data/
- ./mosquitto/log/mosquitto.log:/mosquitto/log/mosquitto.log
user: 1883:1883
environment:
- PUID=1883
- PGID=1883
Here is the mosquitto.conf:
persistence true
persistence_location /mosquitto/data
log_dest file /mosquitto/log/mosquitto.log
include_dir /mosquitto/config/conf.d
plugin /mosquitto/config/mosquitto_message_timestamp.so
I'm using mosquitto 2.0.10 on a ubuntu serveur with the version 18.04.5 LTS.
In thanking you for your help.
Your best bet here is probably to set up a multi step Docker build file that uses an Alpine based image to build the plugin then copy it into the eclipse-mosquitto image.

How to setup Travis in multilanguage (Nodejs client- Python server) environment?

I have a repo with a client and a server respectively based on NodeJs/Angular2 and Python/Django with approximately this folder structure:
main/
├── angular2-client/
│ ├── build/
│ ├── dist/
│ ├── node_modules/
│ ├── src/
│ └── ...
└── django-server/
├── myapp/
├── server/
├── manage.py
└── ...
So, client and server are both on the same repo and same branch. What's the correct way of setting up Travis to build/deploy client and server to 2 different providers (eg. Firebase and AWS)?
Any suggestion, documentation reference or tutorial is highly appreciated.
Thanks

Resources