Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass Values from a relative Path in a Git Repo to a HelmRelease created by Subscription #335

Open
abdennour opened this issue May 3, 2023 · 1 comment

Comments

@abdennour
Copy link

I have helm chart in a Git repo, and alongside the file "values.yaml" there is other Values files within same directory ( same helm chart directory).

-- my-git-repo
 |___myapp/
           |__ templates/
           |__ Chart.yaml
           |__ values.yaml
           |__ values.cluster1.yaml

With helm command, it's about :

cd my-git-repo
helm install xxx ./myapp/ -f values.cluster1.yaml

How to reach the same with Subscription/Channel resources?

So far, this is the resources that i configured:

apiVersion: app.k8s.io/v1beta1
kind: Application
metadata:
  name: test-myapp
  namespace: services
spec:
  componentKinds:
  - group: apps.open-cluster-management.io
    kind: Subscription
  descriptor: {}
  selector:
    matchExpressions:
      - key: app
        operator: In
        values: 
          - test-myapp
---
apiVersion: v1
kind: Namespace
metadata:
  name: gbitbucketcompanycom-scl-boilerplate-helm-releases-ns
---
apiVersion: apps.open-cluster-management.io/v1
kind: Channel
metadata:
  annotations:
    apps.open-cluster-management.io/reconcile-rate: medium
  name: gbitbucketcompanycom-scl-boilerplate-helm-releases
  namespace: gbitbucketcompanycom-scl-boilerplate-helm-releases-ns
spec:
  type: Git
  pathname: 'https://bitbucket.company.com/scl/boilerplate-helm-releases.git'
  secretRef:
    name: gbitbucketcompanycom-scl-boilerplate-helm-releases-auth
---
apiVersion: v1
kind: Secret
metadata:
  name: gbitbucketcompanycom-scl-boilerplate-helm-releases-auth
  namespace: gbitbucketcompanycom-scl-boilerplate-helm-releases-ns
data:
  user: # injected on create
  accessToken: # injected on create
---
apiVersion: apps.open-cluster-management.io/v1
kind: Subscription
metadata:
  annotations:
    apps.open-cluster-management.io/git-branch: master
    apps.open-cluster-management.io/git-path: myapp
    apps.open-cluster-management.io/reconcile-option: merge
  labels:
    app: test-myapp
  name: test-myapp-subscription-1
  namespace: services
spec:
  channel: gbitbucketcompanycom-scl-boilerplate-helm-releases-ns/gbitbucketcompanycom-scl-boilerplate-helm-releases
  placement:
    placementRef:
      kind: PlacementRule
      name: test-myapp-placement-1
---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
metadata:
  labels:
    app: test-myapp
  name: test-myapp-placement-1
  namespace: services
spec:
  clusterSelector:
    matchLabels:
       cluster-env: lab

After creating those resources, a resource HelmRelease has been auto-generated in the target cluster, and it looks like :

apiVersion: apps.open-cluster-management.io/v1
kind: HelmRelease
metadata:
  annotations:
    apps.open-cluster-management.io/hosting-subscription: services/test-myapp-subscription-1
  finalizers:
    - uninstall-helm-release
  generation: 1
  labels:
    app: test-myapp
    app.kubernetes.io/part-of: test-myapp
    apps.open-cluster-management.io/reconcile-rate: medium
  name: myapp-e7b58
  namespace: services
  ownerReferences:
    - apiVersion: apps.open-cluster-management.io/v1
      kind: Subscription
      name: test-myapp-subscription-1
      uid: xxxxxx-tttt-dddd-eeee-xxxxxx

repo:
  chartName: myapp
  digest: generated-by-multicloud-operators-subscription
  secretRef:
    name: gbitbucketcompanycom-scl-boilerplate-helm-releases-auth
    namespace: gbitbucketcompanycom-scl-boilerplate-helm-releases-ns
  source:
    git:
      branch: master
      chartPath: myapp
      urls:
        - https://bitbucket.company.com/scl/boilerplate-helm-releases.git
    type: git
  version: 0.1.0
spec:
  '': ''
status:
  conditions:
    - lastTransitionTime: 'xxx'
      reason: InstallSuccessful
      status: 'True'
      type: Deployed
  deployedRelease:
    name: myapp-e7b58

Is there a way to pass values file path (relative to the chart directory) to the HelmRelease CR thru its Subscription CR ?

@mikeshng
Copy link
Member

mikeshng commented May 3, 2023

https://github.com/open-cluster-management-io/multicloud-operators-subscription/blob/main/examples/helmrepo-channel/02-subscription.yaml#L10-L17

  packageOverrides:
  - packageName: nginx-ingress # your helm chart name
    packageAlias: nginx-ingress-simple # this will enforce a helm release name ie: when you do helm ls
    packageOverrides:
    - path: spec # must be this value 
      value: # below this key is where you define the "values.yaml" overrides
        defaultBackend:
          replicaCount: 3

Does that help answer your question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants