pulumi / pulumi-kubernetesx

Kubernetes for Everyone
Apache License 2.0
135 stars 16 forks source link

[bug] fails to import: removes ports #38

Open brandonkal opened 4 years ago

brandonkal commented 4 years ago

Pulumi does not include ports when adopting resulting in a failure to adopt existing resources: YAML

apiVersion: v1
kind: Service
metadata:
  name: gitea-web
  labels:
    app: gitea-web
spec:
  ports:
    - port: 80
      targetPort: 8080
      name: http
  selector:
    app: gitea

TS Note that using the kubernetes package for this service will also fail with a different error.

import * as kx from '@pulumi/kubernetesx' // version 0.1.1
const svc = new kx.Service(
  'gitea-web',
  {
    metadata: {
      name: 'gitea-web',
      labels: {
        app: 'gitea-web',
      },
    },
    spec: {
      ports: [
        {
          name: 'http',
          port: 80,
          targetPort: 8080,
        },
      ],
      selector: {
        app: 'gitea',
      },
    },
  },
  {
    import: 'gitea-web',
    ignoreChanges: ['metadata.annotations'],
  }
)

Details:

  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:dev::gitkit::pulumi:pulumi:Stack::gitkit-dev]
    = kubernetes:core/v1:Service: (import)
        [id=gitea-web]
        [urn=urn:pulumi:dev::gitkit::kubernetes:core/v1:Service::gitea-web]
        [provider=urn:pulumi:dev::gitkit::pulumi:providers:kubernetes::default_1_3_1::3b7c7381-1acb-47d8-a7fd-dd8563b0de39]
      ~ metadata: {
          - annotations: {}
        }
      ~ spec    : {
          ~ ports: [
              - [0]: {
                      - name      : "http"
                      - port      : 80
                      - targetPort: 8080
                    }
            ]
        }

Also, I appear to be doing something wrong with getting it to ignore annotations.

pgavlin commented 4 years ago

@lblackstone do we have import and ignoreChanges plumbed for kx?

brandonkal commented 4 years ago

I believe the issue is that ignoreChanges is not plumbed for the base kubernetes package either.

The second issue is that ports appear to be ignored in kx.