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

all changes #2

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c202cb7
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
3562267
Update 01-docker-build-and-push-to-acr-pipeline-01.yml for Azure Pipe…
shyam1986 Aug 11, 2021
cd097e5
Update 01-docker-build-and-push-to-acr-pipeline-01.yml for Azure Pipe…
shyam1986 Aug 11, 2021
dcda9f6
Update 01-docker-build-and-push-to-acr-pipeline-01.yml for Azure Pipe…
shyam1986 Aug 11, 2021
8f0ffa7
Update 01-docker-build-and-push-to-acr-pipeline-01.yml for Azure Pipe…
shyam1986 Aug 11, 2021
7776562
Update 01-docker-build-and-push-to-acr-pipeline-01.yml for Azure Pipe…
shyam1986 Aug 11, 2021
7cacd84
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
7abde29
Delete 01-docker-build-and-push-to-acr-pipeline-01.yml
shyam1986 Aug 11, 2021
91a25f5
Delete 01-docker-build-and-push-to-acr-pipeline.yml
shyam1986 Aug 11, 2021
0e1ab1b
Delete 02-docker-build-push-to-acs-deploy-to-aks-pipeline.yml
shyam1986 Aug 11, 2021
d691a0b
Delete 022-Docker-BuildPushToACR-DeployToAKSCluster.yml
shyam1986 Aug 11, 2021
898b71c
Delete 03-custom1-pipeline-buildandpush-to-acr-and-publish-artifacts.yml
shyam1986 Aug 11, 2021
cca5b32
Delete 04-custom2-pipeline-build-from-scratch.yml
shyam1986 Aug 11, 2021
936955d
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
5d657c6
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
f591c7c
Delete deployment.yml
shyam1986 Aug 11, 2021
0f7db58
Delete service.yml
shyam1986 Aug 11, 2021
9f30ff5
Delete azure-pipelines-aks.yml
shyam1986 Aug 11, 2021
6c5946e
Update azure-pipelines-aks.yml for Azure Pipelines
shyam1986 Aug 11, 2021
0934cb0
Delete azure-pipelines-aks.yml
shyam1986 Aug 11, 2021
cd0ccd4
Delete 02-docker-build-push-to-acs-deploy-to-aks-pipeline.yml
shyam1986 Aug 11, 2021
c26dbad
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
4fbaf22
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
fc2c8c2
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
65b4700
Update azure-pipelines.yml for Azure Pipelines
shyam1986 Aug 11, 2021
2812f76
Update azure-pipelines.yml for Azure Pipelines
shyam1986 Aug 11, 2021
db8bd9b
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
5fb2c93
Update 03-custom1-BuildPushToACR-Publish-k8s-manifests-to-AzurePipeli…
shyam1986 Aug 11, 2021
e203bdf
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
f44df35
Update 01-Deployment-and-LoadBalancer-Service.yml
shyam1986 Aug 11, 2021
a04afe5
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
93377fd
Update azure-pipelines-5testing.yml for Azure Pipelines
shyam1986 Aug 11, 2021
c08b85f
Update azure-pipelines-5testing.yml for Azure Pipelines
shyam1986 Aug 11, 2021
7719d7b
Update 01-Deployment-and-LoadBalancer-Service.yml
shyam1986 Aug 11, 2021
2a72290
Set up CI with Azure Pipelines
shyam1986 Aug 11, 2021
e9e576b
html changes
Aug 12, 2021
a6998cd
df
Aug 12, 2021
3ed2d93
ok
Aug 12, 2021
6dc9d5c
go
Aug 12, 2021
2124dd0
final-test
Aug 12, 2021
1488882
testing
Aug 12, 2021
0a6f625
pipeline-rename-testing
Aug 12, 2021
dce748c
new change
Aug 12, 2021
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
Prev Previous commit
Next Next commit
Set up CI with Azure Pipelines
[skip ci]
  • Loading branch information
shyam1986 committed Aug 11, 2021
commit 7cacd84af8aa9d513483e15c179285af32881e4c
142 changes: 142 additions & 0 deletions 022-Docker-BuildPushToACR-DeployToAKSCluster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Deploy to Azure Kubernetes Service
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master

resources:
- repo: self

variables:

# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: '19dbd652-a020-41ce-9b5e-c8f514f48fd4'
imageRepository: 'sapp1ngnixaks'
containerRegistry: 'cgaksdevopsacr.azurecr.io'
dockerfilePath: '**/Dockerfile'
tag: '$(Build.BuildId)'
imagePullSecret: 'cgaksdevopsacr9883eefa-auth'

# Agent VM image name
vmImageName: 'Linuxtesting'

# Name of the new namespace being created to deploy the PR changes.
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)'

stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)

- upload: manifests
artifact: manifests

- stage: Deploy
displayName: Deploy stage
dependsOn: Build

jobs:
- deployment: Deploy
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
displayName: Deploy
pool:
vmImage: $(vmImageName)
environment: 'shyam1986azuredevopsgithubacraksapp1.default'
strategy:
runOnce:
deploy:
steps:
- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
action: createSecret
secretName: $(imagePullSecret)
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
manifests: |
$(Pipeline.Workspace)/manifests/deployment.yml
$(Pipeline.Workspace)/manifests/service.yml
imagePullSecrets: |
$(imagePullSecret)
containers: |
$(containerRegistry)/$(imageRepository):$(tag)

- deployment: DeployPullRequest
displayName: Deploy Pull request
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/pull/'))
pool:
name: $(vmImageName)

environment: 'shyam1986azuredevopsgithubacraksapp1.$(k8sNamespaceForPR)'
strategy:
runOnce:
deploy:
steps:
- reviewApp: default

- task: Kubernetes@1
displayName: 'Create a new namespace for the pull request'
inputs:
command: apply
useConfigurationFile: true
inline: '{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "$(k8sNamespaceForPR)" }}'

- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
action: createSecret
secretName: $(imagePullSecret)
namespace: $(k8sNamespaceForPR)
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)

- task: KubernetesManifest@0
displayName: Deploy to the new namespace in the Kubernetes cluster
inputs:
action: deploy
namespace: $(k8sNamespaceForPR)
manifests: |
$(Pipeline.Workspace)/manifests/deployment.yml
$(Pipeline.Workspace)/manifests/service.yml
imagePullSecrets: |
$(imagePullSecret)
containers: |
$(containerRegistry)/$(imageRepository):$(tag)

- task: Kubernetes@1
name: get
displayName: 'Get services in the new namespace'
continueOnError: true
inputs:
command: get
namespace: $(k8sNamespaceForPR)
arguments: svc
outputFormat: jsonpath='http://{.items[0].status.loadBalancer.ingress[0].ip}:{.items[0].spec.ports[0].port}'

# Getting the IP of the deployed service and writing it to a variable for posing comment
- script: |
url="$(get.KubectlOutput)"
message="Your review app has been deployed"
if [ ! -z "$url" -a "$url" != "http://:" ]
then
message="${message} and is available at $url.<br><br>[Learn More](https://aka.ms/testwithreviewapps) about how to test and provide feedback for the app."
fi
echo "##vso[task.setvariable variable=GITHUB_COMMENT]$message"