helm-controller icon indicating copy to clipboard operation
helm-controller copied to clipboard

how the HelmCharts upgrade from apiextensions.k8s.io/v1beta1 to apiextensions.k8s.io/v1

Open xueliangyang-oeuler opened this issue 3 years ago • 11 comments

when change the apiextensions.k8s.io/v1beta1 to apiextensions.k8s.io/v1, errors occur—— error: error validating "helmchart.yaml": error validating data: [ValidationError(CustomResourceDefinition.spec): unknown field "version" in io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionSpec, ValidationError(CustomResourceDefinition.spec): missing required field "versions" in io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionSpec]; if you choose to ignore these errors, turn validation off with --validate=false

the original yaml is from https://github.com/k3s-io/helm-controller/blob/master/manifests/deploy-cluster-scoped.yaml apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: name: helmcharts.helm.cattle.io namespace: kube-system spec: group: helm.cattle.io version: v1 names: kind: HelmChart plural: helmcharts singular: helmchart scope: Cluster

xueliangyang-oeuler avatar May 08 '22 03:05 xueliangyang-oeuler

So is the project still maintaining?

xueliangyang-oeuler avatar May 08 '22 03:05 xueliangyang-oeuler

ping @brandond I need some help for my issue.

xueliangyang-oeuler avatar May 08 '22 04:05 xueliangyang-oeuler

We don't really use that CRD, since the helm controller is usually deployed embedded in RKE2 or K3s, and it will create the CRDs itself using the correct version of the CRD API for whatever cluster it's running on. If you want to use those manifests, just change apiextensions.k8s.io/v1beta1 to apiextensions.k8s.io/v1 if deploying on a Kubernetes version that no longer supports v1beta1 of that API.

And to answer your other question, yes, this project is actively maintained, but only really as a subcomponent of other projects.

brandond avatar May 09 '22 19:05 brandond

@brandond Thanks for your answer. In fact ,I try to change the version from v1beta1 to v1, but error happens, just as the following: error: error validating "helmchart.yaml": error validating data: [ValidationError(CustomResourceDefinition.spec): unknown field "version" in io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionSpec, ValidationError(CustomResourceDefinition.spec): missing required field "versions" in io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionSpec]; if you choose to ignore these errors, turn validation off with --validate=false

the original yaml is from https://github.com/k3s-io/helm-controller/blob/master/manifests/deploy-cluster-scoped.yaml

xueliangyang-oeuler avatar May 10 '22 04:05 xueliangyang-oeuler

Hmm, fair enough it may need some additional modifications for more recent versions of Kubernetes.

What are you trying to accomplish? If you run the controller it will generate and load the CRDs during startup; this is how it's usually used.

brandond avatar May 10 '22 05:05 brandond

I want to install helm-controller for installing other helm chats resources in Kubernetes, and only need the helm-controller. So I want to install related CRDs of helm-controller and deploy helm-controller. And I think helm-controller need to be install with this original method, just as a common controller.

xueliangyang-oeuler avatar May 10 '22 06:05 xueliangyang-oeuler

You don't need to install the CRD to deploy the controller. As I said above, the CRD will be created by the controller when it first starts up. I'll leave this issue open so that we can track updating the CRD manifest checked in to this repo, but it should not block you from deploying the controller to your cluster.

brandond avatar May 10 '22 17:05 brandond

I've opened a PR to add a CRD release artifact, in the mean time you can use this:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: helmcharts.helm.cattle.io
spec:
  group: helm.cattle.io
  names:
    kind: HelmChart
    plural: helmcharts
    singular: helmchart
  preserveUnknownFields: false
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .status.jobName
      name: Job
      type: string
    - jsonPath: .spec.chart
      name: Chart
      type: string
    - jsonPath: .spec.targetNamespace
      name: TargetNamespace
      type: string
    - jsonPath: .spec.version
      name: Version
      type: string
    - jsonPath: .spec.repo
      name: Repo
      type: string
    - jsonPath: .spec.helmVersion
      name: HelmVersion
      type: string
    - jsonPath: .spec.bootstrap
      name: Bootstrap
      type: string
    name: v1
    schema:
      openAPIV3Schema:
        properties:
          spec:
            properties:
              bootstrap:
                type: boolean
              chart:
                nullable: true
                type: string
              chartContent:
                nullable: true
                type: string
              failurePolicy:
                nullable: true
                type: string
              helmVersion:
                nullable: true
                type: string
              jobImage:
                nullable: true
                type: string
              repo:
                nullable: true
                type: string
              repoCA:
                nullable: true
                type: string
              set:
                additionalProperties:
                  nullable: true
                  type: string
                nullable: true
                type: object
              targetNamespace:
                nullable: true
                type: string
              timeout:
                nullable: true
                type: string
              valuesContent:
                nullable: true
                type: string
              version:
                nullable: true
                type: string
            type: object
          status:
            properties:
              jobName:
                nullable: true
                type: string
            type: object
        type: object
    served: true
    storage: true

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: helmchartconfigs.helm.cattle.io
spec:
  group: helm.cattle.io
  names:
    kind: HelmChartConfig
    plural: helmchartconfigs
    singular: helmchartconfig
  preserveUnknownFields: false
  scope: Namespaced
  versions:
  - name: v1
    schema:
      openAPIV3Schema:
        properties:
          spec:
            properties:
              failurePolicy:
                nullable: true
                type: string
              valuesContent:
                nullable: true
                type: string
            type: object
        type: object
    served: true
    storage: true

brandond avatar May 10 '22 19:05 brandond

@brandond Thanks. I will try again as you said.

xueliangyang-oeuler avatar May 11 '22 00:05 xueliangyang-oeuler

When start the k3s-helm-controller, something is wrong, logs are here: E0511 05:13:16.956238 1 reflector.go:126] github.com/rancher/helm-controller/pkg/generated/informers/externalversions/factory.go:117: Failed to list *v1.HelmChart: the server could not find the requested resource (get helmcharts.k3s.cattle.io)

here is my deployment: apiVersion: apps/v1 kind: Deployment metadata: name: k3s-helm-controller namespace: kube-system labels: app: k3s-helm-controller spec: replicas: 1 selector: matchLabels: app: k3s-helm-controller template: metadata: labels: app: k3s-helm-controller spec: containers: - name: k3s-helm-controller image: rancher/helm-controller:v0.1.2 command: ["helm-controller"]

And when I use the crds from the above, also something is wrong, logs are here The CustomResourceDefinition "helmcharts.helm.cattle.io" is invalid:

  • spec.additionalPrinterColumns[3].JSONPath: Invalid value: "spec.version": must be a simple json path starting with .
  • spec.additionalPrinterColumns[4].JSONPath: Invalid value: "spec.repo": must be a simple json path starting with .
  • spec.additionalPrinterColumns[5].JSONPath: Invalid value: "spec.helmVersion": must be a simple json path starting with .
  • spec.additionalPrinterColumns[6].JSONPath: Invalid value: "spec.bootstrap": must be a simple json path starting with .

xueliangyang-oeuler avatar May 11 '22 05:05 xueliangyang-oeuler

Sorry, couple typos in there. Updated the comment, please try again.

brandond avatar May 11 '22 10:05 brandond