Code Monkey home page Code Monkey logo

actions-aks's Introduction

GitHub Actions with AKS

This sample creates a multi-container application in an Azure Kubernetes Service (AKS) cluster through GitHub Actions. The application interface has been built using Python / Flask. The data component is using Redis. This code is packaged into container images, uploaded to Azure Container Registry, and then run in an AKS cluster..

Getting Started

  1. Fork this repo.
  2. Create a free Azure Account with $200 credit (you can use your GitHub account): https://azure.microsoft.com/en-us/free/
  3. Go to the Azure Portal: https://ms.portal.azure.com/#home and open the Cloud Shell.
  4. Create a resource group
az group create --name <RESOURCEGROUPNAME> --location westeurope
  1. Create an Azure Container Registry (ACR)
az acr create --resource-group <RESOURCEGROUPNAME> --name <ACRNAME> --sku Basic
  1. Get username & password from ACR
az acr update -n <ACRNAME> --admin-enabled true
az acr credential show -n <ACRNAME>
  1. In GitHub, browse to your repository, select Settings > Secrets > Add a new secret and add the username and password from the last step in the following secret variables: REGISTRY_USERNAME REGISTRY_PASSWORD
  2. Create an AKS cluster (you have to wait a few minutes)
az aks create \
    --resource-group <RESOURCEGROUPNAME> \
    --name <AKSNAME> \
    --node-count 2 \
    --generate-ssh-keys \
    --attach-acr <ACRNAME>
  1. Create a Service Principal. You can create a service principal by using the az ad sp create-for-rbac command.
az ad sp create-for-rbac --name <APPNAME> --role contributor --scopes /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP> --sdk-auth

You can obtain the <SUBSCRIPTION_ID> by using > az account list

  1. Copy this JSON object, which you can use to authenticate from GitHub. Add it to the following secret variable: AZURE_CREDENTIALS
  2. GitHub Actions gives you the flexibility to build an automated software development lifecycle workflow. The Kubernetes action azure/aks-set-context@v1 facilitate deployments to Azure Kubernetes Service clusters. The action sets the target AKS cluster context, which could be used by other actions like azure/k8s-deploy, azure/k8s-create-secret etc. or run any kubectl commands. Check: https://github.com/Azure/actions-workflow-samples/tree/master/Kubernetes

In this example, the workflow is already created in .github/workflows/main.yml. Check this file and change the values for the REGISTRY_NAME, CLUSTER_NAME, CLUSTER_RESOURCE_GROUP and NAMESPACE environment variables.

actions-aks's People

Contributors

m3l3r0 avatar kleeadrian avatar

Watchers

James Cloos avatar

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.