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

Build MultiCloud Devops using Azure CI/CD Pipelines with Oracle Database Cloud Services workshop #3

Merged
merged 13 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions azure-pipelines-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ stages:
- script: |
yq eval '.spec.template.spec.containers[0].env += [{"name": "AZURE_LOG_LEVEL", "value": "verbose"}, {"name": "AZURE_CLIENT_ID", "value": "$(AZURE_CLIENT_ID)"}, {"name": "AZURE_CLIENT_SECRET", "value": "$(AZURE_CLIENT_SECRET)"}, {"name": "AZURE_TENANT_ID", "value": "$(AZURE_TENANT_ID)"}]' -i $(Pipeline.Workspace)/manifests/deployment.yml
displayName: 'Add Environment Variable with yq'

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
Expand All @@ -101,3 +102,12 @@ stages:
containers: |
$(containerRegistry)/$(imageRepository):$(tag)

- task: Kubernetes@1
displayName: Deploy ServiceMonitor
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
namespace: default
command: apply
useConfigurationFile: true
configuration: $(Pipeline.Workspace)/manifests/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,71 +1,9 @@
# 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:
- main

resources:
- repo: self

variables:

# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'ba554595-2da8-4cf6-88c4-a57c75966491'
imageRepository: 'multicloudapp'
containerRegistry: 'multicloud.azurecr.io'
dockerfilePath: '**/Dockerfile'
tag: '$(Build.BuildId)'
imagePullSecret: 'multicloud2012b828-auth'

# Agent VM image name
vmImageName: 'ubuntu-latest'

# 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: JavaToolInstaller@0
inputs:
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
javaHomeOption: 'JDKVersion'
mavenVersionOption: '1.17'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
- 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
- script: |
#As part of build...
- script: |
echo Downloading Liquibase and Oracle JDBC driver
wget https://github.com/liquibase/liquibase/releases/download/v4.4.3/liquibase-4.4.3.tar.gz
tar -xzf liquibase-4.4.3.tar.gz
wget https://path/to/ojdbc8.jar
wget https://download.oracle.com/otn-pub/otn_software/jdbc/233/ojdbc8.jar
displayName: 'Install Liquibase and Oracle JDBC'


Expand Down Expand Up @@ -124,3 +62,12 @@ stages:
DB_USERNAME: $(DB_USERNAME)
DB_PASSWORD: $(DB_PASSWORD)

- task: Kubernetes@1
displayName: Deploy ServiceMonitor
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection
namespace: default
command: apply
useConfigurationFile: true
configuration: $(Pipeline.Workspace)/manifests/servicemonitor.yaml
12 changes: 12 additions & 0 deletions azure-pipelines-observability-snippet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@



- task: Kubernetes@1
displayName: Deploy ServiceMonitor
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
namespace: default
command: apply
useConfigurationFile: true
configuration: $(Pipeline.Workspace)/manifests/servicemonitor.yaml
19 changes: 18 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ stages:

- upload: manifests
artifact: manifests

- script: |
echo Downloading Liquibase and Oracle JDBC driver
wget https://github.com/liquibase/liquibase/releases/download/v4.4.3/liquibase-4.4.3.tar.gz
tar -xzf liquibase-4.4.3.tar.gz
wget https://download.oracle.com/otn-pub/otn_software/jdbc/233/ojdbc8.jar
wget https://download.oracle.com/otn_software/java/sqldeveloper/sqlcl-latest.zip
sudo apt-get install unzip
unzip sqlcl-latest.zip
displayName: 'Install Liquibase and Oracle JDBC'


- stage: Deploy
Expand Down Expand Up @@ -102,3 +110,12 @@ stages:
containers: |
$(containerRegistry)/$(imageRepository):$(tag)

- task: Kubernetes@1
displayName: Deploy ServiceMonitor
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
namespace: default
command: apply
useConfigurationFile: true
configuration: $(Pipeline.Workspace)/manifests/servicemonitor.yaml
2 changes: 0 additions & 2 deletions db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="1" author="your_name">
<createTable tableName="cicd_test_table">
<column name="testvalue" type="VARCHAR2(64)"/>
</createTable>
</changeSet>

</databaseChangeLog>
17 changes: 11 additions & 6 deletions manifests/service.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: multicloudapp
name: multicloudapp
labels:
app: multicloudapp
release: stable
spec:
type: LoadBalancer
ports:
- port: 8080
selector:
app: multicloudapp
type: LoadBalancer
ports:
- port: 8080
name: http
targetPort: 8080
selector:
app: multicloudapp
17 changes: 17 additions & 0 deletions manifests/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Copyright (c) 2024 Oracle and/or its affiliates.
## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: multicloudapp-monitor
labels:
app: multicloudapp
release: prometheus
spec:
selector:
matchLabels:
app: multicloudapp
endpoints:
- interval: 20s
port: http
path: /actuator/prometheus
Loading