opendevstack / ods-jenkins-shared-library

Shared Jenkins library which all ODS projects & components use - provisioning, SonarQube code scanning, Nexus publishing, OpenShift template based deployments and repository orchestration
Apache License 2.0
70 stars 57 forks source link

[orchestration pipeline] Stop exporting OpenShift resources #554

Open michaelsauter opened 3 years ago

michaelsauter commented 3 years ago

I have circled these thoughts with a few people already, but I realised I never wrote them down in a GitHub issue. So here it goes.

At the moment, the orchestration pipeline checks for each component whether an openshift folder exists. If it does, the pipeline assumes that this folder contains templates defining the OpenShift resources. If the folder does not exist, an export of all resources labelled with app=${projectId}-${componentId} is performed, and the resulting template is stored in openshift-exported. This feature was introduced to allow users to deploy their component without needing to think about / declare the resources in code. Instead, users can use the console UI to click their app together in the DEV environment, and then get this state replicated in QA/PROD. This approach poses a problem though: typically some parameters (e.g. DB access credentials) should be different between the environments, and to overcome this problem, there is a "reverse param" magic, which replaces hardcoded values in the exported template with parameter names, so that other values can be set for those parameters in QA/PROD.

Let's make this very clear - I think this whole idea of an "ad-hoc automated export" is a terrible mistake, for several reasons:

To sum it up, I strongly believe this feature should be removed. Using the auto-export is not something I would recommend to anyone, especially not in a GxP context. Removing the feature would simplify the documentation, it would simplify the code, it would allow us to easier integrate Helm and would allow us to undo other mistakes (like the merge-back) in future steps.

If we agree on removing it, we should however define how we want to provision new quickstarters. I believe the best would be to ship them with some templates so that there is no initial, manual effort. We'd need to pick if we want to ship with OpenShift templates or Helm templates (or allow the user to pick? or make that dependant on the OpenShift version?). I would love to take this opportunity to ship with Helm templates out-of-the-box, at least for OpenShift v4.

@clemensutschig @metmajer @martsec @segator @henrjk @gerardcl @oalyman Please provide feedback.

segator commented 3 years ago

Agree. From my point of view ODS should support multiple packager apps. as helm will work for basic applications but could not be enough for complex, at this point we'll need something like kustomize. I suggest start moving everyone to helm and avoid export. I Only see benefits. as final user will be aware of how their application is deployed and they will have control over deployment strategy and traceability. Even this open doors to reuse helm packages, decoupling build from deployment process on our jenkins jobs, (nexus have Helm repository support)

michaelsauter commented 3 years ago

Thanks @segator!

as helm will work for basic applications but could not be enough for complex, at this point we'll need something like kustomize.

kustomize does not allow me to do anything that I couldn't do with Helm to my knowledge. To the contrary, kustomize is a simpler approach than Helm. Further, until we have a real-world use case that cannot be covered with Helm, let's not complicate things. But let's keep this discussion separate as it is unrelated to the export functionality.

as final user will be aware of how their application is deployed and they will have control over deployment strategy

I am unsure about how much control should be given to each component. That is an area I need to understand more about. In a GxP context, I'm not sure how much customisation is allowed before the application author needs to account for these in their documentation. To my understanding, right now the application author simply defers to an existing validation of the pre-described deployment approach by the orchestration pipeline. That said, again this is a separate topic and not related to the export functionality so let's keep it out of the discussion for now.

henrjk commented 3 years ago

Please bear with me and let me put my spin on this to clarify the situation perhaps for others also:

To extract Infrastructure as Code from Infrastructure state is a losing proposition and I am fully supporting the idea to remove this from our code base.

henrjk commented 3 years ago

Regarding shipping quickstarters it appears that helm will not make sense for v3.11 so we should use tailor templates for that. I am also for using helm for OpenShift 4.

albertpuente commented 2 years ago

I was thinking today about this... Having helm charts included by default in quickstarters would simplify a lot understanding how to parametrize the deployment to different environments (as long as we carefully see how much we encourage to change). I do not see the automatic exporting of resources by the orchestration pipeline (nor doing it manually with tailor when starting working at a component level) as the most intuitive path for new users.

Has there been any decision been made on this regard? @michaelsauter

michaelsauter commented 2 years ago

To my knowledge, no.

I've added support for Helm in the component pipeline, but the orchestration pipeline does not handle Helm yet. It would need to handle Helm before we can ship quickstarters with Helm charts.

As mentioned above personally I'm all in favour for shipping Helm charts by default and not doing an export ... but I guess this is a bigger change where buy-in has to come from all sides, as a migration for existing users would be needed I think.

metmajer commented 2 years ago

@michaelsauter I have been discussing this topic a few days ago with @clemensutschig. Michael, can you outline what's needed to make the Release Manager with components that use Helm charts?

michaelsauter commented 2 years ago

Sure!

The component pipeline has a switch to either use Helm or Tailor, see https://github.com/opendevstack/ods-jenkins-shared-library/blob/master/src/org/ods/component/RolloutOpenShiftDeploymentStage.groovy#L126-L136.

The same would need to happen in https://github.com/opendevstack/ods-jenkins-shared-library/blob/master/src/org/ods/orchestration/phases/DeployOdsComponent.groovy#L51. This should be the main thing to do, but of course the devil is in the details :)

Right now I can think of the following places needing adjustment:

Apart from this, there are a few differences between Helm and Tailor which would need some consideration. I'm just going to link to https://github.com/opendevstack/tailor/wiki/Migrating-from-Tailor-to-Helm, which offers some more details. One thing to call out here is that existing resources need to be explicitly adopted by Helm before they can be updated by Helm.

serverhorror commented 2 years ago

The component pipeline has a switch to either use Helm or Tailor, see https://github.com/opendevstack/ods-jenkins-shared-library/blob/master/src/org/ods/component/RolloutOpenShiftDeploymentStage.groovy#L126-L136.

For anyone looking, heres the ODS4 docs for this: https://www.opendevstack.org/ods-documentation/opendevstack/4.x/update-guides/4x.html#_helm

serverhorror commented 2 years ago

@michaelsauter We want to give a helm rollout a try.

From what I can see a good starting point is here:

Additionally, the lines you mentioned later.

  • collecting "environment files": for Tailor there is some logic to automatically use param files if they are named using a certain pattern (e.g. foo-dev.env, foo-test.env, foo-prod.env etc.). A similar thing should be done for Helm.

I'm thinking about a values-dev.yaml, values-test.yaml, values-prod.yaml but am not sure how we would like to handle a case with multiple charts, if we even support that by default or want to have a single chart that uses subcharts to get by with a single set of values-....yaml.

Do you prefer a specific issue or should we try and give the PR a reference to this issue?

michaelsauter commented 2 years ago

@serverhorror Have a look at https://github.com/opendevstack/ods-pipeline/blob/master/docs/tasks/ods-deploy-helm.adoc. In ODS Pipeline, we already have implemented a solution that works with multiple values files, and also allows to work with charts spread across repos. Maybe that helps or at least can serve as inspiration?

Do you prefer a specific issue or should we try and give the PR a reference to this issue?

Pick whatever you find suits best.