Azure / k8s-create-secret

GitHub Action to create Kubernetes cluster secrets
MIT License
35 stars 31 forks source link

kubelogin ENOENT #88

Closed alxxyz closed 1 year ago

alxxyz commented 1 year ago
    name: Set secret
    uses: azure/k8s-create-secret@v4
    with:
      namespace: ${{ inputs.namespace }}
      secret-type: 'generic'
      secret-name: database-data
      string-data: '{"data": "Very secret data"}'

I get an error for this action

Run azure/k8s-create-secret@v4
Warning: Failed to delete secret with statusCode: undefined
Deleting secret:
undefined
Creating secret
***"errno":-2,"code":"ENOENT","syscall":"spawnSync kubelogin","path":"kubelogin","spawnargs":["get-token","--environment","AzurePublicCloud"

How to fix this?
davidgamero commented 1 year ago

@alxxyz can you attach the rest of the workflow? which action are you using to set your context before calling k8s-create-secret?

alxxyz commented 1 year ago

Hi @davidgamero, these are other actions

  - name: Authenticate to AKS
    uses: azure/login@v1
    with:
      creds: ${{ inputs.principal }}

  - name: Set AKS Context
    uses: azure/aks-set-context@v3
    with:
        cluster-name: ${{ inputs.cluster-name }}
        resource-group: ${{ inputs.resource-group }}
        subscription: ${{ inputs.subscription }}
davidgamero commented 1 year ago

are you using this as a non-admin user? you may need to add kubelogin

You can do this by adding use-kubelogin: 'true' to your aks-set-context "with" clause and adding this step before it:

- name: Set up kubelogin for non-interactive login
  uses: azure/use-kubelogin@v1
  with:
     kubelogin-version: 'v0.0.24'
alxxyz commented 1 year ago

It works, thank you!

I guess it will be good to add this info to documentation.

davidgamero commented 1 year ago

@alxxyz I'm glad it works for you! this is already included in the documentation under Example > Kubelogin in the README