open-cluster-management-io / multicloud-operators-subscription

Enables multicluster application delivery.
https://open-cluster-management.io/getting-started/integration/app-lifecycle/
Apache License 2.0
44 stars 38 forks source link

subscribe git channel with Chart.yaml and values.yaml files #159

Open callum-stakater opened 2 years ago

callum-stakater commented 2 years ago

If you create a git channel and subscribe to a path that contains a Chart.yaml and values.yaml I would except OCM to be able to deploy the chart similar to how ArgoCD is able too

It seems it is able to determine the Chart.yaml is a helm object and creates a HelmRelease but seems no resources are deployed

Example:

## I was hoping this one would work, to source Chart.yaml from git repo but it doesnt
## seem to work as expected, it does create the helmrelease but cant see why the resources
## dont get deployed

apiVersion: v1
kind: Namespace
metadata:
  name: nordmart-review
---
apiVersion: app.k8s.io/v1beta1
kind: Application
metadata:
  name: nordmart-review
  namespace: nordmart-review
spec:
  componentKinds:
  - group: apps.open-cluster-management.io
    kind: Subscription
  descriptor: {}
  selector:
    matchExpressions:
      - key: app
        operator: In
        values:
          - nordmart-review
---
apiVersion: apps.open-cluster-management.io/v1
kind: Subscription
metadata:
  annotations:
    apps.open-cluster-management.io/git-branch: main
    apps.open-cluster-management.io/git-path: deploy/
    apps.open-cluster-management.io/reconcile-option: replace
  labels:
    app: nordmart-review
  name: nordmart-review-subscription-dev
  namespace: nordmart-review
spec:
  channel: rhacm-channel-stakater-lab-nordmart-review/rhacm-channel-stakater-lab-nordmart-review
  placement:
    placementRef:
      kind: PlacementRule
      name: nordmart-review-placement-dev
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
metadata:
  labels:
    app: nordmart-review
  name: nordmart-review-placement-dev
  namespace: nordmart-review
spec:
  clusterConditions:
    - type: ManagedClusterConditionAvailable
      status: "True"
 ---
 apiVersion: v1
kind: Namespace
metadata:
  name: rhacm-channel-stakater-lab-nordmart-review
---
apiVersion: apps.open-cluster-management.io/v1
kind: Channel
metadata:
  annotations:
    apps.open-cluster-management.io/reconcile-rate: medium
  name: rhacm-channel-stakater-lab-nordmart-review
  namespace: rhacm-channel-stakater-lab-nordmart-review
spec:
  type: Git
  pathname: 'https://github.com/stakater-lab/stakater-nordmart-review'

All the content here is publicly available so should be possible to deploy this as is to recreate the issue

Struggling to find any thing relevant in docs or google foo which makes me think I am maybe doing something wrong?

mikeshng commented 2 years ago

@callum-stakater could you please confirm this is the right folder you are targeting to install as Helm chart? https://github.com/stakater-lab/stakater-nordmart-review/tree/main/deploy

Based on my understanding of Helm https://helm.sh/docs/topics/charts/ you should have at least a templates folder containing the manifest yamls you are trying to install.

What happen if you don't use OCM appsub to install this helm chart but just use the regular helm CLI? For example, what happen if you run helm install deploy deploy ?

callum-stakater commented 2 years ago

Yeah sorry it’s using a leader chart, the Chart.yaml pulls in another generic shared chart via the dependencies: block there, which is also public hosted chart so no auth in the way

To deploy it via helm cli does work BUT you do need to “helm dependency build” first which is maybe what OCM is missing here, I can do some more testing to try validate these assumptions that it is the lack of dependency pull down that is causing what appears to be an empty helmrelease

callum-stakater commented 2 years ago

i see helm install has the flag:

--dependency-update            update dependencies if they are missing before installing the chart

is OCM basically doing a helm install under the hood?

mikeshng commented 2 years ago

@callum-stakater Yes, the OCM app-addon is basically doing a helm install via a Helm3 SDK call. But it's currently not passing the --dependency-update flag. There is also no options to pass in additional params for these type of flags. Since the Helm related code is mostly from https://github.com/operator-framework/operator-sdk I am going to reach out to the maintainers over there first and see how to adopt this feature. Thanks for reporting.

mikeshng commented 2 years ago

It looks like the operator-sdk helm operator "version 2" is going to have this type of support https://github.com/operator-framework/helm-operator-plugins/blob/6470a8f4bc1311e47826584fc502a52ce58d23f0/pkg/reconciler/reconciler.go#L731-L736

For future note: if we want something similar, we can follow the same design in operator-framework/helm-operator-plugins project.