SlideShare a Scribd company logo
1 of 58
Download to read offline
鄭毓融
23 October 2017
CI/CD with Kubernetes
Agenda
Introduction of Continuous Integration and Continuous Deployment/Delivery
- What is CI/CD?
- Run CI/CD with Kubernetes?
Setup Jenkins with Kubernetes
- Setup minikube & jenkins
- Add kubernetes in jenkins
- Test
Summary
2
Introduction of Continuous Integration and Continuous
Delivery (CI/CD)
What is CI/CD and Why need that?
Continuous Integration -
「 持續整合 」 目的在儘快讓新功能的程式碼整合到現存的基礎程式庫(codebase) 中來進行測試。
Continuous Deploy -
「 持續部署 」 的目的就是要讓軟體可以快速自動部署到不同的環境, 至於有多少環境需要部署則
會根據不同公司的持續交付管線(pipeline) 的設計而定。
Continuous Delivery -
「 持續交付 」 是將新的特性儘快交付到最終使用者(end-user) 的手中 。
簡單來說就是盡量減少手動人力,將一些日常工作交給自動化工具。例如:環境建置、單元測試、日
誌紀錄、產品部署。
What is CI/CD?
引用自:
山姆鍋對持續整合、持續部署、持續交付的定義
DevOps:持續整合&持續交付(Docker、CircleCI、AWS)
CI/CD 流程範例
引用自: 安德魯的部落格- 架構師觀點:你需要什麼樣的CI/CD?
Run CI/CD with Kubernetes
引用自: Achieving CI/CD with Kubernetes
Jenkins 透過 Kubernetes plugin 操作
kubernetes cluster 建立 pod (slaves) 來執
行 CI/CD 任務。
Pod 上使用 jenkins/jnlp-slave image,啟動
jnlp java slave 程式,連接 jenkins master。
當完成 CI/CD 任務後,該 pod 自動從
kubernetes cluster 中刪除,釋放資源。
Setup Jenkins with Kubernetes
Use kubernetes-plugin in jenkins
Setup Environment (Minikube)
Host Machine
Virtual Machine (Minikube)
Docker Container (Jenkins Master)
Kubernetes Pod (Jenkins Slave)
Kubernetes Pod (Jenkins Slave)
Kubernetes Pod (Jenkins Slave)
Kubernetes Pod (Jenkins Slave)
Install minikube
root@ycheng:/home/ycheng# curl -L
https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-ubuntu16.04 >
/usr/local/bin/docker-machine-driver-kvm
root@ycheng:/home/ycheng# curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.22.0/minikube-linux-amd64 && chmod
+x minikube && sudo mv minikube /usr/local/bin/
root@ycheng:/home/ycheng# curl -O "https://storage.googleapis.com/kubernetes-release/release/v1.7.8/bin/linux/amd64/kubectl"
root@ycheng:/home/ycheng# chmod +x kubectl && sudo mv kubectl /usr/local/bin/
root@ycheng:/home/ycheng# minikube start --vm-driver=kvm
Starting local Kubernetes v1.7.5 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Run jenkins docker
root@ycheng:/home/ycheng# minikube ssh
_ _
_ _ ( ) ( )
___ ___ (_) ___ (_)| |/') _ _ | |_ __
/' _ ` _ `| |/' _ `| || , < ( ) ( )| '_` /'__`
| ( ) ( ) || || ( ) || || |` | (_) || |_) )( ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`___/'(_,__/'`____)
$ pwd
/home/docker
$ mkdir /home/docker/jenkins_home
$ chmod 777 /home/docker/jenkins_home
$ mkdir /home/docker/jenkins_volume
$ chmod 777 /home/docker/jenkins_volume
$ docker create --name jenkins-k8s jenkins:2.60.3
Unable to find image 'jenkins:2.60.3' locally
2.60.3: Pulling from library/jenkins
3e17c6eae66c: Pull complete
….
Status: Downloaded newer image for jenkins:2.60.3
6f8aef4da1a9ba669e7630ef5deac86c7e15d992ba9a592ff8dca251c4c2c611
Run jenkins docker
$ docker run -d --volumes-from jenkins-k8s -p 8080:8080 -p 50000:50000 -v /home/docker/jenkins_home:/var/jenkins_home jenkins:2.60.3
9107e83bc474e7160fda33c9a52888228ece1e6ad6dd810fca3ac36493b14311
$ docker logs 9107e83bc474e7160fda33c9a52888228ece1e6ad6dd810fca3ac36493b14311
Running from: /usr/share/jenkins/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
….
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
2e058590dded40e5b3d7996246cf3be2
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
….
--> setting agent port for jnlp
--> setting agent port for jnlp... done
Enter jenkins web console
Install suggested plugins
Install suggested plugins
Create admin user
Start using jenkins
Jenkins web UI
Add kubernetes-plugin
Add kubernetes-plugin
Add kubernetes-plugin
Add kubernetes-plugin
Config kubernetes in jenkins
Add kubernetes in jenkins (minikube)
Add kubernetes in jenkins (minikube)
root@ycheng:/home/ycheng# cat /root/.kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority: /root/.minikube/ca.crt
server: https://192.168.42.102:8443
name: minikube
contexts:
- context:
cluster: minikube
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: /root/.minikube/apiserver.crt
client-key: /root/.minikube/apiserver.key
Add kubernetes in jenkins (minikube)
root@ycheng:/home/ycheng# cat /root/.minikube/ca.crt
-----BEGIN CERTIFICATE-----
MIIC5zCCAc+gAwIBAgIBATANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwptaW5p
a3ViZUNBMB4XDTE3MTAxNjA3NDkyNVoXDTI3MTAxNDA3NDkyNVowFTETMBEGA1UE
AxMKbWluaWt1YmVDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKv7
Yum+t342V8/gJw//sv77Gr/WguJ+0JrQISAIQF4Z+ABitbQ9nX0yoZLSTg80qIcy
HDclGF1sQt7BDnfH+UtiCvDrEdMMAqwcYtKGdMW3El7uU6tisnjkwg3ZDflv+7y1
l7TZUMyc+ByWql2wm7h+D3b1f1IRPnevGBPKkTK1HYmIowe5nPzOXnHKU+1zSGmt
wW6yBswE+xz/Y42YCu2qUNnkPKmVYeQCF8fH4SJRBzczfQ0ZLXmO9y/LtzOqedcV
HQv+p0sklG6/ia8Poxn/HdZ3L30hzSGmkwQrwPqL8ty47HTVSx/oC1/jssYMN9mf
CFwWinNjNKV7s2RtMekCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgKkMB0GA1UdJQQW
MBQGCCsGAQUFBwMCBggrBgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3
DQEBCwUAA4IBAQCUqJ8skMD5rZ50+h1IMCyek40eCEiwMW3EPqdiEtgr3oxzdurq
foph2mA9mPyvG9sFmDLAxlXi+bWYXOmKd2I0I6wcejk0hSAEdVhLO925vXWMzVuO
Liet0lHfOGL+zlTPANq858T6GhVC0WKeK/2moxgOTxHq/oTcpNmfXZHDKMvfmlxc
WTwao8uewveZ3QJLaFOFnVWRNqgY/OhFRDW/Mpa4+vNf6r9QX5AUfFGY/0/03MSw
+eohaKZsWbjxAPzwhvYw0lb7nRlJusjfn9lGWCI8b7W75UsPjnK6WOMe+7LXRuHI
fGRiCBzg8n29bvefS05lsFEf8ZC2X76CyxAF
-----END CERTIFICATE-----
Add kubernetes in jenkins (minikube)
root@ycheng:~# openssl pkcs12 -export -out ~/.minikube/minikube.pfx -inkey ~/.minikube/apiserver.key -in ~/.minikube/apiserver.crt
-certfile ~/.minikube/ca.crt -passout pass:secret
root@ycheng:~# cp -afpR ~/.minikube/minikube.pfx ~
root@ycheng:~# ls -l ./minikube.pfx
-rw-r--r-- 1 root root 3293 10月 17 14:41 ./minikube.pfx
Add kubernetes in jenkins (minikube)
Add kubernetes in jenkins (minikube)
Add kubernetes in jenkins (minikube)
Add kubernetes in jenkins (minikube)
Create a project
Config project label
Add shell command to test
Run the project
Run the project
Run the project
Run the project
Run the project
Check output
Check output
root@ycheng:~# minikube ssh
_ _
_ _ ( ) ( )
___ ___ (_) ___ (_)| |/') _ _ | |_ __
/' _ ` _ `| |/' _ `| || , < ( ) ( )| '_` /'__`
| ( ) ( ) || || ( ) || || |` | (_) || |_) )( ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`___/'(_,__/'`____)
$ ls -l ./jenkins_volume/
total 4
-rw-r--r-- 1 10000 10000 48 Oct 17 09:14 output
$ cat ./jenkins_volume/output
Tue Oct 17 09:14:39 UTC 2017
free-job-test-done
Add another kubernetes cluster (2+1)
Host Machine
Virtual Machine (Minikube)
Docker Container (Jenkins Master)
Virtual Machine (Kubernetes node1 - master)
Virtual Machine (Kubernetes node2 - minion)
Virtual Machine (Kubernetes node3 - minion)
kubernetes cluster 2+1
root@ycheng:~# virsh list
Id Name State
----------------------------------------------------
33 minikube running
34 kubernetes_node1 running
35 kubernetes_node2 running
36 kubernetes_node3 running
root@node1:~# kubectl get node -o wide
NAME STATUS AGE VERSION EXTERNAL-IP OS-IMAGE KERNEL-VERSION
node1 Ready,master 161d v1.6.2 <none> Ubuntu 16.04.2 LTS 4.4.0-62-generic
node2 Ready 161d v1.6.2 <none> Ubuntu 16.04.2 LTS 4.4.0-62-generic
node3 Ready 161d v1.6.2 <none> Ubuntu 16.04.2 LTS 4.4.0-62-generic
root@node1:~# kubectl create ns jenkins
namespace "jenkins" created
root@node1:~# showmount -e 192.168.2.254
Export list for 192.168.2.254:
/root/jenkins_output *
Test script and data on NFS server
root@ycheng:~/jenkins_output# ls -l
total 4
drwxrwxrwx 3 ycheng ycheng 4096 10月 19 17:36 iostat_analyzer_for_jenkins
root@ycheng:~/jenkins_output# ls -l ./iostat_analyzer_for_jenkins/
total 40
-rwxrwxr-x 1 ycheng ycheng 527 10月 19 17:19 combine_iostat_files.sh
-rwxrwxrwx 1 ycheng ycheng 13542 10月 19 17:19 iostat_analysis_io_req.sh
-rwxrwxr-x 1 ycheng ycheng 10079 10月 19 11:15 split_by_day.sh
drwxrwxrwx 2 ycheng ycheng 4096 10月 19 17:38 rawdata
Config kubernetes cluster
Config kubernetes cluster
Config kubernetes cluster
Create pipeline job
Write pipeline script
Run pipeline job
pipeline stage
pipeline stage
pipeline stage
Terminal output
Terminal output
Summary
Summary
Continuous Integration
Continuous Deploy
Continuous Delivery
CI/CD with Kubernetes
Other CI/CD Tools :
- Travis CI
- Circle CI
- Drone.io
- gitlab
- & more...
References
https://samkuo.me/post/2013/10/continuous-integration-deployment-delivery/
http://blog.amowu.com/2015/04/devops-continuous-integration-delivery-docker-circl
eci-aws-beanstalk.html
http://columns.chicken-house.net/2017/08/05/what-cicd-do-you-need/
https://docs.docker.com/samples/library/jenkins/
https://travis-ci.org/
http://try.drone.io/
https://dzone.com/articles/achieving-cicd-with-kubernetes
www.inwinstack.com
Thank You!
迎 棧 科 技 股 份 有 限 公 司

More Related Content

What's hot

What's hot (20)

Building Clustered Applications with Kubernetes and Docker
Building Clustered Applications with Kubernetes and DockerBuilding Clustered Applications with Kubernetes and Docker
Building Clustered Applications with Kubernetes and Docker
 
Kubernetes 101 Workshop
Kubernetes 101 WorkshopKubernetes 101 Workshop
Kubernetes 101 Workshop
 
Effective Building your Platform with Kubernetes == Keep it Simple
Effective Building your Platform with Kubernetes == Keep it Simple Effective Building your Platform with Kubernetes == Keep it Simple
Effective Building your Platform with Kubernetes == Keep it Simple
 
Running Production-Grade Kubernetes on AWS
Running Production-Grade Kubernetes on AWSRunning Production-Grade Kubernetes on AWS
Running Production-Grade Kubernetes on AWS
 
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level InterfacesKubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
 
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and BeyondTectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Understanding Kubernetes
Understanding KubernetesUnderstanding Kubernetes
Understanding Kubernetes
 
Kubernetes 101 and Fun
Kubernetes 101 and FunKubernetes 101 and Fun
Kubernetes 101 and Fun
 
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
 
DevOps in AWS with Kubernetes
DevOps in AWS with KubernetesDevOps in AWS with Kubernetes
DevOps in AWS with Kubernetes
 
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech TalkKubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech Talk
 
Kubernetes architecture
Kubernetes architectureKubernetes architecture
Kubernetes architecture
 
Rex gke-clustree
Rex gke-clustreeRex gke-clustree
Rex gke-clustree
 
Continuous Deployment with Jenkins on Kubernetes
Continuous Deployment with Jenkins on KubernetesContinuous Deployment with Jenkins on Kubernetes
Continuous Deployment with Jenkins on Kubernetes
 
GKE vs OpenStack Magnum
GKE vs OpenStack MagnumGKE vs OpenStack Magnum
GKE vs OpenStack Magnum
 
Kube-AWS
Kube-AWSKube-AWS
Kube-AWS
 
Kubernetes on aws
Kubernetes on awsKubernetes on aws
Kubernetes on aws
 
How to Achieve Canary Deployment on Kubernetes
How to Achieve Canary Deployment on KubernetesHow to Achieve Canary Deployment on Kubernetes
How to Achieve Canary Deployment on Kubernetes
 
Distributed tensorflow on kubernetes
Distributed tensorflow on kubernetesDistributed tensorflow on kubernetes
Distributed tensorflow on kubernetes
 

Viewers also liked

Viewers also liked (8)

DNN平台建置分享
DNN平台建置分享DNN平台建置分享
DNN平台建置分享
 
Kubernetes 架構與虛擬化之差異
Kubernetes 架構與虛擬化之差異Kubernetes 架構與虛擬化之差異
Kubernetes 架構與虛擬化之差異
 
Montreal Kubernetes Meetup: Developer-first workflows (for microservices) on ...
Montreal Kubernetes Meetup: Developer-first workflows (for microservices) on ...Montreal Kubernetes Meetup: Developer-first workflows (for microservices) on ...
Montreal Kubernetes Meetup: Developer-first workflows (for microservices) on ...
 
OVN: Scaleable Virtual Networking for Open vSwitch
OVN: Scaleable Virtual Networking for Open vSwitchOVN: Scaleable Virtual Networking for Open vSwitch
OVN: Scaleable Virtual Networking for Open vSwitch
 
Network plugins for kubernetes
Network plugins for kubernetesNetwork plugins for kubernetes
Network plugins for kubernetes
 
容器革命的「利」與「必」
容器革命的「利」與「必」 容器革命的「利」與「必」
容器革命的「利」與「必」
 
Build your own kubernetes apiserver and resource type
Build your own kubernetes apiserver and resource typeBuild your own kubernetes apiserver and resource type
Build your own kubernetes apiserver and resource type
 
Microservices: Notes From The Field
Microservices: Notes From The FieldMicroservices: Notes From The Field
Microservices: Notes From The Field
 

Similar to Cantainer CI/ CD with Kubernetes

containerit at useR!2017 conference, Brussels
containerit at useR!2017 conference, Brusselscontainerit at useR!2017 conference, Brussels
containerit at useR!2017 conference, Brussels
Daniel Nüst
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting started
Munish Mehta
 
DockerCon14 Performance Characteristics of Traditional VMs vs. Docker Containers
DockerCon14 Performance Characteristics of Traditional VMs vs. Docker ContainersDockerCon14 Performance Characteristics of Traditional VMs vs. Docker Containers
DockerCon14 Performance Characteristics of Traditional VMs vs. Docker Containers
Docker, Inc.
 

Similar to Cantainer CI/ CD with Kubernetes (20)

What’s New in Docker - Victor Vieux, Docker
What’s New in Docker - Victor Vieux, DockerWhat’s New in Docker - Victor Vieux, Docker
What’s New in Docker - Victor Vieux, Docker
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build Script
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
Delivering Docker & K3s worloads to IoT Edge devices
Delivering Docker & K3s worloads to IoT Edge devicesDelivering Docker & K3s worloads to IoT Edge devices
Delivering Docker & K3s worloads to IoT Edge devices
 
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
 
Shifter: Containers in HPC Environments
Shifter: Containers in HPC EnvironmentsShifter: Containers in HPC Environments
Shifter: Containers in HPC Environments
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
Production sec ops with kubernetes in docker
Production sec ops with kubernetes in dockerProduction sec ops with kubernetes in docker
Production sec ops with kubernetes in docker
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
 
[Hands-on] Kubernetes | Nov 18, 2017
[Hands-on] Kubernetes | Nov 18, 2017[Hands-on] Kubernetes | Nov 18, 2017
[Hands-on] Kubernetes | Nov 18, 2017
 
MeaNstack on Docker
MeaNstack on DockerMeaNstack on Docker
MeaNstack on Docker
 
Vincent Ruijter - ~Securing~ Attacking Kubernetes
Vincent Ruijter - ~Securing~ Attacking KubernetesVincent Ruijter - ~Securing~ Attacking Kubernetes
Vincent Ruijter - ~Securing~ Attacking Kubernetes
 
containerit at useR!2017 conference, Brussels
containerit at useR!2017 conference, Brusselscontainerit at useR!2017 conference, Brussels
containerit at useR!2017 conference, Brussels
 
Cookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and ServerrspecCookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and Serverrspec
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting started
 
DockerCon14 Performance Characteristics of Traditional VMs vs. Docker Containers
DockerCon14 Performance Characteristics of Traditional VMs vs. Docker ContainersDockerCon14 Performance Characteristics of Traditional VMs vs. Docker Containers
DockerCon14 Performance Characteristics of Traditional VMs vs. Docker Containers
 
Docker
DockerDocker
Docker
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventures
 

More from inwin stack

More from inwin stack (20)

Migrating to Cloud Native Solutions
Migrating to Cloud Native SolutionsMigrating to Cloud Native Solutions
Migrating to Cloud Native Solutions
 
Cloud Native 下的應用網路設計
Cloud Native 下的應用網路設計Cloud Native 下的應用網路設計
Cloud Native 下的應用網路設計
 
當電子發票遇見 Google Cloud Function
當電子發票遇見 Google Cloud Function當電子發票遇見 Google Cloud Function
當電子發票遇見 Google Cloud Function
 
運用高效、敏捷全新平台極速落實雲原生開發
運用高效、敏捷全新平台極速落實雲原生開發運用高效、敏捷全新平台極速落實雲原生開發
運用高效、敏捷全新平台極速落實雲原生開發
 
The last mile of digital transformation AI大眾化:數位轉型的最後一哩
The last mile of digital transformation AI大眾化:數位轉型的最後一哩The last mile of digital transformation AI大眾化:數位轉型的最後一哩
The last mile of digital transformation AI大眾化:數位轉型的最後一哩
 
整合Cloud Foundry 和 Kubernetes 技術打造企業級雲應用平台解決方案
整合Cloud Foundry 和 Kubernetes 技術打造企業級雲應用平台解決方案整合Cloud Foundry 和 Kubernetes 技術打造企業級雲應用平台解決方案
整合Cloud Foundry 和 Kubernetes 技術打造企業級雲應用平台解決方案
 
An Open, Open source way to enable your Cloud Native Journey
An Open, Open source way to enable your Cloud Native JourneyAn Open, Open source way to enable your Cloud Native Journey
An Open, Open source way to enable your Cloud Native Journey
 
維運Kubernetes的兩三事
維運Kubernetes的兩三事維運Kubernetes的兩三事
維運Kubernetes的兩三事
 
Serverless framework on kubernetes
Serverless framework on kubernetesServerless framework on kubernetes
Serverless framework on kubernetes
 
Train.IO 【第六期-OpenStack 二三事】
Train.IO 【第六期-OpenStack 二三事】Train.IO 【第六期-OpenStack 二三事】
Train.IO 【第六期-OpenStack 二三事】
 
Web後端技術的演變
Web後端技術的演變Web後端技術的演變
Web後端技術的演變
 
以 Kubernetes 部屬 Spark 大數據計算環境
以 Kubernetes 部屬 Spark 大數據計算環境以 Kubernetes 部屬 Spark 大數據計算環境
以 Kubernetes 部屬 Spark 大數據計算環境
 
Setup Hybrid Clusters Using Kubernetes Federation
Setup Hybrid Clusters Using Kubernetes FederationSetup Hybrid Clusters Using Kubernetes Federation
Setup Hybrid Clusters Using Kubernetes Federation
 
基於 K8S 開發的 FaaS 專案 - riff
基於 K8S 開發的 FaaS 專案 - riff基於 K8S 開發的 FaaS 專案 - riff
基於 K8S 開發的 FaaS 專案 - riff
 
使用 Prometheus 監控 Kubernetes Cluster
使用 Prometheus 監控 Kubernetes Cluster 使用 Prometheus 監控 Kubernetes Cluster
使用 Prometheus 監控 Kubernetes Cluster
 
Extend the Kubernetes API with CRD and Custom API Server
Extend the Kubernetes API with CRD and Custom API ServerExtend the Kubernetes API with CRD and Custom API Server
Extend the Kubernetes API with CRD and Custom API Server
 
利用K8S實現高可靠應用
利用K8S實現高可靠應用利用K8S實現高可靠應用
利用K8S實現高可靠應用
 
Integrate Kubernetes into CORD(Central Office Re-architected as a Datacenter)
Integrate Kubernetes into CORD(Central Office Re-architected as a Datacenter)Integrate Kubernetes into CORD(Central Office Re-architected as a Datacenter)
Integrate Kubernetes into CORD(Central Office Re-architected as a Datacenter)
 
Virtualization inside kubernetes
Virtualization inside kubernetesVirtualization inside kubernetes
Virtualization inside kubernetes
 
利用K8S實現高可靠應用
利用K8S實現高可靠應用利用K8S實現高可靠應用
利用K8S實現高可靠應用
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Cantainer CI/ CD with Kubernetes

  • 2. Agenda Introduction of Continuous Integration and Continuous Deployment/Delivery - What is CI/CD? - Run CI/CD with Kubernetes? Setup Jenkins with Kubernetes - Setup minikube & jenkins - Add kubernetes in jenkins - Test Summary 2
  • 3. Introduction of Continuous Integration and Continuous Delivery (CI/CD) What is CI/CD and Why need that?
  • 4. Continuous Integration - 「 持續整合 」 目的在儘快讓新功能的程式碼整合到現存的基礎程式庫(codebase) 中來進行測試。 Continuous Deploy - 「 持續部署 」 的目的就是要讓軟體可以快速自動部署到不同的環境, 至於有多少環境需要部署則 會根據不同公司的持續交付管線(pipeline) 的設計而定。 Continuous Delivery - 「 持續交付 」 是將新的特性儘快交付到最終使用者(end-user) 的手中 。 簡單來說就是盡量減少手動人力,將一些日常工作交給自動化工具。例如:環境建置、單元測試、日 誌紀錄、產品部署。 What is CI/CD? 引用自: 山姆鍋對持續整合、持續部署、持續交付的定義 DevOps:持續整合&持續交付(Docker、CircleCI、AWS)
  • 5. CI/CD 流程範例 引用自: 安德魯的部落格- 架構師觀點:你需要什麼樣的CI/CD?
  • 6. Run CI/CD with Kubernetes 引用自: Achieving CI/CD with Kubernetes Jenkins 透過 Kubernetes plugin 操作 kubernetes cluster 建立 pod (slaves) 來執 行 CI/CD 任務。 Pod 上使用 jenkins/jnlp-slave image,啟動 jnlp java slave 程式,連接 jenkins master。 當完成 CI/CD 任務後,該 pod 自動從 kubernetes cluster 中刪除,釋放資源。
  • 7. Setup Jenkins with Kubernetes Use kubernetes-plugin in jenkins
  • 8. Setup Environment (Minikube) Host Machine Virtual Machine (Minikube) Docker Container (Jenkins Master) Kubernetes Pod (Jenkins Slave) Kubernetes Pod (Jenkins Slave) Kubernetes Pod (Jenkins Slave) Kubernetes Pod (Jenkins Slave)
  • 9. Install minikube root@ycheng:/home/ycheng# curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-ubuntu16.04 > /usr/local/bin/docker-machine-driver-kvm root@ycheng:/home/ycheng# curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.22.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ root@ycheng:/home/ycheng# curl -O "https://storage.googleapis.com/kubernetes-release/release/v1.7.8/bin/linux/amd64/kubectl" root@ycheng:/home/ycheng# chmod +x kubectl && sudo mv kubectl /usr/local/bin/ root@ycheng:/home/ycheng# minikube start --vm-driver=kvm Starting local Kubernetes v1.7.5 cluster... Starting VM... Getting VM IP address... Moving files into cluster... Setting up certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... Kubectl is now configured to use the cluster.
  • 10. Run jenkins docker root@ycheng:/home/ycheng# minikube ssh _ _ _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |_ __ /' _ ` _ `| |/' _ `| || , < ( ) ( )| '_` /'__` | ( ) ( ) || || ( ) || || |` | (_) || |_) )( ___/ (_) (_) (_)(_)(_) (_)(_)(_) (_)`___/'(_,__/'`____) $ pwd /home/docker $ mkdir /home/docker/jenkins_home $ chmod 777 /home/docker/jenkins_home $ mkdir /home/docker/jenkins_volume $ chmod 777 /home/docker/jenkins_volume $ docker create --name jenkins-k8s jenkins:2.60.3 Unable to find image 'jenkins:2.60.3' locally 2.60.3: Pulling from library/jenkins 3e17c6eae66c: Pull complete …. Status: Downloaded newer image for jenkins:2.60.3 6f8aef4da1a9ba669e7630ef5deac86c7e15d992ba9a592ff8dca251c4c2c611
  • 11. Run jenkins docker $ docker run -d --volumes-from jenkins-k8s -p 8080:8080 -p 50000:50000 -v /home/docker/jenkins_home:/var/jenkins_home jenkins:2.60.3 9107e83bc474e7160fda33c9a52888228ece1e6ad6dd810fca3ac36493b14311 $ docker logs 9107e83bc474e7160fda33c9a52888228ece1e6ad6dd810fca3ac36493b14311 Running from: /usr/share/jenkins/jenkins.war webroot: EnvVars.masterEnvVars.get("JENKINS_HOME") …. Jenkins initial setup is required. An admin user has been created and a password generated. Please use the following password to proceed to installation: 2e058590dded40e5b3d7996246cf3be2 This may also be found at: /var/jenkins_home/secrets/initialAdminPassword ************************************************************* ************************************************************* ************************************************************* …. --> setting agent port for jnlp --> setting agent port for jnlp... done
  • 12. Enter jenkins web console
  • 23. Add kubernetes in jenkins (minikube)
  • 24. Add kubernetes in jenkins (minikube) root@ycheng:/home/ycheng# cat /root/.kube/config apiVersion: v1 clusters: - cluster: certificate-authority: /root/.minikube/ca.crt server: https://192.168.42.102:8443 name: minikube contexts: - context: cluster: minikube user: minikube name: minikube current-context: minikube kind: Config preferences: {} users: - name: minikube user: client-certificate: /root/.minikube/apiserver.crt client-key: /root/.minikube/apiserver.key
  • 25. Add kubernetes in jenkins (minikube) root@ycheng:/home/ycheng# cat /root/.minikube/ca.crt -----BEGIN CERTIFICATE----- MIIC5zCCAc+gAwIBAgIBATANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwptaW5p a3ViZUNBMB4XDTE3MTAxNjA3NDkyNVoXDTI3MTAxNDA3NDkyNVowFTETMBEGA1UE AxMKbWluaWt1YmVDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKv7 Yum+t342V8/gJw//sv77Gr/WguJ+0JrQISAIQF4Z+ABitbQ9nX0yoZLSTg80qIcy HDclGF1sQt7BDnfH+UtiCvDrEdMMAqwcYtKGdMW3El7uU6tisnjkwg3ZDflv+7y1 l7TZUMyc+ByWql2wm7h+D3b1f1IRPnevGBPKkTK1HYmIowe5nPzOXnHKU+1zSGmt wW6yBswE+xz/Y42YCu2qUNnkPKmVYeQCF8fH4SJRBzczfQ0ZLXmO9y/LtzOqedcV HQv+p0sklG6/ia8Poxn/HdZ3L30hzSGmkwQrwPqL8ty47HTVSx/oC1/jssYMN9mf CFwWinNjNKV7s2RtMekCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgKkMB0GA1UdJQQW MBQGCCsGAQUFBwMCBggrBgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 DQEBCwUAA4IBAQCUqJ8skMD5rZ50+h1IMCyek40eCEiwMW3EPqdiEtgr3oxzdurq foph2mA9mPyvG9sFmDLAxlXi+bWYXOmKd2I0I6wcejk0hSAEdVhLO925vXWMzVuO Liet0lHfOGL+zlTPANq858T6GhVC0WKeK/2moxgOTxHq/oTcpNmfXZHDKMvfmlxc WTwao8uewveZ3QJLaFOFnVWRNqgY/OhFRDW/Mpa4+vNf6r9QX5AUfFGY/0/03MSw +eohaKZsWbjxAPzwhvYw0lb7nRlJusjfn9lGWCI8b7W75UsPjnK6WOMe+7LXRuHI fGRiCBzg8n29bvefS05lsFEf8ZC2X76CyxAF -----END CERTIFICATE-----
  • 26. Add kubernetes in jenkins (minikube) root@ycheng:~# openssl pkcs12 -export -out ~/.minikube/minikube.pfx -inkey ~/.minikube/apiserver.key -in ~/.minikube/apiserver.crt -certfile ~/.minikube/ca.crt -passout pass:secret root@ycheng:~# cp -afpR ~/.minikube/minikube.pfx ~ root@ycheng:~# ls -l ./minikube.pfx -rw-r--r-- 1 root root 3293 10月 17 14:41 ./minikube.pfx
  • 27. Add kubernetes in jenkins (minikube)
  • 28. Add kubernetes in jenkins (minikube)
  • 29. Add kubernetes in jenkins (minikube)
  • 30. Add kubernetes in jenkins (minikube)
  • 33. Add shell command to test
  • 40. Check output root@ycheng:~# minikube ssh _ _ _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |_ __ /' _ ` _ `| |/' _ `| || , < ( ) ( )| '_` /'__` | ( ) ( ) || || ( ) || || |` | (_) || |_) )( ___/ (_) (_) (_)(_)(_) (_)(_)(_) (_)`___/'(_,__/'`____) $ ls -l ./jenkins_volume/ total 4 -rw-r--r-- 1 10000 10000 48 Oct 17 09:14 output $ cat ./jenkins_volume/output Tue Oct 17 09:14:39 UTC 2017 free-job-test-done
  • 41. Add another kubernetes cluster (2+1) Host Machine Virtual Machine (Minikube) Docker Container (Jenkins Master) Virtual Machine (Kubernetes node1 - master) Virtual Machine (Kubernetes node2 - minion) Virtual Machine (Kubernetes node3 - minion)
  • 42. kubernetes cluster 2+1 root@ycheng:~# virsh list Id Name State ---------------------------------------------------- 33 minikube running 34 kubernetes_node1 running 35 kubernetes_node2 running 36 kubernetes_node3 running root@node1:~# kubectl get node -o wide NAME STATUS AGE VERSION EXTERNAL-IP OS-IMAGE KERNEL-VERSION node1 Ready,master 161d v1.6.2 <none> Ubuntu 16.04.2 LTS 4.4.0-62-generic node2 Ready 161d v1.6.2 <none> Ubuntu 16.04.2 LTS 4.4.0-62-generic node3 Ready 161d v1.6.2 <none> Ubuntu 16.04.2 LTS 4.4.0-62-generic root@node1:~# kubectl create ns jenkins namespace "jenkins" created root@node1:~# showmount -e 192.168.2.254 Export list for 192.168.2.254: /root/jenkins_output *
  • 43. Test script and data on NFS server root@ycheng:~/jenkins_output# ls -l total 4 drwxrwxrwx 3 ycheng ycheng 4096 10月 19 17:36 iostat_analyzer_for_jenkins root@ycheng:~/jenkins_output# ls -l ./iostat_analyzer_for_jenkins/ total 40 -rwxrwxr-x 1 ycheng ycheng 527 10月 19 17:19 combine_iostat_files.sh -rwxrwxrwx 1 ycheng ycheng 13542 10月 19 17:19 iostat_analysis_io_req.sh -rwxrwxr-x 1 ycheng ycheng 10079 10月 19 11:15 split_by_day.sh drwxrwxrwx 2 ycheng ycheng 4096 10月 19 17:38 rawdata
  • 56. Summary Continuous Integration Continuous Deploy Continuous Delivery CI/CD with Kubernetes Other CI/CD Tools : - Travis CI - Circle CI - Drone.io - gitlab - & more...
  • 58. www.inwinstack.com Thank You! 迎 棧 科 技 股 份 有 限 公 司