Giter VIP home page Giter VIP logo

dokube's Introduction

DigitalOcean Kubernetes GitHub Action

Fetches the config for your DigitalOcean Kubernetes Cluster, then installs and configures kubectl, exposing it to path for future use!

Disclaimer: As of late, I haven't been using much Kubernetes in my daily projects. I've been focusing more on developing with serverless functions. Because of this, I haven't been making use of this GitHub Action either, so I haven't been able to find any bugs or feature ideas. Consider this project relatively unmaintained. That is to say, if you do make use of it and would like to submit and Issue outlining a problem you're facing, or a feature you want to implement, I will definitely be around to address those. Thank you.

For help updating, view the change logs.

Runs on

Type Systems Note
GitHub Runners ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, windows-2019, windows-2022 All available GitHub hosted runners.
Self-Hosted Runners linux-amd64, linux-arm64, linux-s390x, macOS-x64, windows-x64 Not tested, but in theory should work as long as kubectl is available for your system.

Inputs

Name Requirement Description
personalAccessToken Required A DigitalOcean Personal Access Token to use for authentication, when fetching cluster credentials from DigitalOcean. Must be tied to the same account as the Kubernetes Cluster you are trying to operate on. For instructions, see here.
clusterName Required The name of the cluster you are trying to operate on. This was chosen during the "Choose a name" step when originally creating the cluster.
version Optional The kubectl version to use. Remember to omit "v" prefix, for example: 1.16.0. Defaults to 1.16.0. See example below.
expirationTime Optional Amount of time, in seconds, that the generated DigitalOcean Token has to live. Typically should be slightly longer than the amount of time your job will run. Defaults to 600. See example below.
namespace Optional The Kubernetes namespace to operate under. Defaults to default.

Example usage

Simple, minimal usage

# Set up the Kubernetes CLI with your DigitalOcean Kubernetes cluster.
- name: Set up kubectl
  uses: matootie/[email protected]
  with:
    personalAccessToken: ${{ secrets.DIGITALOCEAN_TOKEN }}
    clusterName: my-fabulous-cluster

# Run any kubectl commands you want!
- name: Get nodes
  run: kubectl get nodes

This will setup kubectl configured with your DigitalOcean Kubernetes cluster. After that you're free to use kubectl as you wish!

Specifying a specific kubectl version

# Set up the Kubernetes CLI with your DigitalOcean Kubernetes cluster.
- name: Set up kubectl
  uses: matootie/[email protected]
  with:
    personalAccessToken: ${{ secrets.DIGITALOCEAN_TOKEN }}
    clusterName: my-fabulous-cluster
    version: "1.20.15"

# Run any kubectl commands you want!
- name: Get nodes
  run: kubectl get nodes

If you would like to install a specific version of kubectl, you can specify it with the version input.

Specifying a custom expiration time

# Set up the Kubernetes CLI with your DigitalOcean Kubernetes cluster.
- name: Set up kubectl
  uses: matootie/[email protected]
  with:
    personalAccessToken: ${{ secrets.DIGITALOCEAN_TOKEN }}
    clusterName: my-fabulous-cluster
    expirationTime: "1200"

# Run any kubectl commands you want!
- name: Get nodes
  run: kubectl get nodes

The generated Kubernetes config is set to only last a short amount of time, as it is only expected to be used for the duration of the job. If you would like to specify a shorter or larger time, better tailored to the average length of your job, you can do so with the expirationTime input.

dokube's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar matootie avatar twin avatar vassopoli 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

Watchers

 avatar  avatar

dokube's Issues

cross-device link not permitted

##[error]EXDEV: cross-device link not permitted, rename '/home/runner/work/_temp/93e0c884-618d-442c-9938-ffe3f288519e' -> '/home/runner/dokubetemp/kubectl'

kubectl: command not found

I'm having difficulties to make it work, I'm not sure if it's a bug / issue with my workflow config

# This is a basic workflow to help you get started with Actions

name: K8S Deployment

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ alpha ]

env:
  repository: registry.digitalocean.com/hyperair/nuxt-website

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  deploy:
    # The type of runner that the job will run on
    runs-on: [self-hosted, linux]

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2

    - name: Build and push to DO
      uses: docker/[email protected]
      with:
        username: ${{ secrets.DO_API_TOKEN }}
        password: ${{ secrets.DO_API_TOKEN }}
        registry: registry.digitalocean.com
        repository: hyperair/nuxt-website
        tags: ${{ github.sha }}

    - name: Set up kubectl
      uses: matootie/[email protected]
      with:
        personalAccessToken: ${{ secrets.DO_API_TOKEN }}
        clusterName: hyperair

    - name: Deploy
      run: kubectl set image -n alpha --record deployment/website app=${{ env.repository }}:${{ github.sha }}
2020-06-08T05:44:38.3663099Z ##[group]Run matootie/[email protected]
2020-06-08T05:44:38.3663231Z with:
2020-06-08T05:44:38.3663807Z   personalAccessToken: ***
2020-06-08T05:44:38.3663894Z   clusterName: hyperair
2020-06-08T05:44:38.3663990Z   expirationTime: 600
2020-06-08T05:44:38.3664088Z   namespace: default
2020-06-08T05:44:38.3664220Z   version: 1.16.0
2020-06-08T05:44:38.3664315Z env:
2020-06-08T05:44:38.3664403Z   repository: registry.digitalocean.com/hyperair/nuxt-website
2020-06-08T05:44:38.3664511Z ##[endgroup]
2020-06-08T05:44:42.4968710Z ##[group]Run kubectl set image -n alpha --record deployment/website app=registry.digitalocean.com/hyperair/nuxt-website:6140374e69c2c82288cdcac96227e5f0ad1f35b0
2020-06-08T05:44:42.4969311Z �[36;1mkubectl set image -n alpha --record deployment/website app=registry.digitalocean.com/hyperair/nuxt-website:6140374e69c2c82288cdcac96227e5f0ad1f35b0�[0m
2020-06-08T05:44:42.5046785Z shell: /usr/bin/bash -e {0}
2020-06-08T05:44:42.5046902Z env:
2020-06-08T05:44:42.5047015Z   repository: registry.digitalocean.com/hyperair/nuxt-website
2020-06-08T05:44:42.5047136Z   KUBECONFIG: /root/dokubetemp/kubeconfig
2020-06-08T05:44:42.5047237Z ##[endgroup]
2020-06-08T05:44:42.5169361Z /tmp/github-runner-hyperairhk/_temp/7c6bd1e9-f4af-4eeb-bd14-e1a95d6dc530.sh: line 1: kubectl: command not found
2020-06-08T05:44:42.5175390Z ##[error]Process completed with exit code 127.

Set custom namespace in context

Currently, when dokube generates the kubeconfig file, it leaves the namespace at "default".

Simply provide an optional GitHub Actions input for the namespace. If it was provided, use it for the context. If not, use "default"

Example

action.yml

# ...
inputs:
  # ...
  namespace:
    description: 'The namespace to operate on.'
    required: false
    default: 'default'
# ...

index.js

// ...
const namespaceName = core.getInput("namespace", { required: true });

contexts: [
  {
    context: {
      // ...
      namespace: namespaceName,
      // ...
    },
    // ...
  }
]
// ...

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.