Actions to create secret on K8S

3/25/2021

I'm trying to create a secret in k8s using github actions like following (I've pre step which install lightweight k8s - k3s)

  - name: example tests
    shell: bash
    env:
      SUPER_SECRET: ${{ secrets.KUBECONFIG }}
   run: |
       kubectl create secret generic mysec --from-literal="$SUPER_SECRET" -n default

But I got error, any idea how to do it using github actions?

I use the settings->secrets and create a KUBECONFIG value and put the file content

in my local env I created a secret successfully with a kubeconfig file like:

 kubectl create secret generic mysec --from-file=./kubeconfig -n default

But in the CI I want to use it from the secret env in github ...

The error is: Error: Error: The process '/usr/local/bin/kubectl' failed with exit code 1

Error: ENAMETOOLONG: name too long, open '/home/runner/work/_temp/* * * * * *

What am I missing here?

I tried also with

kubectl create secret generic mysec --from-literal kubeconfig=$SUPER_SECRET -n default

If there is other way to make it work please let me know.

-- Alberto
azure
github
github-actions
kubernetes

0 Answers