Last active
July 28, 2021 02:14
-
-
Save adrianbumbas/96347d8de2dc7ba875325bc92f53f6f1 to your computer and use it in GitHub Desktop.
Rollback Kubernetes deployments with Azure DevOps pipelines https://adrianbumbas.com/rollback-kubernetes-deployments-with-azure-devops-pipelines/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: Kubernetes@1 | |
name: 'apply' | |
inputs: | |
connectionType: 'Kubernetes Service Connection' | |
kubernetesServiceEndpoint: 'test' | |
namespace: 'default' | |
command: 'apply' | |
arguments: '-f deployment.yaml' | |
secretType: 'dockerRegistry' | |
containerRegistryType: 'Azure Container Registry' | |
outputFormat: "jsonpath={$.metadata.name}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
- master | |
jobs: | |
- job: Deploy_to_AKS | |
pool: | |
vmImage: 'ubuntu-latest' | |
steps: | |
- task: Kubernetes@1 | |
name: 'apply' | |
inputs: | |
connectionType: 'Kubernetes Service Connection' | |
kubernetesServiceEndpoint: 'test' | |
namespace: 'default' | |
command: 'apply' | |
arguments: '-f deployment.yaml' | |
secretType: 'dockerRegistry' | |
containerRegistryType: 'Azure Container Registry' | |
outputFormat: "jsonpath={$.metadata.name}" | |
- task: Kubernetes@1 | |
name: rollout_status | |
inputs: | |
connectionType: 'Kubernetes Service Connection' | |
kubernetesServiceEndpoint: 'test' | |
namespace: 'default' | |
command: rollout | |
arguments: status deployment/$(apply.KubectlOutput) | |
secretType: 'dockerRegistry' | |
containerRegistryType: 'Azure Container Registry' | |
- task: Kubernetes@1 | |
name: rollout_undo | |
condition: failed() | |
inputs: | |
connectionType: 'Kubernetes Service Connection' | |
kubernetesServiceEndpoint: 'test' | |
namespace: 'default' | |
command: rollout | |
arguments: undo deployment/$(apply.KubectlOutput) | |
secretType: 'dockerRegistry' | |
containerRegistryType: 'Azure Container Registry' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: hello-kubernetes | |
spec: | |
replicas: 3 | |
progressDeadlineSeconds: 120 | |
strategy: | |
type: RollingUpdate | |
rollingUpdate: | |
maxUnavailable: 0 | |
maxSurge: 1 | |
selector: | |
matchLabels: | |
app: hello-kubernetes | |
template: | |
metadata: | |
labels: | |
app: hello-kubernetes | |
spec: | |
containers: | |
- name: hello-kubernetes | |
image: gcr.io/google-samples/hello-app:1.0 | |
ports: | |
- containerPort: 8080 | |
readinessProbe: | |
httpGet: | |
path: / | |
port: 8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: hello-kubernetes | |
spec: | |
replicas: 3 | |
progressDeadlineSeconds: 120 | |
strategy: | |
type: RollingUpdate | |
rollingUpdate: | |
maxUnavailable: 0 | |
maxSurge: 1 | |
selector: | |
matchLabels: | |
app: hello-kubernetes | |
template: | |
metadata: | |
labels: | |
app: hello-kubernetes | |
spec: | |
containers: | |
- name: hello-kubernetes | |
# change here the image | |
image: ngnix:latest | |
ports: | |
- containerPort: 8080 | |
readinessProbe: | |
httpGet: | |
path: / | |
port: 8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: Kubernetes@1 | |
name: rollout_status | |
inputs: | |
connectionType: 'Kubernetes Service Connection' | |
kubernetesServiceEndpoint: 'test' | |
namespace: 'default' | |
command: rollout | |
arguments: status deployment/$(apply.KubectlOutput) | |
secretType: 'dockerRegistry' | |
containerRegistryType: 'Azure Container Registry' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: Kubernetes@1 | |
name: rollout_undo | |
# conditional execution | |
condition: failed() | |
inputs: | |
connectionType: 'Kubernetes Service Connection' | |
kubernetesServiceEndpoint: 'test' | |
namespace: 'default' | |
command: rollout | |
arguments: undo deployment/$(apply.KubectlOutput) | |
secretType: 'dockerRegistry' | |
containerRegistryType: 'Azure Container Registry' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment