From 829376afd94780bfa29dd7a5a6317fe2a78da9a3 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Mon, 21 Oct 2019 06:50:56 +0000 Subject: [PATCH] Update staging file with 507549c commit --- Jenkinsfile | 28 ++++++++++---------- infra/ansible/staging/main.yaml | 14 ++++++++++ infra/kube/Jenkinsfile | 23 ++++++++++++++++ infra/kube/workloads/production/service.yaml | 14 ++++++++++ infra/kube/workloads/staging/deployment.yaml | 4 +-- infra/kube/workloads/staging/service.yaml | 4 +-- 6 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 infra/ansible/staging/main.yaml create mode 100644 infra/kube/Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile index 4687b7bce..489747271 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,20 +20,20 @@ pipeline { } -// stage('image build') { -// environment { -// sha = sh(script: 'git rev-parse --short HEAD', returnStdout: true) -// } -// -// steps { -// acrQuickTask azureCredentialsId: "jenkins-sp", -// registryName: "jenkinsdemosacr", -// resourceGroupName: "demo-aks", -// local: "", -// dockerfile: "Dockerfile", -// imageNames: [[image: "jenkinsdemosacr.azurecr.io/pet-clinic:master-${sha}"]] -// } -// } + stage('image build') { + environment { + sha = sh(script: 'git rev-parse --short HEAD', returnStdout: true) + } + + steps { + acrQuickTask azureCredentialsId: "jenkins-sp", + registryName: "jenkinsdemosacr", + resourceGroupName: "demo-aks", + local: "", + dockerfile: "Dockerfile", + imageNames: [[image: "jenkinsdemosacr.azurecr.io/pet-clinic:master-${sha}"]] + } + } stage('update staging config') { environment { diff --git a/infra/ansible/staging/main.yaml b/infra/ansible/staging/main.yaml new file mode 100644 index 000000000..32d0d1213 --- /dev/null +++ b/infra/ansible/staging/main.yaml @@ -0,0 +1,14 @@ +- name: deploy staging environment + hosts: localhost + connection: local + vars: + resource_group: azure-k8stest + tasks: + - name: apply deployment + k8s: + state: present + src: ../../kube/workloads/staging/deployment.yaml + - name: apply service + k8s: + state: present + src: ../../kube/workloads/staging/service.yaml diff --git a/infra/kube/Jenkinsfile b/infra/kube/Jenkinsfile new file mode 100644 index 000000000..74d4755ec --- /dev/null +++ b/infra/kube/Jenkinsfile @@ -0,0 +1,23 @@ +pipeline { + agent any + + stages { + + stage('deploy') { + environment { + sha = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + } + + steps { + withCredentials([azureServicePrincipal(credentialsId: 'jenkins-sp', + subscriptionIdVariable: 'AZURE_SUBSCRIPTION_ID', + clientIdVariable: 'AZURE_CLIENT_ID', + clientSecretVariable: 'AZURE_SECRET', + tenantIdVariable: 'AZURE_TENANT')]) { + ansiblePlaybook installation: 'ansible', + playbook: 'infra/ansible/staging/main.yaml' + } + } + } + } +} diff --git a/infra/kube/workloads/production/service.yaml b/infra/kube/workloads/production/service.yaml index e69de29bb..2a492ebff 100644 --- a/infra/kube/workloads/production/service.yaml +++ b/infra/kube/workloads/production/service.yaml @@ -0,0 +1,14 @@ +kind: Service +apiVersion: v1 +metadata: + name: pet-clinic + namespace: production + labels: + version: master-507549c +spec: + selector: + app: auth-service + version: master-507549c + ports: + - port: 80 + targetPort: 8080 diff --git a/infra/kube/workloads/staging/deployment.yaml b/infra/kube/workloads/staging/deployment.yaml index 8c13c547b..a6f0063d1 100644 --- a/infra/kube/workloads/staging/deployment.yaml +++ b/infra/kube/workloads/staging/deployment.yaml @@ -12,12 +12,12 @@ spec: metadata: labels: app: pet-clinic - version: master-xxxxxxx + version: master-507549c spec: containers: - name: pet-clinic - image: "jenkinsdemosacr.azurecr.io/pet-clinic:master-xxxxxxx" + image: "jenkinsdemosacr.azurecr.io/pet-clinic:master-507549c" ports: - containerPort: 8080 imagePullSecrets: diff --git a/infra/kube/workloads/staging/service.yaml b/infra/kube/workloads/staging/service.yaml index e9562c685..06906ab4a 100644 --- a/infra/kube/workloads/staging/service.yaml +++ b/infra/kube/workloads/staging/service.yaml @@ -4,11 +4,11 @@ metadata: name: pet-clinic namespace: staging labels: - version: master-xxxxxxx + version: master-507549c spec: selector: app: auth-service - version: master-xxxxxxx + version: master-507549c ports: - port: 80 targetPort: 8080