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

[Deploy to K8s] Clean up #158

Merged
merged 6 commits into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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 templates/deploy-to-existing-k8s.properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"required": "true"
},
{
"name": "imageName",
"name": "imageRepository",
"type": "string",
"required": "true",
"displayName": "Image Name"
Expand Down
33 changes: 16 additions & 17 deletions templates/deploy-to-existing-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@ variables:

# Container registry service connection established during pipeline creation - Docker Hub/ACR/...
dockerRegistryServiceConnection: '{{ containerRegistryConnection.Id }}'
imageRepository: '$(build.repository.name)'
imageRepository: '{{ imageRepository }}'
containerRegistryName: '{{ containerRegistryName }}'

dockerfilePath: '**/Dockerfile'

# Kubernetes Environment
environmentName: '{{ environment.Environment.Name }}'
k8sResourceName: "{{ environment.Resources.kubernetesConnection.Name }}"
k8sResourceNamespace: "{{ environment.Resources.kubernetesConnection.Namespace }}"

# Docker Image Name
imageName: '{{ imageName }}'
tag: '$(Build.BuildId)'

# Kubernetes Namespace
k8sNamespace: '{{ environment.Resources.kubernetesConnection.Namespace }}'
imagePullSecret: '{{ containerRegistryName }}-auth'

stages:
- stage: Build
Expand All @@ -40,31 +35,35 @@ stages:
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)

- stage: Deploy
displayName: Deploy stage
dependsOn: Build
jobs:
- deployment: Deploy to Kubernetes
displayName: Deploy job
environment: $(environmentName).$(k8sResourceName)
environment: '{{ environment.Environment.Name }}.{{ environment.Resources.kubernetesConnection.Name }}'
strategy:
runOnce:
deploy:
steps:
- task: Kubernetes@2
displayName: 'kubectl create imagepullsecret docker-auth'
- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
containerRegistryType: 'Container Registry'
action: createSecret
secretName: $(imagePullSecret)
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
secretName: 'docker-auth'

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
namespace: $(k8sResourceNamespace)
namespace: $(k8sNamespace)
manifests: |
manifests/*
imagePullSecrets: |
$(imagePullSecret)
containers: |
$(containerRegistryName)/$(imageRepository)
$(containerRegistryName)/$(imageRepository):$(tag)