Sean
Sean

Reputation: 396

Deploy to a Kubernetes cluster on Linode via Github Actions

I have a very specific use case leveraging github actions

  1. Build and push docker image to a private registry on linode
  2. Login to Linode K8s Environment and do a rollout restart on the affected deployments

Problem is, there are no ready yaml file actions on the Github market place for Linode integration- they have for other providers like AWS, Azure, GKE, etc using Dockerhub The internet in general does not have these use cases combined. I am a newbie to Github actions so it will take some time to hack this myself. Any help/pointers will be appreciated.

Upvotes: 2

Views: 847

Answers (1)

Sean
Sean

Reputation: 396

After some hacking, I was able to come up with this simple workflow that works for me. Credit to this post

name: deployment-deploy

on:
 push:
   branches:
    - somebranch
jobs:
 build:
  runs-on: ubuntu-latest
  steps:

    - uses: actions/checkout@v2
      #build and push image
    - name: Build, tag, and push image to Private registry
      id: build-image
      env:
        IMAGE_TAG: image_tag
      run: |
        docker build -t ${{secrets.REGISTRY_ENDPOINT}}:$IMAGE_TAG .
        docker login registry.domain.com -u ${{ secrets.REGISTRY_USERNAME }} -p ${{secrets.REGISTRY_PASSWORD}}
        docker push ${{secrets.REGISTRY_ENDPOINT}}:$IMAGE_TAG
        echo "::set-output name=image::${{secrets.REGISTRY_ENDPOINT}}:$IMAGE_TAG"

    - name: Kubernetes set context
      uses: Azure/k8s-set-context@v1
      with:
        method: kubeconfig
        kubeconfig: ${{ secrets.KUBE_CONFIG }}


    #push
    - name: Deploy k8s yaml
      id: deploy-k8s-yaml
      run: |
        # Verify deployment
        kubectl rollout restart deployment some_depl
     

Upvotes: 2

Related Questions