Skip to content

Commit

Permalink
[DEVOPS-284] Add support for deploying to default Kubernetes namespace (
Browse files Browse the repository at this point in the history
#71)

<details open>
<summary><a href="https://amuniversal.atlassian.net/browse/DEVOPS-284"
title="DEVOPS-284" target="_blank">DEVOPS-284</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td>Update AKS deploy workflow to account for new AKS clusters</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"
src="https://amuniversal.atlassian.net/images/icons/issuetypes/story.png"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Development Env</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
      <td>-</td>
    </tr>
  </table>
</details>
<!--
do not remove this marker as it will break action-jira-linter's
functionality.
  added_by_jira_lint
-->
---

<!-- Please make sure you read the contribution guidelines and then fill
out the blanks below.

Please format the PR title appropriately based on the type of change:
  [JIRA-XXX]: <description>
-->

## Description

- Add support for deploying to default Kubernetes namespace by adding
the `environmentNamespace` input.

## Related Links

<!-- List any links related to this pull request here

Replace "JIRA-XXX" with the your Jira issue key -->

- Jira Issue: DEVOPS-284
- Testing environment: [![Reusable Workflow
Test](https://github.com/Andrews-McMeel-Universal/reusable_workflows-test/actions/workflows/aks-development.yml/badge.svg?branch=story%2FDEVOPS-284%2Fadd-environment-cluster-ingress-input)](https://github.com/Andrews-McMeel-Universal/reusable_workflows-test/actions/workflows/aks-development.yml)
  • Loading branch information
ebronson68 authored Oct 24, 2023
1 parent ad93458 commit 1b2c5cc
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/aks-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ on:
type: string
description: "Add the environment name to the front of the hostname (for DNS)"
default: "true"
environmentNamespace:
required: false
type: boolean
description: "Enable/Disable adding environment in AKS cluster ingress DNS record"
default: true
secrets:
azureClusterName:
required: true
Expand Down Expand Up @@ -381,8 +386,15 @@ jobs:
cluster-name: ${{ secrets.azureClusterName }}
resource-group: ${{ inputs.clusterResourceGroup }}

- name: Switch to ${{ inputs.environment }} Namespace
run: kubectl config set-context --current --namespace="${{ inputs.environment }}"
- name: Switch Kubernetes Namespace
id: namespace
run: |
if [ "${{ inputs.environmentNamespace }}" == "true" ]; then
kubectl config set-context --current --namespace="${{ inputs.environment }}"
echo "namespace=${{ inputs.environment }}" >> $GITHUB_OUTPUT
else
echo "namespace=default" >> $GITHUB_OUTPUT
fi
- name: Apply configMap if it exists
if: ${{ needs.build.outputs.configMap != null }}
Expand Down Expand Up @@ -423,7 +435,7 @@ jobs:
timeout-minutes: ${{ inputs.deploymentTimeout }}
uses: Azure/k8s-deploy@v4
with:
namespace: ${{ inputs.environment }}
namespace: ${{ steps.namespace.outputs.namespace }}
manifests: ${{ needs.build.outputs.manifestsBundle }}
images: |
"${{ secrets.registryHostName }}/${{ inputs.dockerImageName }}:${{ inputs.dockerImageTag }}"
Expand All @@ -443,16 +455,25 @@ jobs:
creds: "${{ secrets.azureCredentials }}"

- name: Create or Update Public DNS Record
id: dns
run: |
az network dns record-set cname set-record --resource-group ${{ inputs.dnsResourceGroup }} --zone-name "${{ needs.build.outputs.domainName }}" --record-set-name ${{ needs.build.outputs.hostName }} --cname "${{ secrets.azureClusterName }}-${{ inputs.environment }}-ingress.centralus.cloudapp.azure.com." --ttl 3600
if [ "${{ inputs.environmentNamespace }}" == "true" ]; then
INGRESS="${{ secrets.azureClusterName }}-${{ inputs.environment }}"
else
INGRESS="${{ secrets.azureClusterName }}"
fi
AKS_INGRESS="${INGRESS}-ingress.centralus.cloudapp.azure.com."
az network dns record-set cname set-record --resource-group "${{ inputs.dnsResourceGroup }}" --zone-name "${{ needs.build.outputs.domainName }}" --record-set-name "${{ needs.build.outputs.hostName }}" --cname "${AKS_INGRESS}" --ttl 3600
echo "aksIngress=${AKS_INGRESS}" >> $GITHUB_OUTPUT
- name: Record deployment information in Azure Storage Table
uses: LadyCailin/azure-table-storage-upload@v1.0.1
with:
table_name: "${{ inputs.appInfoTableName }}"
partition_key: "${{ inputs.repositoryName }}"
row_key: "${{ inputs.environment }}"
data: "ApplicationName=${{ needs.build.outputs.appName }} Version=${{ needs.build.outputs.appVersion }} KeyVault=${{ inputs.environmentKeyVault }} HostName=${{ needs.build.outputs.hostName }} DomainName=${{ needs.build.outputs.domainName }} IngressFqdn=${{ needs.build.outputs.ingress }} HealthCheckPath=${{ needs.build.outputs.appHealthCheck }} AksIngress=${{ secrets.azureClusterName }}-${{ inputs.environment }}-ingress.centralus.cloudapp.azure.com. Cluster=${{ secrets.azureClusterName }} ClusterResourceGroup=${{ inputs.clusterResourceGroup }} ConfigSecret=${{needs.build.outputs.configSecret }} ConfigMap=${{ needs.build.outputs.configMap }} LastDeploy=${{ needs.build.outputs.date }}"
data: "ApplicationName=${{ needs.build.outputs.appName }} Version=${{ needs.build.outputs.appVersion }} KeyVault=${{ inputs.environmentKeyVault }} HostName=${{ needs.build.outputs.hostName }} DomainName=${{ needs.build.outputs.domainName }} IngressFqdn=${{ needs.build.outputs.ingress }} HealthCheckPath=${{ needs.build.outputs.appHealthCheck }} AksIngress=${{ steps.dns.outputs.aksIngress }} Cluster=${{ secrets.azureClusterName }} ClusterResourceGroup=${{ inputs.clusterResourceGroup }} ConfigSecret=${{needs.build.outputs.configSecret }} ConfigMap=${{ needs.build.outputs.configMap }} LastDeploy=${{ needs.build.outputs.date }}"
if_exists: "replace"
extra_args: ""
connection_string: "AccountName=${{ inputs.storageAccountName }};AccountKey=${{ secrets.storageAccountKey }}"
Expand Down

0 comments on commit 1b2c5cc

Please sign in to comment.