The template allows you to host an instance of Jenkins on a DS1_v2 size Linux Ubuntu 14.04 LTS VM in Azure China.
It also includes a basic Jenkins pipeline that will checkout a sample git repository with a Dockerfile embedded and it will build and push the Docker container in the provisioned private docker registry you provided, then deploy it to Kubernetes cluster.
- Click the "Deploy to Azure" button. If you don't have an Azure subscription, you can follow instructions to signup for a free trial.
- Enter the desired user name and password for the VM that's going to host the Jenkins instance. Also provide a DNS prefix for your VM.
- Enter the appId and appKey for your Service Principal (used by the Jenkins pipeline to push the built docker container). If you don't have a service principal, use the Azure CLI 2.0 to create one (see here for more details):
az cloud set -n AzureChinaCloud az login az account set --subscription <Subscription ID> az ad sp create-for-rbac --name "Jenkins"
NOTE: You can run
az account list
after you login to get a list of subscription IDs for your account. - Enter a public git repository. The repository must have a Dockerfile in its root.
- Provide a private Docker registry url , login user name and password
- The Kubernetes master FQDN, user name and private key which is base64 encoded, the pipeline will deploy sample project to this kubernetes cluster. You could use some online tool to do encode.
By default the Jenkins instance is using the http protocol and listens on port 8080. Users shouldn't authenticate over unsecured protocols!
You need to setup port forwarding to view the Jenkins UI on your local machine. If you do not know the full DNS name of your instance, go to the Portal and find it in the deployment outputs here: Resource Groups > {Resource Group Name} > Deployments > {Deployment Name, usually 'Microsoft.Template'} > Outputs
Install Putty or use any bash shell for Windows (if using a bash shell, follow the instructions for Linux or Mac).
Run this command:
putty.exe -ssh -L 8080:localhost:8080 <User name>@<Public DNS name of instance you just created>
Or follow these manual steps:
- Launch Putty and navigate to 'Connection > SSH > Tunnels'
- In the Options controlling SSH port forwarding window, enter 8080 for Source port. Then enter 127.0.0.1:8080 for the Destination. Click Add.
- Click Open to establish the connection.
Run this command:
ssh -L 8080:localhost:8080 <User name>@<Public DNS name of instance you just created>
- After you have started your tunnel, navigate to http://localhost:8080/ on your local machine.
- Unlock the Jenkins dashboard for the first time with the initial admin password. To get this token, SSH into the VM and run
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Your Jenkins instance is now ready to use! You can access a read-only view by going to http://< Public DNS name of instance you just created >.
- Go to http://aka.ms/azjenkinsagents if you want to build/CI from this Jenkins master using Azure VM agents.
If you are using unsecured private docker registry for example if your docker registry use http instead of https or your certs are not CA signed. You need to do below command on jenkins master all nodes in kuernetes cluster to make whole pipleline works
sudo touch /etc/docker/daemon.json
sudo vim /etc/docker/daemon.json
then add below entry to configuration:
{"insecure-registries" : [ "139.217.12.139" ]}
then save the changes and run below command to restart docker
sudo service restart docker
The pipeline included in this template is based on the sample application(https://github.com/azure-devops/spin-kub-demo) to do build and deployment. You could use your own application, but the build and deployment scripts in Jenkins may need to be updated accordingly.
Azure-devops-utils (MIT License)
This repository contains utility scripts to run/configure DevOp systems in Azure.