Родитель
aaffd4ae1a
Коммит
fb6cc9f1c1
|
@ -0,0 +1,99 @@
|
||||||
|
variables:
|
||||||
|
|
||||||
|
- group: captureorder-variables # Variable Group containing 'teamName', 'mongoHost', 'mongoUser' and the secret 'mongoPassword'
|
||||||
|
|
||||||
|
- name: dockerRegistryServiceConnection
|
||||||
|
value: 'containerRegistryConnection' # replace with container registry service connection name established during pipeline creation
|
||||||
|
|
||||||
|
- name: imageRepository
|
||||||
|
value: 'captureorder' # replace with your own image name to match the name in the deployment.yaml
|
||||||
|
|
||||||
|
- name: tag
|
||||||
|
value: '$(Build.BuildId)'
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- stage: Build
|
||||||
|
displayName: Build stage
|
||||||
|
jobs:
|
||||||
|
- job: Build
|
||||||
|
displayName: Build job
|
||||||
|
pool:
|
||||||
|
vmImage: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- task: Docker@2
|
||||||
|
displayName: Build and push an image to container registry
|
||||||
|
inputs:
|
||||||
|
command: buildAndPush
|
||||||
|
repository: $(imageRepository)
|
||||||
|
dockerfile: '**/Dockerfile'
|
||||||
|
containerRegistry: $(dockerRegistryServiceConnection)
|
||||||
|
tags: |
|
||||||
|
$(tag)
|
||||||
|
|
||||||
|
- task: PublishPipelineArtifact@0
|
||||||
|
inputs:
|
||||||
|
artifactName: 'manifests'
|
||||||
|
targetPath: 'manifests'
|
||||||
|
|
||||||
|
- stage: DeployDev
|
||||||
|
displayName: Deploy to dev stage
|
||||||
|
dependsOn: Build
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- name: k8sNamespace # Kubernetes Namespace to deploy to
|
||||||
|
value: 'dev'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- deployment: DeployDev
|
||||||
|
displayName: Deploy to dev job
|
||||||
|
pool:
|
||||||
|
vmImage: ubuntu-latest
|
||||||
|
|
||||||
|
environment: 'aksworkshop.dev' # name of the environment to target. This will pull in the Kubernetes service connection automatically
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
runOnce:
|
||||||
|
deploy:
|
||||||
|
steps:
|
||||||
|
- task: DownloadPipelineArtifact@1
|
||||||
|
inputs:
|
||||||
|
artifactName: 'manifests'
|
||||||
|
downloadPath: '$(System.ArtifactsDirectory)/manifests'
|
||||||
|
|
||||||
|
- task: KubernetesManifest@0
|
||||||
|
displayName: Create imagePullSecret from dockerRegistryServiceConnection
|
||||||
|
inputs:
|
||||||
|
action: createSecret
|
||||||
|
secretName: acr-auth
|
||||||
|
namespace: $(k8sNamespace)
|
||||||
|
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
|
||||||
|
|
||||||
|
- task: KubernetesManifest@0
|
||||||
|
displayName: Create secret for MongoDB
|
||||||
|
inputs:
|
||||||
|
action: createSecret
|
||||||
|
secretName: mongodb
|
||||||
|
secretType: generic
|
||||||
|
namespace: $(k8sNamespace)
|
||||||
|
secretArguments: --from-literal=mongoHost=$(mongoHost) --from-literal=mongoUser=$(mongoUser) --from-literal=mongoPassword=$(mongoPassword)
|
||||||
|
|
||||||
|
- task: KubernetesManifest@0
|
||||||
|
displayName: Deploy to Kubernetes cluster
|
||||||
|
inputs:
|
||||||
|
action: deploy
|
||||||
|
namespace: $(k8sNamespace)
|
||||||
|
manifests: $(System.ArtifactsDirectory)/manifests/*
|
||||||
|
imagePullSecrets: |
|
||||||
|
acr-auth
|
||||||
|
containers: |
|
||||||
|
$(imageRepository):$(tag)
|
||||||
|
|
||||||
|
- task: KubernetesManifest@0
|
||||||
|
displayName: Patch the deployment environment variables
|
||||||
|
inputs:
|
||||||
|
action: patch
|
||||||
|
resourceToPatch: name
|
||||||
|
name: $(imageRepository)
|
||||||
|
kind: Deployment
|
||||||
|
namespace: $(k8sNamespace)
|
||||||
|
patch: '{"spec": {"template": {"spec":{"containers":[{"name":"$(imageRepository)","env":[{"name":"TEAMNAME","value":"$(teamName)"}]}]}}}}' # replacing TEAMNAME with the value specified in the variables
|
|
@ -0,0 +1,3 @@
|
||||||
|
# What is the directory
|
||||||
|
|
||||||
|
Add your Kubernetes manifest files (YAML) here and setup the pipeline to pick up the files for deployment to your Kubernetes cluster using the [KubernetesManifest](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/kubernetes-manifest) task of Azure DevOps Pipelines.
|
|
@ -0,0 +1,53 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: captureorder
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: captureorder
|
||||||
|
replicas: 2
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: captureorder
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: captureorder
|
||||||
|
image: sabbour.azurecr.io/captureorder # replace with your own repository
|
||||||
|
imagePullPolicy: Always
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
port: 8080
|
||||||
|
path: /healthz
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
port: 8080
|
||||||
|
path: /healthz
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "64Mi"
|
||||||
|
cpu: "100m"
|
||||||
|
limits:
|
||||||
|
memory: "128Mi"
|
||||||
|
cpu: "500m"
|
||||||
|
env:
|
||||||
|
- name: TEAMNAME
|
||||||
|
value: 'placeholder' # will be patched at deployment time by value of 'teamName' in the variable group
|
||||||
|
- name: MONGOHOST
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: mongodb
|
||||||
|
key: mongoHost
|
||||||
|
- name: MONGOUSER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: mongodb
|
||||||
|
key: mongoUser
|
||||||
|
- name: MONGOPASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: mongodb
|
||||||
|
key: mongoPassword
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
|
@ -0,0 +1,12 @@
|
||||||
|
apiVersion: autoscaling/v1
|
||||||
|
kind: HorizontalPodAutoscaler
|
||||||
|
metadata:
|
||||||
|
name: captureorder
|
||||||
|
spec:
|
||||||
|
scaleTargetRef:
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
name: captureorder
|
||||||
|
minReplicas: 2
|
||||||
|
maxReplicas: 4
|
||||||
|
targetCPUUtilizationPercentage: 50
|
|
@ -0,0 +1,12 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: captureorder
|
||||||
|
spec:
|
||||||
|
type: LoadBalancer
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 80
|
||||||
|
targetPort: 8080
|
||||||
|
selector:
|
||||||
|
app: captureorder
|
Загрузка…
Ссылка в новой задаче