Azure Pipeline Code Deploy over On-premise Kubernetes Cluster.
Pre-requisites:
1. Azure DevOps account
2. Kubernetes Cluster
Agenda:
1. Create Azure Git repository
2. Create a git local repository
3. Create the Dockerfile
4. Commit and merge to the master branch.
5. Create Build pipeline
6. Create a Deployment Group and PAT for On-Perm server access
7. Create a Service account for Cluster access from Azure
8. Create a Release pipeline.
Create Azure Git repository:
# login https://dev.azure.com/
# navigate to repos and create a new empty repo and select generate Git credentials
Create a git local repository:
"since our motive to deploy in on-perm server, not going in detail on git commands"
"To Clone and use the demonstrated configuration files, try Git-repo "
$ user@server: mkdir azurecicd && git init
$ user@server: cat >> EOF > Dockerfile
FROM centos:7
MAINTAINER xploritec
RUN yum -y install httpd
COPY index.html /var/www/html
CMD ["usr/sbin/httpd", "-D", "FOREGROUND"]
EXPOSE 80
EOF
## create the index.html or download one from
$ user@server: git add . && git status && git commit -m "first commit"
# output of git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: Dockerfile
new file: index.html
$ user@server: git remote add origin https://user@dev.azure.com/user/project/_git/newrepo
$ user@server: git push -u origin --all
Create an Azure Build Pipeline:
1. Navigate to azure Pipelines
Azure DevOps provides a great feature (Something like S2I) and provide us the appropriate templates to start editing: Here I select Docker.
Click Settings and select your "Docker hub" Service connection and name the repository something like {your docker repo}/demo-project. Save and run.
Azure Release Pipelines:
It's time to make a connection from Azure Pipelines to the On-prem server.
In my case, I have CentOS VM hosted on Oracle VirtualBox.
1. Starting Virtual machines and check the server's status:
Log on to Azure DevOps:
1. We are going to create a Deployment group and execute the script to make a connection to Azure pipelines for continuous deployment.
3. Time to execute the snippet on the On-Perm server.
4. Check the Deployment group for Virtual machine status:
5. Create a service account for cluster access from Azure Pipelines.
6. Create a new release pipeline and add deployment group Job and Kubectl task as below.
Conclusion: Achieving continuous delivery is quite a process, but things will get in place once we set up for the first time. The same process should follow to add more clusters or deployment groups.
Thank you, your article helped me a lot
ReplyDeleteThanks Bro...Savior...
ReplyDelete