Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update workflow templates #356

Merged
merged 7 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/workflows/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Workflows struct {

const (
parentDirName = "workflows"
configFileName = "/draft.yaml"
configFileName = "draft.yaml"
emptyDefaultFlagValue = ""
)

Expand Down
2 changes: 2 additions & 0 deletions template/deployments/helm/charts/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if ne .Values.namespace "default" }}
kind: Namespace
apiVersion: v1
metadata:
Expand All @@ -8,4 +9,5 @@ metadata:
kubernetes.azure.com/generator: {{GENERATORLABEL}}
annotations:
openservicemesh.io/sidecar-injection: enabled
{{- end }}

Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
# - AZURE_SUBSCRIPTION_ID
#
# 2. Set the following environment variables (or replace the values below):
# - ACR_RESOURCE_GROUP (resource group of your ACR)
# - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR)
# - CONTAINER_NAME (name of the container image you would like to push up to your ACR)
# - RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_NAME (name of your AKS cluster)
# - IMAGE_PULL_SECRET_NAME (name of the ImagePullSecret that will be created to pull your ACR image)
#
# 3. Choose the appropriate render engine for the bake step https://github.com/Azure/k8s-bake. The config below assumes Helm.
# Set your helmChart, overrideFiles, overrides, and helm-version to suit your configuration.
# - DOCKER_FILE (path to your Dockerfile)
# - BUILD_CONTEXT_PATH (path to the context of your Dockerfile)
# - CHART_PATH (path to your helm chart)
# - CHART_OVERRIDE_PATH (path to your helm chart with override values)
# - CHART_OVERRIDES (override values for your helm chart)
# - NAMESPACE (namespace to deploy your application)
#
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
Expand Down Expand Up @@ -73,7 +74,7 @@ jobs:
# Builds and pushes an image up to your Azure Container Registry
OliverMKing marked this conversation as resolved.
Show resolved Hide resolved
- name: Build and push image to ACR
run: |
az acr build --image ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f ${{ env.DOCKER_FILE }} ${{ env.BUILD_CONTEXT_PATH }}
az acr build --image ${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f ${{ env.DOCKER_FILE }} ${{ env.BUILD_CONTEXT_PATH }}
deploy:
permissions:
actions: read
Expand Down Expand Up @@ -108,34 +109,19 @@ jobs:
admin: 'false'
use-kubelogin: 'true'

# Runs Helm to create manifest files
- name: Bake deployment
uses: azure/k8s-bake@v2
with:
renderEngine: "helm"
helmChart: ${{ env.CHART_PATH }}
overrideFiles: ${{ env.CHART_OVERRIDE_PATH }}
overrides: ${{ env.CHART_OVERRIDES }}
helm-version: "latest"
id: bake

# Checks if the AKS cluster is private
- name: Is private cluster
id: isPrivate
run: |
result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster")
echo "PRIVATE_CLUSTER=$result" >> "$GITHUB_OUTPUT"

# Deploys application based on manifest files from previous step
- name: Deploy application
uses: Azure/k8s-deploy@v4
with:
action: deploy
manifests: ${{ steps.bake.outputs.manifestsBundle }}
images: |
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }}
name: ${{ env.CLUSTER_NAME }}
private-cluster: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER }}
namespace: ${{ env.NAMESPACE }}
# Deploys application
- name: Deploy application on private cluster
if : steps.isPrivate.outputs.PRIVATE_CLUSTER == 'true'
run: az aks command invoke --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --command "helm upgrade --wait -i -f ${{ env.CHART_OVERRIDE_PATH }} --set ${{ env.CHART_OVERRIDES }} automated-deployment ${{ env.CHART_PATH }} --namespace ${{env.NAMESPACE}}" --file .
bosesuneha marked this conversation as resolved.
Show resolved Hide resolved

- name: Deploy application on public cluster
if : steps.isPrivate.outputs.PRIVATE_CLUSTER == 'false'
run: helm upgrade --wait -i -f ${{ env.CHART_OVERRIDE_PATH }} --set ${{ env.CHART_OVERRIDES }} automated-deployment ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }}
bosesuneha marked this conversation as resolved.
Show resolved Hide resolved
`}}
2 changes: 1 addition & 1 deletion template/workflows/helm/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ variables:
- name: "CHARTOVERRIDES"
default:
disablePrompt: true
value: "replicas:2"
value: "replicas=2,image.tag=${{ github.sha }}"
bosesuneha marked this conversation as resolved.
Show resolved Hide resolved
description: "the Helm chart overrides"
- name: "NAMESPACE"
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
# - AZURE_SUBSCRIPTION_ID
#
# 2. Set the following environment variables (or replace the values below):
# - ACR_RESOURCE_GROUP (resource group of your ACR)
# - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR)
# - CONTAINER_NAME (name of the container image you would like to push up to your ACR)
# - RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_NAME (name of your AKS cluster)
# - IMAGE_PULL_SECRET_NAME (name of the ImagePullSecret that will be created to pull your ACR image)
# - DOCKER_FILE (path to your Dockerfile)
# - BUILD_CONTEXT_PATH (path to the context of your Dockerfile)
# - NAMESPACE (namespace to deploy your application)
#
# 3. Choose the appropriate render engine for the bake step https://github.com/Azure/k8s-bake. The config below assumes Kustomize.
# Set your kustomizationPath and kubectl-version to suit your configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
# - AZURE_SUBSCRIPTION_ID
#
# 2. Set the following environment variables (or replace the values below):
# - ACR_RESOURCE_GROUP (resource group of your ACR)
# - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR)
# - RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_NAME (name of your AKS cluster)
# - CONTAINER_NAME (name of the container image you would like to push up to your ACR)
# - IMAGE_PULL_SECRET_NAME (name of the ImagePullSecret that will be created to pull your ACR image)
# - DEPLOYMENT_MANIFEST_PATH (path to the manifest yaml for your deployment)
# - DOCKER_FILE (path to your Dockerfile)
# - BUILD_CONTEXT_PATH (path to the context of your Dockerfile)
# - NAMESPACE (namespace to deploy your application)
#
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
Expand Down
Loading