Skip to content

Commit 355e6eb

Browse files
committed
Welcome to Stack Simplify
1 parent af7d87f commit 355e6eb

File tree

1 file changed

+113
-94
lines changed

1 file changed

+113
-94
lines changed

25-Azure-DevOps-Terraform-Azure-AKS/README.md

Lines changed: 113 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -291,53 +291,58 @@ variables:
291291
value: dev
292292
- name: QA_ENVIRONMENT
293293
value: qa
294+
# Stage-2: Deploy Stages for Dev & QA
295+
# Deployment-1: Deploy Dev AKS Cluster
296+
## Step-1: Define Variables for environments
297+
## Step-2: Download SSH Secure File
298+
## Step-3: Terraform Initialize (State Storage to store in Azure Storage Account for Dev AKS Cluster)
299+
## Step-4: Terraform Plan (Create Plan)
300+
## Step-5: Terraform Apply (Use the plan created in previous step)
294301

295-
- stage: DeployAKS
302+
- stage: DeployAKSClusters
296303
jobs:
297-
- deployment: DeployDev
298-
pool:
299-
vmImage: 'ubuntu-latest'
300-
environment: $(DEV_ENVIRONMENT)
301-
strategy:
302-
# default deployment strategy
303-
runOnce:
304-
deploy:
305-
steps:
306-
- task: DownloadSecureFile@1
307-
displayName: Download SSH Key for Linux VMs
308-
name: sshkey
309-
inputs:
310-
secureFile: 'aks-terraform-devops-ssh-key-ububtu.pub'
311-
- task: TerraformCLI@0
312-
displayName: Terraform Init
313-
inputs:
314-
command: 'init'
315-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
316-
backendType: 'azurerm'
317-
backendServiceArm: 'terraform-aks-azurerm-for-pipe3'
318-
backendAzureRmResourceGroupName: 'terraform-state-storage-rg2'
319-
backendAzureRmStorageAccountName: 'tfstatekalyan123'
320-
backendAzureRmContainerName: 'tfstatefiles'
321-
backendAzureRmKey: 'aks-$(DEV_ENVIRONMENT).tfstate'
322-
allowTelemetryCollection: false
323-
324-
- task: TerraformCLI@0
325-
displayName: Terraform Plan
326-
inputs:
327-
command: 'plan'
328-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
329-
environmentServiceName: 'terraform-aks-azurerm-for-pipe3'
330-
commandOptions: '-var ssh_public_key=$(sshkey.secureFilePath) -var environment=$(DEV_ENVIRONMENT) -out $(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
331-
allowTelemetryCollection: false
332-
333-
- task: TerraformCLI@0
334-
displayName: Terraform Apply
335-
inputs:
336-
command: 'apply'
337-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
338-
environmentServiceName: 'terraform-aks-azurerm-for-pipe3'
339-
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
340-
allowTelemetryCollection: false
304+
- deployment: DeployDevAKSCluster
305+
displayName: DeployDevAKSCluster
306+
pool:
307+
vmImage: 'ubuntu-latest'
308+
environment: $(DEV_ENVIRONMENT)
309+
strategy:
310+
runOnce:
311+
deploy:
312+
steps:
313+
- task: DownloadSecureFile@1
314+
displayName: Download SSH Key
315+
name: sshkey
316+
inputs:
317+
secureFile: 'aks-terraform-devops-ssh-key-ububtu.pub'
318+
- task: TerraformCLI@0
319+
displayName: Terraform Init
320+
inputs:
321+
command: 'init'
322+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
323+
backendType: 'azurerm'
324+
backendServiceArm: 'terraform-aks-azurerm-svc-con'
325+
backendAzureRmResourceGroupName: 'terraform-storage-rg'
326+
backendAzureRmStorageAccountName: 'terraformstatexlrwdrzs'
327+
backendAzureRmContainerName: 'tfstatefiles'
328+
backendAzureRmKey: 'aks-$(DEV_ENVIRONMENT).tfstate'
329+
allowTelemetryCollection: false
330+
- task: TerraformCLI@0
331+
displayName: Terraform Plan
332+
inputs:
333+
command: 'plan'
334+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
335+
environmentServiceName: 'terraform-aks-azurerm-svc-con'
336+
commandOptions: '-var ssh_public_key=$(sshkey.secureFilePath) -var environment=$(DEV_ENVIRONMENT) -out $(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
337+
allowTelemetryCollection: false
338+
- task: TerraformCLI@0
339+
displayName: Terraform Apply
340+
inputs:
341+
command: 'apply'
342+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
343+
environmentServiceName: 'terraform-aks-azurerm-svc-con'
344+
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
345+
allowTelemetryCollection: false
341346
```
342347
343348
@@ -379,64 +384,60 @@ kubectl get nodes
379384
## Step-14: Deploy QA AKS Cluster
380385
### Stage-2: Deployment-1: Deploy Dev AKS Cluster
381386
```yaml
382-
383387
# Stage-2: Deploy Stages for Dev & QA
384388
# Deployment-2: Deploy QA AKS Cluster
385389
## Step-1: Download Secure File
386390
## Step-2: Terraform Initialize (State Storage to store in Azure Storage Account)
387391
## Step-3: Terraform Plan
388-
## Step-4: Terraform Apply
389-
390-
- deployment: DeployQA
391-
dependsOn: DeployDev
392-
pool:
393-
vmImage: 'ubuntu-latest'
394-
environment: $(QA_ENVIRONMENT)
395-
strategy:
396-
# default deployment strategy
397-
runOnce:
398-
deploy:
399-
steps:
400-
- task: DownloadSecureFile@1
401-
displayName: Download SSH Key for Linux VMs
402-
name: sshkey
403-
inputs:
404-
secureFile: 'aks-terraform-devops-ssh-key-ububtu.pub'
405-
- task: TerraformCLI@0
406-
displayName: Terraform Init
407-
inputs:
408-
command: 'init'
409-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
410-
backendType: 'azurerm'
411-
backendServiceArm: 'terraform-aks-azurerm-for-pipe3'
412-
backendAzureRmResourceGroupName: 'terraform-state-storage-rg2'
413-
backendAzureRmStorageAccountName: 'tfstatekalyan123'
414-
backendAzureRmContainerName: 'tfstatefiles'
415-
backendAzureRmKey: 'aks-$(QA_ENVIRONMENT).tfstate'
416-
allowTelemetryCollection: false
417-
418-
- task: TerraformCLI@0
419-
displayName: Terraform Plan
420-
inputs:
421-
command: 'plan'
422-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
423-
environmentServiceName: 'terraform-aks-azurerm-for-pipe3'
424-
commandOptions: '-var ssh_public_key=$(sshkey.secureFilePath) -var environment=$(QA_ENVIRONMENT) -out $(Pipeline.Workspace)/terraform-manifests-out/$(QA_ENVIRONMENT)-$(Build.BuildId).out'
425-
allowTelemetryCollection: false
426-
427-
- task: TerraformCLI@0
428-
displayName: Terraform Apply
429-
inputs:
430-
command: 'apply'
431-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
432-
environmentServiceName: 'terraform-aks-azurerm-for-pipe3'
433-
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(QA_ENVIRONMENT)-$(Build.BuildId).out'
434-
allowTelemetryCollection: false
392+
## Step-4: Terraform Apply
393+
394+
- deployment: DeployQAAKSCluster
395+
dependsOn: DeployDevAKSCluster
396+
displayName: DeployQAAKSCluster
397+
pool:
398+
vmImage: 'ubuntu-latest'
399+
environment: $(QA_ENVIRONMENT)
400+
strategy:
401+
runOnce:
402+
deploy:
403+
steps:
404+
- task: DownloadSecureFile@1
405+
displayName: Download SSH Key
406+
name: sshkey
407+
inputs:
408+
secureFile: 'aks-terraform-devops-ssh-key-ububtu.pub'
409+
- task: TerraformCLI@0
410+
displayName: Terraform Init
411+
inputs:
412+
command: 'init'
413+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
414+
backendType: 'azurerm'
415+
backendServiceArm: 'terraform-aks-azurerm-svc-con'
416+
backendAzureRmResourceGroupName: 'terraform-storage-rg'
417+
backendAzureRmStorageAccountName: 'terraformstatexlrwdrzs'
418+
backendAzureRmContainerName: 'tfstatefiles'
419+
backendAzureRmKey: 'aks-$(QA_ENVIRONMENT).tfstate'
420+
allowTelemetryCollection: false
421+
- task: TerraformCLI@0
422+
displayName: Terraform Plan
423+
inputs:
424+
command: 'plan'
425+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
426+
environmentServiceName: 'terraform-aks-azurerm-svc-con'
427+
commandOptions: '-var ssh_public_key=$(sshkey.secureFilePath) -var environment=$(QA_ENVIRONMENT) -out $(Pipeline.Workspace)/terraform-manifests-out/$(QA_ENVIRONMENT)-$(Build.BuildId).out'
428+
allowTelemetryCollection: false
429+
- task: TerraformCLI@0
430+
displayName: Terraform Apply
431+
inputs:
432+
command: 'apply'
433+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
434+
environmentServiceName: 'terraform-aks-azurerm-svc-con'
435+
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(QA_ENVIRONMENT)-$(Build.BuildId).out'
436+
allowTelemetryCollection: false
435437
436438
```
437439

438440

439-
440441
### Pipeline Save and Run
441442
- Click on **Save and Run**
442443
- Commit Message: Third Commit - QA AKS Cluster Provision via terraform
@@ -471,6 +472,24 @@ kubectl cluster-info
471472
kubectl get nodes
472473
```
473474

475+
## Step-16: Make Changes to Infrastructure and Push Code
476+
- Add this as node-label and tag to linux101 nodepool
477+
```
478+
# Add this tag and node-label
479+
"ui-apps" = "react-apps"
480+
```
481+
- Execute Git Commands
482+
```
483+
# First sync Remote repo with local repo
484+
git pull
485+
486+
# Commit
487+
git add .
488+
git commit -am "Added New Node-label to linux101 nodepool"
489+
git push
490+
```
491+
- Verify the pipeline
492+
474493
## References
475494
- [Publish & Download Artifacts in Azure DevOps Pipeline](https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/pipeline-artifacts?view=azure-devops&tabs=yaml)
476495
- [Azure Pipelines - Deployment Jobs](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/deployment-jobs?view=azure-devops)

0 commit comments

Comments
 (0)