FairwindsOps / pluto

A cli tool to help discover deprecated apiVersions in Kubernetes
https://fairwinds.com
Apache License 2.0
2.14k stars 124 forks source link

issue with Helm (v2) detection on my cluster #40

Closed sdesbure closed 4 years ago

sdesbure commented 4 years ago

Hello, we have a lot of (big, fat, awful) helm deployment and I wanted to check deprecation with pluto:

but it doesn't work as expexted (I assume):

$ helm ls
NAME                            REVISION    UPDATED                     STATUS      CHART                               APP VERSION NAMESPACE
kube-eagle                      1           Wed Apr 15 06:44:59 2020    DEPLOYED    kube-eagle-1.1.5                    1.1.0       monitoring
onap                            1           Wed Apr 15 07:21:11 2020    DEPLOYED    onap-6.0.0                          El Alto     onap
onap-aaf                        1           Wed Apr 15 07:21:12 2020    DEPLOYED    aaf-6.0.0                                       onap
onap-aai                        1           Wed Apr 15 07:21:13 2020    DEPLOYED    aai-6.0.0                                       onap
onap-appc                       1           Wed Apr 15 07:21:21 2020    DEPLOYED    appc-6.0.0                                      onap
onap-cassandra                  1           Wed Apr 15 07:21:26 2020    DEPLOYED    cassandra-6.0.0                                 onap
onap-cds                        1           Wed Apr 15 07:21:27 2020    DEPLOYED    cds-6.0.0                                       onap
onap-clamp                      1           Wed Apr 15 07:21:30 2020    DEPLOYED    clamp-6.0.0                                     onap
onap-cli                        1           Wed Apr 15 07:21:31 2020    DEPLOYED    cli-6.0.0                                       onap
onap-consul                     1           Wed Apr 15 07:21:31 2020    DEPLOYED    consul-6.0.0                                    onap
onap-contrib                    1           Wed Apr 15 07:21:33 2020    DEPLOYED    contrib-6.0.0                                   onap
onap-dcaegen2                   1           Wed Apr 15 07:21:35 2020    DEPLOYED    dcaegen2-6.0.0                                  onap
onap-dcaemod                    1           Wed Apr 15 07:21:54 2020    DEPLOYED    dcaemod-6.0.0                                   onap
onap-dmaap                      1           Wed Apr 15 07:22:01 2020    FAILED      dmaap-6.0.0                                     onap
onap-esr                        1           Wed Apr 15 07:37:11 2020    DEPLOYED    esr-6.0.0                                       onap
onap-log                        1           Wed Apr 15 07:37:13 2020    DEPLOYED    log-6.0.0                                       onap
onap-mariadb-galera             1           Wed Apr 15 07:37:14 2020    DEPLOYED    mariadb-galera-6.0.0                            onap
onap-modeling                   1           Wed Apr 15 07:37:15 2020    DEPLOYED    modeling-6.0.0                                  onap
onap-msb                        1           Wed Apr 15 07:37:17 2020    DEPLOYED    msb-6.0.0                                       onap
onap-multicloud                 1           Wed Apr 15 07:37:19 2020    DEPLOYED    multicloud-6.0.0                                onap
onap-nbi                        1           Wed Apr 15 07:37:21 2020    DEPLOYED    nbi-6.0.0                                       onap
onap-oof                        1           Wed Apr 15 07:37:25 2020    DEPLOYED    oof-6.0.0                                       onap
onap-policy                     1           Wed Apr 15 07:37:34 2020    DEPLOYED    policy-6.0.0                                    onap
onap-pomba                      1           Wed Apr 15 07:37:40 2020    DEPLOYED    pomba-6.0.0                                     onap
onap-portal                     1           Wed Apr 15 07:37:44 2020    DEPLOYED    portal-6.0.0                                    onap
onap-robot                      1           Wed Apr 15 07:37:47 2020    DEPLOYED    robot-6.0.0                                     onap
onap-sdc                        1           Wed Apr 15 07:37:48 2020    DEPLOYED    sdc-6.0.0                                       onap
onap-sdnc                       1           Wed Apr 15 07:37:51 2020    DEPLOYED    sdnc-6.0.0                                      onap
onap-sniro-emulator             1           Wed Apr 15 07:48:31 2020    DEPLOYED    sniro-emulator-6.0.0                            onap
onap-so                         1           Wed Apr 15 07:48:31 2020    DEPLOYED    so-6.0.0                                        onap
onap-uui                        1           Wed Apr 15 07:50:13 2020    DEPLOYED    uui-6.0.0                                       onap
onap-vfc                        1           Wed Apr 15 07:50:14 2020    DEPLOYED    vfc-6.0.0                                       onap
onap-vid                        1           Wed Apr 15 07:50:19 2020    DEPLOYED    vid-6.0.0                                       onap
onap-vnfsdk                     1           Wed Apr 15 07:50:22 2020    DEPLOYED    vnfsdk-6.0.0                                    onap
prometheus-blackbox-exporter    1           Wed Apr 15 06:44:51 2020    DEPLOYED    prometheus-blackbox-exporter-3.4.0  0.15.1      monitoring
prometheus-operator             1           Wed Apr 15 06:43:30 2020    DEPLOYED    prometheus-operator-8.12.13         0.37.0      monitoring
weave-scope                     1           Wed Apr 15 06:43:09 2020    DEPLOYED    weave-scope-1.1.10                  1.12.0      monitoring
$ pluto detect-helm -v8 --helm-version=2
I0415 15:21:48.554216   17322 loader.go:375] Config loaded from file:  /Users/sylvain/.kube/config
I0415 15:21:48.556031   17322 round_trippers.go:420] GET https://127.0.0.1:6443/api/v1/configmaps?labelSelector=OWNER%3DTILLER
I0415 15:21:48.556058   17322 round_trippers.go:427] Request Headers:
I0415 15:21:48.556067   17322 round_trippers.go:431]     Accept: application/json, */*
I0415 15:21:48.556074   17322 round_trippers.go:431]     User-Agent: pluto/v0.0.0 (darwin/amd64) kubernetes/$Format
I0415 15:21:48.729969   17322 round_trippers.go:446] Response Status: 200 OK in 173 milliseconds
I0415 15:21:48.729998   17322 round_trippers.go:449] Response Headers:
I0415 15:21:48.730006   17322 round_trippers.go:452]     Content-Type: application/json
I0415 15:21:48.730013   17322 round_trippers.go:452]     Date: Wed, 15 Apr 2020 13:21:48 GMT
I0415 15:21:49.231527   17322 request.go:1017] Response Body: {"kind":"ConfigMapList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/configmaps","resourceVersion":"189177"},"items":[{"metadata":{"name":"kube-eagle.v1","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/configmaps/kube-eagle.v1","uid":"e5262e4b-ef59-420b-809e-595dfc7fd5fa","resourceVersion":"7664","creationTimestamp":"2020-04-15T04:44:59Z","labels":{"MODIFIED_AT":"1586925899","NAME":"kube-eagle","OWNER":"TILLER","STATUS":"DEPLOYED","VERSION":"1"}},"data":{"release":"H4sIAAAAAAAC/+w8d1gU1/bYoo4kMaiILVwXECHsAioGVsUCKCjSQQUjzu7e3R2YnVlmZqkSsMSIIpZIgr3FrjGaoGJvsUfBgooKJsYQK3ZUhP19M7MdMJKXvPe97/38g2925tzT77nnnnuuCJKokUAhRBU4tLnfAtnXok0zwa4WDg4OYJThA3BwcEAQmKomKQaEhfrHhwwdHTDIsTc7VMrgQAEZoCZlNBAKCVQFaTUqhUBFEhhDUhihAEIcCFC1epCRlBsFcYjS0OSVAAhJkECThBpllIMEGSKMgSo6zuMzkQoyqAxlUBGLPFPggiBQqiSBIIoEDKQZwCghkGsIKYORBIpjTJoboCGjUQMU6DlkORfKSSoFpWSAJEAaqaEATkpRHKhQqRIjoAhEKSH3AUhRAiRjNMZjlkCcTAHREcG0QEc3hvumZBi12N3ds8+nIg+Rh8hT7O3h7eGuggyFSWnAkECqhNJEDgWrORrKgO7ju+BRQhRnlCwaFZoIAa2hICcM4A2C0YDSEASr [truncated 5624181 chars]
I0415 15:21:49.492648   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.493304   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.500651   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.530575   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.543033   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.545200   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.548839   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.554656   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.555173   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.560202   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.566084   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.580253   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.586464   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.587965   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.592394   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.593796   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.596183   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.600184   17322 versions.go:129] not json: invalid character '-' in numeric literal
I0415 15:21:49.602625   17322 versions.go:135] not yaml: yaml: unmarshal errors:
  line 969: mapping key "metadata" already defined at line 966
Error running helm-detect: no matches for stub, error: yaml: unmarshal errors:
  line 969: mapping key "metadata" already defined at line 966

fyi I'm "out of cluster" with ssh proxy in between if

lucasreed commented 4 years ago

So a couple of things going on.

  1. We should handle this error gracefully and give you a useful message
  2. This error means one of your chart templates is defining a field more than once, so that should probably be fixed as well. The field in question is metadata in this case, but we unfortunately don't output which chart/resource it's in.

I hit a similar issue in testing when running against the prometheus-operator chart that was defining two namespaces in a template. Helm just merges these duplicate fields I suppose so it's not noticed upon deploying. Here is the commit that fixes that chart as an example.

All that being said, we need to handle this situation with better output. Thanks for the bug report!