armory / spinnaker-operator

Open Source Spinnaker Kubernetes Operator source code
Apache License 2.0
187 stars 70 forks source link

Getting error when referencing the kubeconfigfile in spinnaker operator when adding kubernetes account #225

Open praseedasathaye opened 3 years ago

praseedasathaye commented 3 years ago

I am referencing https://docs.armory.io/docs/armory-admin/kubernetes-account-add/#add-the-kubeconfig-and-cloud-provider-to-spinnaker for adding kubeconfig for cloud driver, Is there any way I can copy the content to env variable and add here instead of file content. I tried below but I get this error error: unable to recognize "STDIN": no matches for kind "Config" in version "spinnaker.io/v1alpha2"

apiVersion: spinnaker.io/v1alpha2
kind: SpinnakerService
metadata:
  name: spinnaker
spec:
  spinnakerConfig:
    files: 
        kubeconfig-sp: |
          "$KUBECONFIG_CONTENT"
    profiles: 

Doc says: kubeconfigFile: A file path referencing the contents of the kubeconfig file for connecting to the target cluster. When using the Operator, this can be any name that should match an entry in spec.spinnakerConfig.files where the file contents is copied. If using Halyard, this is a physical file path. This field supports referencing files stored in external secret engines

I also tried

apiVersion: spinnaker.io/v1alpha2
kind: SpinnakerService
metadata:
  name: spinnaker
spec:
  spinnakerConfig:
    files: 
        kubeconfig-sp: |
          $(awk '{printf "    %s\n", $0}' < /home/ec2-user/Kubeconfig-ws-sa)

And also

apiVersion: spinnaker.io/v1alpha2
kind: SpinnakerService
metadata:
  name: spinnaker
spec:
  spinnakerConfig:
    files: 
        kubeconfig-sp: |
          $(awk '{printf "    %s\n", $0}' < front_config)
philvadala commented 3 years ago

I'm also running into the same issue. I've also tried to parse the json from my kubeconfigfile and added it to the manifest file.

Is it recommended to use halyard instead?

praseedasathaye commented 3 years ago

I'm also running into the same issue. I've also tried to parse the json from my kubeconfigfile and added it to the manifest file.

Is it recommended to use halyard instead?

Copying the kubeconfig json data into the section of spinnakersservice.yaml manifest works for me. But referencing the content as a file does not work.

widdix123 commented 2 years ago

you need to make sure the indentation starts from the same line as example below

  files:
      kubeconfig-sp: |
        apiVersion: v1
        clusters:
        - cluster:
            certificate-authority-data: xxxxxx
            server: xxxxxx
          name: xxxxx
        contexts:
        - context:
            cluster: xxxxxx
            namespace: spinnaker
            user: spinnaker-token-user
          name: spinnaker
        current-context: spinnaker
        kind: Config
        preferences: {}
        users:
        - name: spinnaker-token-user
          user:
            token:  xxxxx