Building my own Azure DevOps Ecosystem
DevOps ecosystem with container CI/CD using Jenkins and Kubernetes on Azure Kubernetes Service (AKS)
Containers make it easy for you to continuously build and deploy applications. By orchestrating the deployment of those containers using Azure Kubernetes Service (AKS), you can achieve replicable, manageable clusters of containers.
By setting up a continuous build to produce your container images and orchestration, you can increase the speed and reliability of your deployment.
- Change application source code.
- Commit code to GitHub.
- Continuous Integration Trigger to Jenkins.
- Jenkins triggers a build job using Azure Kubernetes Service (AKS) for a dynamic build agent.
- Jenkins builds and pushes Docker container to Azure Container Registry.
- Jenkins deploys your new containerized app to Kubernetes on Azure.
- Container Service (AKS), backed by Azure Cosmos DB.
- Grafana displays visualization of infrastructure and application metrics via Azure Monitor.
- Monitor application and make improvements.
PRODUCTS/DESCRIPTION
I. Build and deploy multi-platform apps to get the most from Azure services.
II. Store and manage container images across all types of Azure deployments.
III. Globally distributed, multi-model database for any scale.
IV. Simplify the deployment, management, and operations of Kubernetes.
V. Highly granular and real-time monitoring data for any Azure resource.
Let's Prepare!
Open terminal, then execute:
# az ad sp create-for-rbac --name devops
hanging "devops" to a valid URI of "http://devops", which is the required format used for service principal names
Retrying role assignment creation: 1/36
{
"appId": "8b04e108-096f-4a89-bb43-4402c062f078",
"displayName": "devops",
"name": "http://devops",
"password": "5add8aa5-d661-47d3-9949-0ffd12274d9a",
"tenant": "060855ec-43f6-4b5b-8e0d-a7d1a4b08bfb"
}
#
Copy the values appId and password, they will be used later.
Use a new resource group and choose a location.
# az group create --resource-group DevopsEcosystem --location eastus
{
"id": "/subscriptions/39917769-5ad7-4e16-bf25-7914453b6578/resourceGroups/DevopsEcosystem",
"location": "eastus",
"managedBy": null,
"name": "DevopsEcosystem",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null
}
#
Now, we will create a template file azuredeploy.json with input the settings below:
SpClientID
spClientSecret
linuxAdminUsername
linuxAdminPassoword
linuxSSHPublicKey
cosmosDbName
acrName
jenkinsDnsPrefix
grafanaDnsPrefix
kubernetesClusterName
kubernetesAgentCount
kubernetesAgentVMSize
Important:
The names and DNS prefixes should be unique. To avoid naming conflicting, we strongly recommend you to add some suffix. For example, the Cosmos Db name could be acscosmosdb.
ACR (Azure Container Registry) names may contain alpha numeric characters only. A valid name is acrimages201901.
All Set! Let's Deploy…
Back to terminal, then execute:
# az group deployment create --resource-group DevOpsEcoSystem --template-uri https://raw.githubusercontent.com/adilsonbna/devopsecosystem/master/azuredeploy.json
- Running ....
It will take about 13 minutes to finish the deployment.
Deployment output
After the deployment finishes, you will get some important information from the outputs section.
Access Deployed Resources…
Access Jenkins
This Jenkins instance does not support https, so logging in through a public IP address has been disabled (it would expose your password and other information to eavesdropping). To securely login, you need to connect to the Jenkins instance using SSH port forwarding.
Connect to the Jenkins instance using "SSH port forwarding"
Copy the JENKINSSSH value from the Outputs section of the deployment.
Open terminal, then paste and execute it.
# ssh -L 8080:localhost:8080 adilson@acsjenkins.eastus.cloudapp.azure.com
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.15.0-1036-azure x86_64)* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantageGet cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud0 packages can be updated.
0 updates are security updates.New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.Last login: Sun Dec 30 18:45:55 2018 from 201.75.171.101
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.adilson@jenkins:~$
Get the Jenkins admin password
Execute the command in the terminal:
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
48bc2733dd714bdca003862e84e33aef
$
You will get the Jenkins admin password which looks like above:
Log into Jenkins
- Open http://localhost:8080 in a browser and input admin password:
Check the sample pipeline job
After logged in, you will see the Hello World Build & Deploy pipeline job. Please click to explore it.
Access Kubernetes Cluster
Sign into Azure and get AKS credentials
Execute the command below to get Kubenetes cluster credentials.
# az aks get-credentials --resource-group DevopsEcosystem --name acsv2kubecluster
Merged "acsv2kubecluster" as current context in /Users/adilsoncesar/.kube/config
Get Kubenetes service
Install kubectl if you have not and execute the command below:
# kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-world-service LoadBalancer 10.0.134.115 23.101.130.122 80:31909/TCP 34m
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 50m
Open the external IP in a browser. You will see the response:
Access the Grafana instance
Copy the GRAFANAURL value from the Outputs section of the deployment.
Open it in a browser, then log in:
Build your dashboards and Enjoy!
Access the Kubernetes Web dashboard (AKS)
To start the Kubernetes dashboard, use the az aks browse command. The following example opens the dashboard for the cluster named acsv2kubecluster in the resource group named DevopsEcosystem:
$ az aks browse --resource-group DevopsEcosystem --name acsv2kubecluster
Merged "acsv2kubecluster" as current context in /var/folders/rt/20m7t9mn3xd9zqb6bh1kwy580000gn/T/tmp9dri8nkb
Proxy running on http://127.0.0.1:8001/
Press CTRL+C to close the tunnel...
Forwarding from 127.0.0.1:8001 -> 9090
Forwarding from [::1]:8001 -> 9090
Handling connection for 8001
Handling connection for 8001
Handling connection for 8001
Handling connection for 8001
Handling connection for 8001
Handling connection for 8001
This command creates a proxy between your development system and the Kubernetes API, and opens a web browser to the Kubernetes dashboard. If a web browser doesn’t open to the Kubernetes dashboard, copy and paste the URL address noted in the Azure CLI, typically http://127.0.0.1:8001.
For the next tutorial, we will configure Jenkins with GitHub and once Jenkins is notified when new code is pushed to the repository. An automatically new pipeline will trigger building Docker image, Pushing image to ACR and finally Deploying it on AKS. Also, using Visual Studio Code of course.