![Page 1: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/1.jpg)
การสรางระบบ Automation CI/CD Pipeline ดวย open source Rancher
วทยากร: ธวช วราไชย / ไกรสวรรณ หยางทกร
ฝายคอมพวเตอรทางวศวกรรมศาสตร คณะวศวกรรมศาสตร
มหาวทยาลยสงขลานครนทร
![Page 2: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/2.jpg)
Workshop agenda
ความรเบองตนเกยวกบระบบ Automation CI/CD
รจกสถาปตยกรรมของ Rancher version 2.1 (RKE)
การตดตง Rancher version 2.1
Workshop 1. เรมตนงาย ๆ ดวยตนแบบทเตรยมไวใหแลว
Workshop 2. เรยนรตามตนแบบและปรบแตงมน
Workshop 3. ทดลองสราง Pine Line ของคณเอง
Discussion and experience sharing
![Page 3: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/3.jpg)
ความรเบองตนเกยวกบระบบAutomation CI/CD
ความจาเปนตอการใชงานระบบ Automation CI/CD
กระบวนการทางานของระบบ
เครองมอทใชในการสราง
เบองหลงกลไกการทางานของระบบ Automation CI/CD
จะเรมตนสรางระบบงานแบบ Automation ควรเรมตนอยางไร
![Page 4: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/4.jpg)
ความจาเปนตอการใชงานระบบ Automation CI/CD
ชวยวเคราะหดหนอยนะครบ “หนวยงานใหน จาเปนตองใชกระบวนการ Automation CI/CD” ?.
Operation+ Developer
Aหนวยงาน Bหนวยงาน Cหนวยงาน
Operation
เพลตฟอรมสาหรบการพฒนา
monolithic Microservices
เพลตฟอรมสาหรบการพฒนา
monolithic
เพลตฟอรมสาหรบการพฒนา
Microservices
Developer Developer Developer Operation Developer Developer Developer
![Page 5: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/5.jpg)
กระบวนการของระบบ Automation CI/CD Pipeline
Continuous Delivery / Continuous Deploy
CDCIContinuous Integration
![Page 6: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/6.jpg)
เครองมอทใชในการสรางระบบ Automation CI/CD
Drone CI
Concourse CI
Reference https://stackify.com/top-continuous-integration-tools
![Page 7: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/7.jpg)
เบองหลงการทางานของระบบ Automation CI/CD
http://yaml.orghttps://en.wikipedia.org/wiki/YAML
Execution
(YAML Ain't Markup Language)Initial release 11 May 2001
![Page 8: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/8.jpg)
จะเรมตนสรางระบบงานแบบ Automation ควรเรมตนอยางไร
1. ควรศกษา ทาความเขาใจและกาหนดขอตกลงรวมกนภายในทม
2. ออกแบบ Workflow ของการพฒนาระบบงานรวมกน
3. เลอกเครองมอทเหมาะสมทสดกบทมของคณ
4. เลอกโครงการทสนใจ มาสก 1-2 โครงการ เพอศกษาและทดสอบกระบวนการ
5. สรปผลการทดสอบและปรบปรงกระบวนการเพอให บรรลเปาหมาย
![Page 9: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/9.jpg)
ตวอยาง Workflow ของทมพฒนาระบบสารสนเทศของคณะวศวกรรมศาสตร มหาวทยาลยสงขลานครนทร
Productionenvironment
Developenvironment
QA
Deploy
Build
Testing
Run
Feedback
Run
Release upgraded
Operation Developer
Developer
![Page 10: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/10.jpg)
รจกสถาปตยกรรมของ Rancher version 2.1 (RKE)
RKE, Unified Cluster ManagementHigh-level ArchitectureApplication Workload ManagementRancher tools Pipelines
https://rancher.com
One Platform for Kubernetes Management
![Page 11: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/11.jpg)
สถาปตยกรรมของ Rancher version 2.1 (RKE)
Google: Kubernetes (K8S)
https://kubernetes.io
https://rancher.com
![Page 12: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/12.jpg)
Rancher 2.1 High-level Architecture
etcdnodes
controlplanenodes
workernodes
Cluster
https://rancher.com/docs/rancher/v2.x/en/overview/architecture
Rancher server components1. Rancher API Server2. Cluster Controller and Agents3. Authentication Proxy
![Page 13: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/13.jpg)
Rancher 2.1 Application Workload Management
https://rancher.com/managing-kubernetes-workloads-with-rancher-2-0
![Page 14: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/14.jpg)
Rancher 2.1 Tools pipelines
https://rancher.com/docs/rancher/v2.x/en/concepts/ci-cd-pipelines
![Page 15: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/15.jpg)
RequirementsInstallation modeSingle node install
การตดตง Rancher version 2.1
https://rancher.com/docs/rancher/v2.x/en/installation
![Page 16: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/16.jpg)
Rancher version 2.1 Requirements
Operating System
• Ubuntu 16.04 (64-bit)• Red Hat Enterprise Linux 7.5 (64-bit)• RancherOS 1.4 (64-bit)• Windows Server version 1803 (64-bit)
https://rancher.com/docs/rancher/v2.x/en/installation/requirements
Hardware
Deployment Size Clusters Nodes vCPUs RAM
Small Up to 5 Up to 50 4 16GB
Medium Up to 100 Up to 500 8 32GB
Large Over 100 Over 500 Contact RancherSoftware support Docker version
• 17.03.x• 18.06.x• 18.09.x
![Page 17: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/17.jpg)
Rancher 2.1: Installation mode
1. Single Node Install 2. High Availability (HA) Install
1VM / 4 vCPUs / RAM 4 GB
![Page 19: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/19.jpg)
Virtualbox Network setting
Network setting
Attached to : Bridged Adapter
Name: [Select your network adapter]
![Page 20: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/20.jpg)
Virtualbox start VM and get your IP address
Start VM WUNCA39
User : osboxesPassword: osboxes.org
Check your IP address
ifconfig
![Page 21: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/21.jpg)
Open SSH connection
Open PuTTY program SSH connect
Fill-up your IP address: Open connection
User : osboxesPassword: osboxes.org
![Page 22: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/22.jpg)
Rancher 2.1: single node install with docker command
sudo docker run --name rancher2 --restart=unless-stopped \-d -p 8080:80 -p 8443:443 \-v /data/rancher2:/var/lib/rancher rancher/rancher:latest
![Page 23: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/23.jpg)
Open your web browser for setup Rancher
http://[your ip address]:8080
Example: http://172.13.133.148:8080
Set new password for admin user
Click “Continue”
![Page 24: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/24.jpg)
Open your web browser for setup Rancher
Click “Save URL”
![Page 25: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/25.jpg)
Open your web browser for setup Rancher
Welcome to Rancher!
Click “Got it”
![Page 26: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/26.jpg)
Add Cluster
Select “CUSTOM”
Example wunca39
Then click “Next”
![Page 27: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/27.jpg)
Add Cluster
Set Node Role
• Etcd
• Control plane
• worker
Click “copy to clipboard”
![Page 28: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/28.jpg)
Install Rancher agent node
Paste code from clipboard to SSH terminal
Enter for run docker command
![Page 29: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/29.jpg)
Check your status in Add Cluster
“1 new node has registered”
Click “Done”
![Page 30: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/30.jpg)
Wait for Rancher setup system workload
Click menu wunca39 > system
Check for “green color active”
status
Wait for system workload is active
Successfully are system workload
activated
![Page 31: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/31.jpg)
Workshop 1. เรมตนงาย ๆ ดวยตนแบบทเตรยมไวใหแลว
Github fork startup template projectRancher add repository and authorize Github accountThe first run manual pipeline CI/CDSee your result
![Page 32: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/32.jpg)
Github fork startup template project
1. Github login
2. Fork repository from
https://github.com/vthawat/wunca39
![Page 33: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/33.jpg)
Rancher add repository for manage
1. Click from menu
wunca39 > default
2. Click “Pipelines”
3. Click “Configure Repositories”
![Page 34: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/34.jpg)
Rancher add repository for manage
1. Click from menu
wunca39 > default
2. Click “Pipelines”
3. Click “Configure Repositories”
4. Click “Authorize & Fetch Your Own Repository”
5. Click “Config Now”
![Page 35: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/35.jpg)
Rancher add repository for manage
Follow step from Setup a githubapplication
![Page 36: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/36.jpg)
Rancher add repository for manage
Step 1. add new application from link https://github.com/settings/developers
![Page 37: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/37.jpg)
Rancher add repository for manage
Step 2. Fill-up form for Register a new OAuth application
This is example please see instruction from your Rancher screen
Then click “Register application”
![Page 38: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/38.jpg)
Rancher add repository for manage
Copy Client ID and Client Secret from your Github application
Then click “Authenticate”
![Page 39: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/39.jpg)
Rancher add repository for manage
Click “Authorize”
![Page 40: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/40.jpg)
Rancher enable repository for run CI/CD pipeline
Click Enabled for repository wunca39.git
Then click “Done”
![Page 41: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/41.jpg)
The first run manual pipeline CI/CD
![Page 42: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/42.jpg)
The first run manual pipeline CI/CD
Wait for pipeline execution
see log detail on pipeline step
![Page 43: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/43.jpg)
The first run manual pipeline CI/CD
The pipeline execution success all step display green color
![Page 44: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/44.jpg)
See your result the CI/CD startup template
![Page 45: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/45.jpg)
![Page 46: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/46.jpg)
Workshop 2. เรยนรตามตนแบบและปรบแตงมน
How Pipelines Work on Rancher version 2.1How to customize startup template
![Page 47: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/47.jpg)
How Pipelines Work on Rancher version 2.1
https://rancher.com/docs/rancher/v2.x/en/tools/pipelines/#how-pipelines-work
1
2
3
![Page 48: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/48.jpg)
How to customize startup template
Important files of Rancher CI/CD pipeline
.rancher-pipeline.yaml -- rancher pipeline script
Dockerfile -- docker build image script
Deployment.yaml -- rancher deployment script
1
2
3
![Page 49: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/49.jpg)
Rancher pipeline stages
https://rancher.com/docs/rancher/v2.x/en/tools/pipelines
Build Publish Deploy1 2 3
![Page 50: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/50.jpg)
.rancher-pipeline.yaml
How to customize startup template
1
![Page 51: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/51.jpg)
Build stage
Build stages
- runScriptConfig:
image: [image for build source code]
shellScript: [use shell command from image define]
Example:
image: alpine
shellScript: |-
mkdir ./test
echo ‘hello wunca39’ > ./test/test.txt
![Page 52: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/52.jpg)
Publish stage
Publish stages
- publishImageConfig:
dockerfilePath: [docker source for build image]
buildContext: . [use option command for docker build]
tag: [use command for docker tag]
Example:
dockerfilePath : ./Dockerfile
buildContext : .
tag: vthawat/wunca39:version-1
![Page 53: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/53.jpg)
Deploy stage
Deploy stages
- applyYamlConfig:
path: [rancher source deployment config]
Example:
path : ./deployment.yaml
![Page 54: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/54.jpg)
Dockerfile
How to customize startup template
2
![Page 55: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/55.jpg)
Dockerfile
FROM [base image for docker build]
RUN [use command reference on image from]
COPY [copy file local to build image ]
CMD [use command when container start]
EXPOSE [use port number for connection]
Example:
FROM nginx
COPY /sample-html /usr/share/nginx/html
EXPOSE 80
https://docs.docker.com/develop/develop-images/dockerfile_best-practices
![Page 56: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/56.jpg)
deployment.yaml
How to customize startup template
3
![Page 57: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/57.jpg)
deployment.yaml
kind: Service kind: Deployment
metadata:
name: hello-service
labels:
app:hello
spec:
port: 80
https://kubernetes.io/docs/getting-started-guides/ubuntu/rancher
metadata:
name: deploy-hello
labels:
app:hello
spec:
replicas: 3
![Page 58: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/58.jpg)
Workshop 2.1 Pipeline CI/CD trigger
Pipeline CI/CD trigger configurationTesting git push for trigger eventCheck your result
![Page 59: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/59.jpg)
Pipeline CI/CD trigger configuration
Pipeline trigger type
1 Branch 2 Event
webhook
Git CLI
- Master
- Develop
- pull request- push- tag
![Page 60: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/60.jpg)
Github web hook don’t work in localhost or LAN IP address
https://developer.github.com/webhooks/configuring
web hook
https://172.31.133.148:8080Rancher Server
Using ngrokForwarding https://7e9ea9dc.ngrok.io -> 172.31.133.148:8080
Rancher server https://7e9ea9dc.ngrok.io
![Page 61: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/61.jpg)
Using https://ngrok.com
![Page 62: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/62.jpg)
Setup ngrok
1. Sign up new account
https://dashboard.ngrok.com/user/signup
2. Open SSH terminal
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
unzip ngrok-stable-linux-amd64.zip
./ngrok authtoken <YOUR_AUTH_TOKEN>
./ngrok http <YOUR HOST IP ADDRESS>:8080
3. Copy url from ngrok generate URL forwarding
Example: https://6c595d35.ngrok.io
![Page 63: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/63.jpg)
Rancher settings server-url
![Page 64: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/64.jpg)
Rancher settings server-url
![Page 65: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/65.jpg)
Git hub add webhooks
Payload URL:
https://e08ac305.ngrok.io/hooks
Content type: application/json
Secret: dfgkp994
Example
![Page 66: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/66.jpg)
Check your git hub repository settings Webhooks
![Page 67: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/67.jpg)
Rancher pipeline configure repositories
![Page 68: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/68.jpg)
Configure repositories Disable and Enable toggle
![Page 69: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/69.jpg)
Testing git push for trigger event
1. Git clone your repository
2. Modify source code
./sample-html/index.html
3. Git commit
4. Git push
![Page 70: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/70.jpg)
Testing git push for trigger event
![Page 71: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/71.jpg)
Testing git push for trigger event
Pipeline begin process automatic when git push event
![Page 72: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/72.jpg)
Workshop 2.2 Deploy with Ingrees
About IngressConfiguration deployment.yaml
![Page 73: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/73.jpg)
About Ingress
https://kubernetes.io/docs/concepts/services-networking/ingress
Kubernetes engine
Pod service A
Pod service B
Ingress controller
Internet
wunca39.workshop.io
demo.workshop.comUser
Version 2.1
![Page 74: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/74.jpg)
Configuration deployment.yaml
• remove comment line #
• Edit
host wunca38.[your ingress controller ip].nip.io
• Sample domain with wildcard DNS for any IP Address
• Save
• Git commit
• Git push
![Page 75: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/75.jpg)
Wait pipeline process
![Page 76: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/76.jpg)
See detailed log pipeline deploy step
![Page 77: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/77.jpg)
See your Workloads > Load balancing
Ingress created wunca39 > devstarter-service
![Page 78: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/78.jpg)
Check your result
![Page 79: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/79.jpg)
Workshop 2.3 Run pipeline example-react
Learn for build and testing pipeline CI/CD
![Page 80: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/80.jpg)
Learn for build and testing pipeline CI/CD
Fork example-react project
https://github.com/vthawat/example-react
Deploy example-react with Ingress
http://example-react.[your ip address].xip.io
1
2
![Page 81: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/81.jpg)
Check your result
![Page 82: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/82.jpg)
Workshop 2.4 Use external docker registry
About docker registryCreate new repository on docker hubPipeline configuration use external docker registry
![Page 83: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/83.jpg)
Rancher Pipelines default use internal private registry
https://rancher.com/docs/rancher/v2.x/en/tools/pipelines/#how-pipelines-work
1
2
3
![Page 84: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/84.jpg)
About docker registry
Public Registry
Docker image
Docker image
Docker image
Docker pull Docker pull
Docker push Docker push
Authentication
Private Registry
Docker image
Docker image
Docker image
Authenticationhub.docker.com gitlab.com
treescale.com
![Page 85: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/85.jpg)
Create new repository on hub.docker.com
1. Sign-in https://hub.docker.com
2. Create Repository
3. Fill-up repository name and shot description
4. Click “Create”
![Page 86: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/86.jpg)
Rancher add registry
![Page 87: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/87.jpg)
Rancher add registry
1. Fill-up Name
2. Address select DockerHub
3. Fill-up username/password Docker hub account
4. Click “Save”
![Page 88: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/88.jpg)
Configuration file .rancher-pipeline.yaml
Edit on line 12
tag: [dockerhub username]/wunca39:version-${CICD_EXECUTION_SEQUENCE}
Remove comment on line 14-15
pushRemote: true
registry: index.docker.io
![Page 89: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/89.jpg)
Git push and wait for Pipeline execution
![Page 90: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/90.jpg)
Workshop 3. ทดลองสราง Pine Line ของคณเอง
![Page 91: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/91.jpg)
Create and design your pipeline CI/CD
1 2 3 4
RKE
ตองเขาใจกระบวนการขนตอนใน
การ build docker image ใหรองรบ
การทางานของ App หรอ Services
ตองเขาใจกระบวนการ
ขนตอนในการ test และ
build source code
ตองเขาใจกระบวนการขนตอนใน
การ deploy container ใหทางาน
รวมกนมากกวา 1 container
ตองตงเปาหมายทจะ
พฒนาอะไร เชน
Services , Application
เปนตนและเลอกภาษาท
ใชในการพฒนาให
เหมาะสมกบสงทจะ
พฒนาใหมากทสด
![Page 92: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/92.jpg)
Discussion and experience sharing
![Page 93: การสร้างระบบAutomation CI/CD Pipeline ด้วยopen source …wunca.uni.net.th/wunca_regis/wunca39_doc/28/014-.Automation-CICD.pdfการสร้างระบบAutomation](https://reader033.vdocuments.site/reader033/viewer/2022060310/5f0a934a7e708231d42c4ea5/html5/thumbnails/93.jpg)
Thank [email protected]://ecs.eng.psu.ac.th
ฝายคอมพวเตอรทางวศวกรรมศาสตร คณะวศวกรรมศาสตร
มหาวทยาลยสงขลานครนทร