Added the creation of the namespace if it does not already exist

This commit is contained in:
Bahram Rushenas 2022-09-26 19:08:17 -07:00
Родитель 208636e194
Коммит c4d98283b0
4 изменённых файлов: 10 добавлений и 23 удалений

6
.github/workflows/App-Flask-DockerBuild.yml поставляемый
Просмотреть файл

@ -134,6 +134,12 @@ jobs:
sudo mv bin/linux_amd64/kubelogin /usr/bin
kubelogin convert-kubeconfig -l azurecli
- name: Create the namespace if it does not exist
if: ${{ inputs.NAMESPACE }} != 'default'
run: |
cmdOut=$(kubectl get namespaces ${{ inputs.NAMESPACE }} -o json | jq -r '.status.phase')
if [ "$cmdOut" != 'Active' ]; then kubectl create namespace ${{ inputs.NAMESPACE }}; fi
- name: Deploy app to AKS
uses: azure/k8s-deploy@v1.5
env:

23
.github/workflows/App-Flask-GitOps.yml поставляемый
Просмотреть файл

@ -8,21 +8,13 @@
## -------------------------------------------------------------------------------------------------------------------------
# This workflow demonstrates building and pushing a container image to an Azure Container Registry.
# The workflow then updates the necessary Kubernetes manifest deployment file so a GitOps operator can sync from the manifest file deploying the application to an Azure Kubernetes Service cluster.
# The workflow then updates the necessary Kubernetes manifest deployment files in the GitHub repo so that a GitOps operator can sync them to deploy an application to an Azure Kubernetes Service cluster.
# It is split into separate jobs for readability but could be squashed into a single job if that best suits your scenario.
name: App Deploy Flask - GitOps
on:
workflow_dispatch:
inputs:
RG:
description: 'The Resource Group where your resources are deployed'
required: true
type: string
AKSNAME:
description: 'The Name of the AKS resource'
required: true
type: string
ACRNAME:
description: 'The Name of the ACR resource'
required: true
@ -32,11 +24,6 @@ on:
default: "flask"
required: true
type: string
NAMESPACE:
description: 'The Kubernetes Namespace to deploy the Application to'
default: "default"
required: false
type: string
ENVIRONMENT:
description: 'A GitHub Environment to pull action secrets from'
required: true
@ -107,14 +94,6 @@ jobs:
# Checks out the baseline repository
- uses: actions/checkout@v2
# Logs into your Azure subscription
- uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Update image name in manifest file
uses: azure/powershell@v1
with:

Просмотреть файл

@ -5,7 +5,9 @@ This article outlines how to deploy your workload using the pull option as descr
1. Follow steps 1 to 5 in [Option #1 Push-based CI/CD](./app-flask-push-dockerbuild.md) to setup your GitHub environment.
2. Install Argo CD on your AKS cluster by following the steps in [Get Started with Argo CD](https://argo-cd.readthedocs.io/en/stable/getting_started/).
3. Run the [.github/workflows/App-Flask-GitOps.yml](../../.github/workflows/App-Flask-GitOps.yml) workflow by clicking on **Actions** and selecting the display name for this workflow, which is **App Deploy Flask - GitOps**. This workflow will build and push the container image to the Azure Container Registry (ACR), then it will update the application *deployment.yaml* file with the names of the pushed image.
3. Run the [.github/workflows/App-Flask-GitOps.yml](../../.github/workflows/App-Flask-GitOps.yml) workflow by clicking on **Actions** and selecting the display name for this workflow, which is **App Deploy Flask - GitOps**. This workflow will build and push the container image to the Azure Container Registry (ACR), then it will update the application *deployment.yaml* file with the names of the pushed image.
Enter the parameters requested by this workflow as shown below:
![](media/b4bf25dc9497c669d54a205648cb864c.png)
4. Create a new app for the App in Argo CD by following [these steps](https://argo-cd.readthedocs.io/en/stable/getting_started/#creating-apps-via-ui). Make sure you enter the following parameters:
- Application Name: flask

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 102 KiB

После

Ширина:  |  Высота:  |  Размер: 80 KiB