Continuous Integration and Application Deployment with the Kubernetes Technology Student: Radek Šmíd Supervisor: Ing
Total Page:16
File Type:pdf, Size:1020Kb
ASSIGNMENT OF BACHELOR’S THESIS Title: Continuous integration and application deployment with the Kubernetes technology Student: Radek Šmíd Supervisor: Ing. Jan Trdlička, Ph.D. Study Programme: Informatics Study Branch: Computer Security and Information technology Department: Department of Computer Systems Validity: Until the end of summer semester 2020/21 Instructions Learn about the Kubernetes technology and available commercial and open-source deployment tools suitable for this technology. Compare features of individual open-source deployment tools. Design a suitable solution for application deployment using some of these open-source tools and try to implement this solution. Test the functionality of your solution on a suitable containerized application and try to compare your solution with available commercial solutions (if possible under trial licenses). References Will be provided by the supervisor. prof. Ing. Pavel Tvrdík, CSc. doc. RNDr. Ing. Marcel Jiřina, Ph.D. Head of Department Dean Prague October 22, 2019 CZECH TECHNICAL UNIVERSITY IN PRAGUE Faculty of Information Technology F8 Department of Computer Systems Bachelor’s Thesis Continuous integration and application deployment with the Kubernetes technology Radek Šmíd Květen 2020 https://gitlab.fit.cvut.cz/smidrad1/ci-cd-pipeline-with-kubernetes Supervisor: Ing. Trdlička Jan Ph.D. Acknowledgement / Declaration I would like to sincerely thank my I hereby declare that the presented supervisor Ing. Jan Trdlička, Ph.D. thesis is my own work and that I have His guidance and support have been cited all sources of information in accor- beyond excellent. dance with the Guideline for adhering to ethical principles when elaborating an academic final thesis. I acknowledge that my thesis is sub- ject to the rights and obligations stipu- lated by the Act No. 121/2000 Coll., the Copyright Act, as amended, in particu- lar that the Czech Technical University in Prague has the right to conclude a license agreement on the utilization of this thesis as a school work under the provisions of Article 60 (1) of the Act. In Prague 28. 5. 2020 ........................................ iii Abstrakt / Abstract Poslední dobou by téměř každý chtěl It seems nearly everyone would like to své aplikace nasadit do Kubernetes. deploy to Kubernetes nowadays. To effi- Jenže pro plné využití Kubernetes ciently leverage the power of Kubernetes je třeba přijmout s otevřenou náručí one must first fully embrace continuous postupy průběžné integrace (CI) a na- integration (CI) and deployment (CD) sazení (CD). Je třeba CI/CD pipeline. practices. A CI/CD pipeline is needed. Ale k dispozici je až zdrcující množ- But there is an overwhelming amount ství open-source nástrojů, kde každý of open-source tools that cover various pokrývá různé části celého procesu. parts of the whole process. Následující text vysvětlí základy tech- The following text explains the basics nologií, kterých bude pro pipeline třeba. of the underlying technologies needed A následně shrne některé z populárních for a pipeline deploying to Kubernetes. open-source nástrojů využívaných pro And subsequently summarizes some of CI/CD. the popular open-source tools used for Z open-source nástrojů navrhneme CI/CD. pipeline. Závěrečné porovnání možných Then it designs a working pipeline řešení (včetně proprietárních) poskytne from the researched tools. Finally, čtenáři konkrétní tipy a rady ohledně it summarizes some of the possible vytváření vlastní pipeline. pipelines (including proprietary) and provides the reader with specific bits of Klíčová slova: Open-source CI/CD, advice on how to implement a pipeline. Kubernetes, CI/CD pipeline, Mikro- služby, Průběžná integrace, Průběžné Keywords: Open-source CI/CD, nasazení, Nepřetržitá integrace a nasa- Kubernetes, CI/CD pipeline, Microser- zení. vices, Continuous integration, Continu- Překlad titulu: Nepřetržitá integrace ous delivery, Continuous deployment. a nasazení aplikací s technologií Kuber- netes iv Contents / 1 Introduction ........................1 4.4.3 Concourse ................ 19 2 Technology ..........................2 4.4.4 Jenkins ................... 19 2.1 Microservice architecture ........2 4.4.5 Jenkins Blue Ocean ...... 19 2.2 Sample microservice 4.5 CI & CD tools ................. 20 application .......................4 4.5.1 Drone ..................... 20 2.2.1 DeathStarBench ...........4 4.5.2 GoCD .................... 20 2.2.2 Sock Shop ..................4 4.5.3 Agola ..................... 20 2.2.3 TeaStore....................4 4.5.4 Tekton.................... 21 2.3 Docker & containerization .......5 4.5.5 Jenkins X ................ 21 2.3.1 Docker engine ..............5 4.6 CD tools........................ 21 2.3.2 Docker image...............6 4.6.1 Argo CD ................. 21 2.3.3 Dockerfile...................6 4.6.2 Flux ...................... 22 2.3.4 Docker registry.............6 4.6.3 Flagger ................... 22 2.3.5 Docker container ...........7 4.6.4 Keptn..................... 22 2.4 Kubernetes & orchestration .....7 4.6.5 Spinnaker................. 22 2.4.1 Imperative vs declarative ..7 4.7 Container registry manager ... 23 2.4.2 Kubernetes nodes ..........8 4.7.1 Harbor.................... 23 2.4.3 Pods, deployments, 4.7.2 Portus .................... 23 services .....................9 4.7.3 Project Quay ............. 23 2.4.4 Kubernetes architecture ...9 4.8 Code quality tools ............. 24 3 Continuous integration & con- 4.8.1 Clair ...................... 24 tinuous deployment .............. 11 4.8.2 Anchore Engine .......... 24 3.1 Continuous integration ........ 11 4.8.3 SonarQube ............... 24 3.2 Continuous delivery............ 12 4.9 Monitoring ..................... 25 3.3 Continuous deployment........ 12 4.9.1 Kubernetes dashboard ... 25 3.4 CI/CD & Kubernetes .......... 12 4.9.2 Prometheus .............. 25 3.4.1 Git repository manager .. 12 4.9.3 Graphana ................ 25 3.4.2 Continuous integration 4.9.4 cAdvisor .................. 26 & Kubernetes ............ 13 4.9.5 Fluentd ................... 26 3.4.3 Registry or repository? .. 13 4.10 Other useful tools .............. 26 3.4.4 GitOps ................... 13 4.10.1 Helm...................... 26 3.4.5 Continuous deploy- 4.10.2 Falco...................... 27 ment & Kubernetes ...... 14 4.10.3 Utilities & other help- 3.4.6 Monitoring & Kuber- ful projects ............... 27 netes ...................... 14 5 Open-source CI/CD pipeline 4 Open-source tools ................ 15 design ............................. 28 4.1 Methodology ................... 15 5.1 Test enviroment ................ 28 4.2 All the parts of a pipeline ..... 16 5.1.1 Teastore breakdown ..... 28 4.3 Git managers & Issues ......... 17 5.1.2 Kind ...................... 29 4.3.1 Gitlab .................... 17 5.2 Only GitLab pipeline .......... 30 4.3.2 Gitea ..................... 17 5.2.1 GitLab Runners.......... 30 4.3.3 Gogs ...................... 17 5.2.2 GitLab CI ................ 31 4.3.4 Phabricator .............. 18 5.2.3 Pros & cons .............. 33 4.4 CI tools......................... 18 5.3 Mixed tools pipeline ........... 34 4.4.1 Buildbot .................. 18 5.3.1 Gitea ..................... 34 4.4.2 Travis CI ................. 18 5.3.2 Drone ..................... 35 v 5.3.3 Harbor & Clair........... 36 5.3.4 Deployment .............. 36 5.3.5 Flux ...................... 37 5.3.6 Pros & cons .............. 37 6 Proprietary vs. open-source CI/CD pipeline solution........... 38 6.1 Proprietary solutions .......... 38 6.1.1 Managed Kubernetes & external tools .......... 38 6.1.2 Cloud provider’s way .... 39 6.1.3 Openshift................. 39 6.1.4 GitHub Actions .......... 39 6.2 Pipeline comparison ........... 40 6.3 Discussion ...................... 41 6.3.1 In practice................ 41 6.3.2 Developer at the center.. 41 6.3.3 Cloud controller.......... 41 6.3.4 Caching CI & testing .... 41 6.3.5 Docker in Docker ........ 42 6.3.6 Helm Charts ............. 42 6.3.7 Consider GitOps ......... 42 7 Conclusion ........................ 43 A Dictionary ......................... 45 B Tools honorable mentions ........ 46 References ........................ 48 vi / Figures 2.1. Monolithic vs microservice architecture .......................2 2.2. Microservice scaling ..............3 2.3. Containerization vs virtual machines ..........................5 2.4. Docker engine ....................6 2.5. Imperative administration .......8 2.6. Declarative administration.......8 2.7. Kubernetes architecture .........9 3.1. GitOps diagram. ............... 14 5.1. TeaStore architecture .......... 29 5.2. Kubernetes in Docker archi- tecture .......................... 29 5.3. Gitlab CI/CD workflow for Teastore ........................ 31 5.4. A simple example of the .gitlab-ci.yml syntax ........... 32 5.5. GitLab UI of a pipeline ........ 32 5.6. A simple artifact and Con- tainer Registry configuration in .gitlab-ci.yml ................ 33 5.7. Drone UI of a pipeline ......... 34 5.8. A sample of a .drone-ci.yml file syntax. ...................... 35 5.9. Drone UI of a pipeline ......... 36 6.1. Idividual tools vs all-in-one solution ......................... 40 vii Chapter 1 Introduction Is it possible to create a fully-featured pipeline deploying to Kubernetes only with open-source tools? Kubernetes. The seventh most contributed project on GitHub has caused quite a buzz in the IT world. Kubernetes makes it possible to build fault-tolerant, automatically scaling, cost-efficient systems. Who wouldn’t want that? Naturally, everything