Giter VIP home page Giter VIP logo

setup-kubectl's Introduction

Setup Kubectl

Sample workflow to install a specific version of kubectl binary on the runner.

Acceptable values are latest or any semantic version string like v1.15.0. Use this action in workflow to define which version of kubectl will be used.

- uses: azure/setup-kubectl@v3
  with:
     version: '<version>' # default is latest stable
  id: install

Refer to the action metadata file for details about all the inputs https://github.com/Azure/setup-kubectl/blob/main/action.yml

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Support

setup-kubectl is an open source project that is not covered by the Microsoft Azure support policy. Please search open issues here, and if your issue isn't already represented please open a new one. The project maintainers will respond to the best of their abilities.

setup-kubectl's People

Contributors

aamgayle avatar ccremer avatar davidgamero avatar dependabot[bot] avatar gtrubach avatar microsoftopensource avatar msftgits avatar olivermking avatar perkrlsn avatar rethab avatar rgsubh avatar shashankbarsin avatar shigupt202 avatar sumnerwarren avatar sundargs2000 avatar tauhid621 avatar tbarnes94 avatar thesattiraju avatar vidya2606 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

setup-kubectl's Issues

No such file or directory

/opt/hostedtoolcache/kubectl/1.24.1/x64/kubectl: No such file or directory

The above now shows when kubectl is ran on Actions 2.293.0.

Error: Cannot find module '@actions/tool-cache'

I am getting the following error:

Run azure/setup-kubectl@fe45ba1148dde192f0ccd6dbb58caacb996c1452
internal/modules/cjs/loader.js:800
    throw err;
    ^

Error: Cannot find module '@actions/tool-cache'
Require stack:
- /usr/local/bin/actions-runner/_work/_actions/azure/setup-kubectl/fe45ba1148dde192f0ccd6dbb58caacb996c1452/lib/run.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/bin/actions-runner/_work/_actions/azure/setup-kubectl/fe45ba1148dde192f0ccd6dbb58caacb996c1452/lib/run.js:16:19)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/bin/actions-runner/_work/_actions/azure/setup-kubectl/fe45ba1148dde192f0ccd6dbb58caacb996c1452/lib/run.js'
  ]
}

I am confused if I need install those modules separately. I am using self hosted runners.

My understanding all dependencies should be pre-build using ncc package (recommended approach from Github)

https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#commit-tag-and-push-your-action-to-github

Example:
https://github.com/actions/setup-node/blob/main/package.json#L8
https://github.com/actions/setup-node/blob/main/dist/setup/index.js

Error trying to use the action on my project

I tried using azure/setup-kubectl action, providing the documented inputs, and I'm getting the next error:

image

I would provide more logs if I could, but that's as much as I get from GH Actions

This is the code I used to try to use the action:

name: Publish a new production release

on:
  create:
    tags:
      - v*

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - uses: azure/setup-kubectl@v1
      with:
        version: '1.15.0'
      id: install
      name: install kubectl client
    - name: create kubernetes config
      run: |
        cat << EOF > kube-config
        apiVersion: v1
        clusters:
        - cluster:
            certificate-authority-data: ${{ secrets.CLUSTER_CERT_AUTH_DATA }}
            server: ${{ secrets.CLUSTER_IP }}
          name: kubernetes
        contexts:
        - context:
            cluster: kubernetes
            user: kubernetes-admin
          name: kubernetes-admin@kubernetes
        current-context: kubernetes-admin@kubernetes
        kind: Config
        preferences: {}
        users:
        - name: kubernetes-admin
          user:
            client-certificate-data: ${{ secrets.CLIENT_CERT_DATA }}
            client-key-data: ${{ secrets.CLIENT_KEY_DATA }}
        EOF
        export KUBECONFIG=$(pwd)/kube-config
    - name: build kubernetes manifest files and deploy them
      run: |
        make build-kubernetes deploy-kubernetes

Please let me know if there's anything else I can provide to help solve this, I'm pretty sure I'm missing something super obvious but I can't put my finger on it.

ARM support

Hello,

As I understand this action does not support ARM since there is amd64 hardcoded in download URLs. Is it possible to make this work with ARM (ideally is should decide the arch based on the arch where it's running)?

kubectl not found in PATH (v2.1)

As already mentioned in #3 the kubectl path does not seem to be added to the PATH environment variable.
I'm using v2.1 and when executing any kubectl command it runs into an error that kubectl is not found:

/_temp/AZ_CLI_GITHUB_ACTION_1652104293056.sh: line 4: kubectl: command not found
Error: Error: az cli script failed.

I'm running in a self hosted environment with runner version 2.288.1

Bump to Node 20

changes already merged into main branch but not released. do you have any news?

Action is failing to install kubectl due to wrong URL

I've been trying to install version 1.23.15 (and all other 1.23.x) versions using this action but it always fails to download the tool.

It tries to download kubectl from the following URL:

'https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubectl',

which doesn't seem to be correct. Instead it should be:

https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-kubectl-binary-with-curl-on-linux

Bug: Action causes deprecated 'set-output' command warning

What happened?

Using azure/[email protected] causes the GHA complain about usage of deprecated set-output command. Its probably coming from one of the dependencies which could be upgraded.

Version

  • I am using the latest version

Runner

Relevant log output

Run azure/[email protected]
Warning: The set-output command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

GITHUB_TOKEN permissions used by this action

At https://github.com/step-security/secure-workflows we are building a knowledge-base (KB) of GITHUB_TOKEN permissions needed by different GitHub Actions. When developers try to set minimum token permissions for their workflows, they can use this knowledge-base instead of trying to research permissions needed by each GitHub Action they use.

Below you can see the KB of your GITHUB Action.

name: "Kubectl tool installer" # Azure/setup-kubectl
# GITHUB_TOKEN not used

If you think this information is not accurate, or if in the future your GitHub Action starts using a different set of permissions, please create an issue at https://github.com/step-security/secure-workflows/issues to let us know.

This issue is automatically created by our analysis bot, feel free to close after reading :)

References:

GitHub asks users to define workflow permissions, see https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ and https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token for securing GitHub workflows against supply-chain attacks.

Setting minimum token permissions is also checked for by Open Source Security Foundation (OpenSSF) Scorecards. Scorecards recommend using https://github.com/step-security/secure-workflows so developers can fix this issue in an easier manner.

Bug: running amd64 kubectl on runners returns 'cannot execute binary file: Exec format error'

What happened?

Additionally when leveraging the action
'azure/setup-kubectl@v3'

Error: Error: Kubectl 'v1.28.3' for 'amd64' arch not found.

Version

  • I am using the latest version

Runner

ubuntu-latest

Relevant log output

  with:
    version: latest
  env:
    VERSION: 
    CUSTOMER: thunderdome
    TENANT: test
    COMPONENT_OVERRIDES: ""
    EXCLUSIVE_COMPONENTS: stopevents-gql-api,stopevents-3pi-in-tripevents-to-notifications-con,stopevents-3pi-in-tripevents-to-stopevents-con,stopevents-3pi-out-trackrequests-from-stopevents-con,stopevents-3pi-out-tripevents-from-stopevents-con,stopevents-load-route-vendors-v1-con,stopevents-load-routes-stops-v1-con,stopevents-load-routes-stops-v[2](https://github.com/masterysystems/mastermind-release/actions/runs/6565412886/job/17833883230#step:3:2)-con,stopevents-aggregation-con,stopevents-current-stop-aggregation-con,stopevents-stopex-events-subscription-api-con,stopevents-current-and-next-stop-consumer,stopevents-from-driver-assignments,stopevents-load-routes-v2-con,stopevents-trailer-exception
    ROBOTSLACK_NOTIFICATIONS: Success&Failures
    FIX_OPERATION_IN_PROGRESS: 
    FIX_CANNOT_PATCH: 
    KONDUCTOR_HOME: .
    KUBECONFIG: /home/runner/work/_temp/kubeconfig_16464116[3](https://github.com/masterysystems/mastermind-release/actions/runs/6565412886/job/17833883230#step:3:3)7[4](https://github.com/masterysystems/mastermind-release/actions/runs/6565412886/job/17833883230#step:3:4)[6](https://github.com/masterysystems/mastermind-release/actions/runs/6565412886/job/17833883230#step:3:6)3
    E2EFLAG: 
    RUN_TESTS:  
Error: Error: Kubectl 'v1.2[8](https://github.com/masterysystems/mastermind-release/actions/runs/6565412886/job/17833883230#step:3:8).3' for 'amd64' arch not found.```

When trying the workout 

name: test-kubectl
run-name: test-kubectl
on:
  workflow_dispatch:

jobs:
  test-kubectl:
    name: test-kubectl
    runs-on: ubuntu-latest
    steps:
      - run: |
          lscpu
          curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.28.2/bin/darwin/amd64/kubectl
          sudo mv ./kubectl /usr/local/bin/kubectl
          sudo chmod +x /usr/local/bin/kubectl
          which kubectl
          kubectl

error 

Run lscpu
  lscpu
  curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.[2](https://github.com/masterysystems/mastermind-release/actions/runs/6565473319/job/17834071172#step:2:2)8.2/bin/darwin/amd64/kubectl
  sudo mv ./kubectl /usr/local/bin/kubectl
  sudo chmod +x /usr/local/bin/kubectl
  which kubectl
  kubectl
  shell: /usr/bin/bash -e {0}
Architecture:                       x86_64
CPU op-mode(s):                     [3](https://github.com/masterysystems/mastermind-release/actions/runs/6565473319/job/17834071172#step:2:3)2-bit, 6[4](https://github.com/masterysystems/mastermind-release/actions/runs/6565473319/job/17834071172#step:2:4)-bit
Address sizes:                      46 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             2
On-line CPU(s) list:                0,1
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
CPU family:                         6
Model:                              8[5](https://github.com/masterysystems/mastermind-release/actions/runs/6565473319/job/17834071172#step:2:5)
Thread(s) per core:                 1
Core(s) per socket:                 2
Socket(s):                          1
Stepping:                           7
BogoMIPS:                           5187.81
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse3[6](https://github.com/masterysystems/mastermind-release/actions/runs/6565473319/job/17834071172#step:2:6) clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap clflushopt avx512cd avx512bw avx512vl xsaveopt xsavec xsaves md_clear
Hypervisor vendor:                  Microsoft
Virtualization type:                full
L1d cache:                          64 KiB (2 instances)
L1i cache:                          64 KiB (2 instances)
L2 cache:                           2 MiB (2 instances)
L3 cache:                           35.8 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0,1
Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status
Vulnerability Itlb multihit:        KVM: Mitigation: VMX unsupported
Vulnerability L1tf:                 Mitigation; PTE Inversion
Vulnerability Mds:                  Mitigation; Clear CPU buffers; SMT Host state unknown
Vulnerability Meltdown:             Mitigation; PTI
Vulnerability Mmio stale data:      Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Retbleed:             Vulnerable
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Vulnerable
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Mitigation; Clear CPU buffers; SMT Host state unknown
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 54 53.3M   54 29.2M    0     0  50.5M      0  0:00:01 --:--:--  0:00:01 50.5M
100 53.3M  100 53.3M    0     0  62.8M      0 --:--:-- --:--:-- --:--:-- 62.8M
/usr/local/bin/kubectl
/home/runner/work/_temp/3a940518-e3ea-45f0-b105-23260ec3c[7](https://github.com/masterysystems/mastermind-release/actions/runs/6565473319/job/17834071172#step:2:7)20.sh: line 6: /usr/local/bin/kubectl: cannot execute binary file: Exec format error
Error: Process completed with exit code [12](https://github.com/masterysystems/mastermind-release/actions/runs/6565473319/job/17834071172#step:2:13)6.

Bug: kubectl for amd64 was not found

What happened?

I'm running the following step on my github workflow and got an error telling that the version '1.28.2' for 'amd64' was not found.

            - name: install kubectl
              uses: azure/setup-kubectl@v3

i've tried to downgrade the version adding the following, but got the same error:

              with:
                  version: '1.28.2'`

The error is strange because reaching the download link locally on my machine works correctly.

Version

  • I am using the latest version

Runner

ubuntu-latest

Relevant log output

##[debug]Evaluating condition for step: 'install kubectl'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: install kubectl
##[debug]Loading inputs
##[debug]Loading env
Run azure/setup-kubectl@v3
##[debug]Downloading https://storage.googleapis.com/kubernetes-release/release/stable.txt
##[debug]Destination /home/runner/work/_temp/8ed25fc3-ddb3-4b8b-847a-244571e4a0e9
##[debug]download complete
##[debug]isExplicit: 1.28.3
##[debug]explicit? true
##[debug]checking cache: /opt/hostedtoolcache/kubectl/1.28.3/x64
##[debug]not found
##[debug]Downloading https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl
##[debug]Destination /home/runner/work/_temp/50d81c8f-95cc-4889-8d7a-ab8d1a2da771
##[debug]Failed to download from "https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl". Code(404) Message(Not Found)
Error: Error: Kubectl 'v1.28.3' for 'amd64' arch not found.
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: install kubectl

image

Any plans for arm builds?

This action seems neat and I thought it would be nice to be able to get kubectl on my runners conveniently

Feature Request: Migrate from `set-output`

Feature request

When running this action, a warning is shown:

The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

They've already moved the deprecation of this feature forward, with seemingly no planned time currently in mind, but I think it's a good idea to at least make it known that they plan to deprecate it. It looks like the source of this issue might be this line in the run.ts file, but I'm no expert.

Bug: error: no openapi getter

What happened?

I am using setup-kubectl on a self-hosted Ubuntu server 22.04 AWS AMI based runner. When a kubectl command is issued as an example below it gives this error.

Run kubectl diff -k some/path/to/overlay
error: no openapi getter
Error: Process completed with exit code 2.

I am sure there is some underlying library dependency missing in newer versions of kubectl which I've not been able to track down out yet...

Version

  • I am using the latest version

Runner

self-hosted, ubuntu-server-22.04

Relevant log output

N/A

Error: Kubectl '1.25.11' for 'amd64' arch not found.

This issue just started happening for me Error: Kubectl '1.25.11' for 'amd64' arch not found.
I've also tried switch to latest

        uses: azure/setup-kubectl@v3
        with:
           version: latest

and hit same
Error: Error: Kubectl 'v1.28.3' for 'amd64' arch not found.

DEBUG

##[debug]isExplicit: 1.25.11
##[debug]explicit? true
##[debug]checking cache: /opt/hostedtoolcache/kubectl/1.25.11/x64
##[debug]not found
##[debug]Downloading https://dl.k8s.io/release/1.25.11/bin/linux/amd64/kubectl
##[debug]Destination /home/runner/work/_temp/7938a0d6-c4fb-458d-9160-f828d656f77e
##[debug]Failed to download from "https://dl.k8s.io/release/1.25.11/bin/linux/amd64/kubectl". Code(404) Message(Not Found)
Error: Error: Kubectl '1.25.11' for 'amd64' arch not found.

kubelogin is not installed which is required to connect to AAD enabled cluster.

I'm using

      - name: Install kubectl
        uses: azure/setup-kubectl@v3

When I run a script with kubectl get nodes I get

E0913 16:38:36.754158    2214 memcache.go:265] couldn't get current server API group list: Get "[.....)": getting credentials: exec: executable kubelogin not found

It looks like you are trying to use a client-go credential plugin that is not installed.

To learn more about this feature, consult the documentation available at:
      https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins


kubelogin is not installed which is required to connect to AAD enabled cluster.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.