mario
July 24, 2024, 3:53pm
1
I have a repository that has the Chart templates for the application, and the services it depends on are in different repositories.
I have seen this sample GitHub - okteto/microservices-multi
But my services repositories don’t have any chart to independently deploy them, and I need to use the build images from those repositories into the Chart repository
mario
July 24, 2024, 3:55pm
2
For this use case, you can still use the manifest dependencies from the App Chart repository to the services ones.
But you need to propagate the ENV variables from those services to it.
Here is an example on how to do it: GitHub - okteto-community/go-getting-started-chart
mario
July 30, 2024, 8:27am
3
Another two option to handle this:
We have a central repo for our helm chart and separate repo’s for the development of the actual services.
Our repo’s on github:
chart repository containing the depoyment files for each service
service A
service B
and so on…
We have implemented the following solution which utilizes the okteto registry.
Chart repository
Whenever there is a change in the charts, we push it to the okteto registry with a github workflow that uses an okteto manifest.
Github Workflow
name: okteto-registry
on:
workflow_dispatch:
push:
branches:
- main
jobs:
upload-chart:
runs-on: ubuntu-latest
env:
OKTETO_CA_CERT: ${{ secrets.OKTETO_CA_CERT }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Context
uses: okteto/okteto-context-action@latest
with:
url: ${{ secrets.OKTETO_CONTEXT }}
token: ${{ secrets.OKTETO_TOKEN }}
- name: Trigger the pipeline
uses: okteto/okteto-pipeline-action@latest
with:
name: upload-product-charts:latest
filename: okteto.yaml
Okteto Manifest
deploy:
commands:
- name: Install dependencies
command: helm dependency update charts/chartname
- name: Login registry
command: |
helm registry login ${OKTETO_REGISTRY_URL} -u ${OKTETO_USERNAME} -p ${OKTETO_TOKEN}
- name: Package chart
command: |
helm package ./charts/chartname --version 0.0.1
- name: Push chart to registry
command: |
helm push ./chartname-0.0.1.tgz oci://${OKTETO_REGISTRY_URL}/okteto
Service A & B and so on
In each service we pull the chart from registry and we deploy the chart. We reuse the values so we can develop against several services at once (else container image will return to default on upgrade if not specifically set).
Okteto Manifest
build:
gui:
context: .
dockerfile: Dockerfile
target: dev
deploy:
commands:
- helm registry login ${OKTETO_REGISTRY_URL} -u ${OKTETO_USERNAME} -p ${OKTETO_TOKEN}
- helm pull oci://${OKTETO_REGISTRY_URL}/okteto/chartname --version 0.0.1
- |
RELEASE_NAME=${OKTETO_NAMESPACE}
CHART_PATH=./chartname-0.0.1.tgz
helm upgrade --install --reuse-values $RELEASE_NAME $CHART_PATH \
--set serviceA.repository=${OKTETO_BUILD_GUI_REGISTRY}/${OKTETO_BUILD_GUI_REPOSITORY} \
--set serviceA.tag=${OKTETO_BUILD_GUI_SHA} \
dev:
gui:
sync:
- .:/usr/src/app
forward:
- 8080:8080
selector:
component: serviceA
Hope this helps and if someone has better ideas, happy to learn
1 Like
mario
August 28, 2024, 2:46pm
5
Perfect @Michiel !
Thank you so much for the contribution. Truly appreciate it!
1 Like