Search code examples
pulumi

Pulumi - How do we patch a deployment created with helm chart, when values do not contain the property to be updated


I've code to deploy a helm chart using pulumi kubernetes. I would like to patch the StatefulSet (change serviceAccountName) after deploying the chart. Chart doesn't come with an option to specify service account for StatefulSet.

here's my code

// install psmdb database chart
const psmdbChart = new k8s.helm.v3.Chart(psmdbChartName, {
  namespace: namespace.metadata.name,
  path: './percona-helm-charts/charts/psmdb-db',
  // chart: 'psmdb-db',
  // version: '1.7.0',
  // fetchOpts: {
  //   repo: 'https://percona.github.io/percona-helm-charts/'
  // },
  values: psmdbChartValues
}, {
  dependsOn: psmdbOperator
})

const set = psmdbChart.getResource('apps/v1/StatefulSet', `${psmdbChartName}-${psmdbChartValues.replsets[0].name}`);

I'm using Percona Server for MongoDB Operator helm charts. It uses Operator to manage StatefulSet, which also defines CRDs.

I've tried pulumi transformations. In my case Chart doesn't contain a StatefulSet resource instead a CRD.

If it's not possible to update ServiceAccountName on StatefulSet using transformations, is there any other way I can override it?

any help is appreciated.

Thanks,


Solution

  • Seems Pulumi doesn't have straight forward way to patch the existing kubernetes resource. Though this is still possible with multiple steps.

    From Github Comment

    1. Import existing resource
    2. pulumi up to import
    3. Make desired changes to imported resource
    4. pulumi up to apply changes

    It seems they plan on supporting functionality similar to kubectl apply -f for patching resources.