├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── arc ├── README.md ├── deployment.yaml ├── namespace.yaml └── service.yaml ├── argo ├── README.md ├── deployment.yaml ├── namespace.yaml └── service.yaml ├── flagger ├── README.md ├── canary.yaml ├── deployment.yaml ├── hpa.yaml ├── ingress.yaml └── namespace.yaml ├── flux ├── README.md ├── deployment.yaml ├── namespace.yaml └── service.yaml ├── setup.sh └── terraform ├── README.md ├── aks-k8s-cluster.tf ├── install_terraform.sh ├── outputs.tf ├── terraform.tfvars └── variables.tf /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Codeowners for these exercise files: 2 | # * (asterisk) deotes "all files and folders" 3 | # Example: * @producer @instructor 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ## Issue Overview 9 | 10 | 11 | ## Describe your environment 12 | 13 | 14 | ## Steps to Reproduce 15 | 16 | 1. 17 | 2. 18 | 3. 19 | 4. 20 | 21 | ## Expected Behavior 22 | 23 | 24 | ## Current Behavior 25 | 26 | 27 | ## Possible Solution 28 | 29 | 30 | ## Screenshots / Video 31 | 32 | 33 | ## Related Issues 34 | 35 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | .tmp 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | Contribution Agreement 3 | ====================== 4 | 5 | This repository does not accept pull requests (PRs). All pull requests will be closed. 6 | 7 | However, if any contributions (through pull requests, issues, feedback or otherwise) are provided, as a contributor, you represent that the code you submit is your original work or that of your employer (in which case you represent you have the right to bind your employer). By submitting code (or otherwise providing feedback), you (and, if applicable, your employer) are licensing the submitted code (and/or feedback) to LinkedIn and the open source community subject to the BSD 2-Clause license. 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LinkedIn Learning Exercise Files License Agreement 2 | ================================================== 3 | 4 | This License Agreement (the "Agreement") is a binding legal agreement 5 | between you (as an individual or entity, as applicable) and LinkedIn 6 | Corporation (“LinkedIn”). By downloading or using the LinkedIn Learning 7 | exercise files in this repository (“Licensed Materials”), you agree to 8 | be bound by the terms of this Agreement. If you do not agree to these 9 | terms, do not download or use the Licensed Materials. 10 | 11 | 1. License. 12 | - a. Subject to the terms of this Agreement, LinkedIn hereby grants LinkedIn 13 | members during their LinkedIn Learning subscription a non-exclusive, 14 | non-transferable copyright license, for internal use only, to 1) make a 15 | reasonable number of copies of the Licensed Materials, and 2) make 16 | derivative works of the Licensed Materials for the sole purpose of 17 | practicing skills taught in LinkedIn Learning courses. 18 | - b. Distribution. Unless otherwise noted in the Licensed Materials, subject 19 | to the terms of this Agreement, LinkedIn hereby grants LinkedIn members 20 | with a LinkedIn Learning subscription a non-exclusive, non-transferable 21 | copyright license to distribute the Licensed Materials, except the 22 | Licensed Materials may not be included in any product or service (or 23 | otherwise used) to instruct or educate others. 24 | 25 | 2. Restrictions and Intellectual Property. 26 | - a. You may not to use, modify, copy, make derivative works of, publish, 27 | distribute, rent, lease, sell, sublicense, assign or otherwise transfer the 28 | Licensed Materials, except as expressly set forth above in Section 1. 29 | - b. Linkedin (and its licensors) retains its intellectual property rights 30 | in the Licensed Materials. Except as expressly set forth in Section 1, 31 | LinkedIn grants no licenses. 32 | - c. You indemnify LinkedIn and its licensors and affiliates for i) any 33 | alleged infringement or misappropriation of any intellectual property rights 34 | of any third party based on modifications you make to the Licensed Materials, 35 | ii) any claims arising from your use or distribution of all or part of the 36 | Licensed Materials and iii) a breach of this Agreement. You will defend, hold 37 | harmless, and indemnify LinkedIn and its affiliates (and our and their 38 | respective employees, shareholders, and directors) from any claim or action 39 | brought by a third party, including all damages, liabilities, costs and 40 | expenses, including reasonable attorneys’ fees, to the extent resulting from, 41 | alleged to have resulted from, or in connection with: (a) your breach of your 42 | obligations herein; or (b) your use or distribution of any Licensed Materials. 43 | 44 | 3. Open source. This code may include open source software, which may be 45 | subject to other license terms as provided in the files. 46 | 47 | 4. Warranty Disclaimer. LINKEDIN PROVIDES THE LICENSED MATERIALS ON AN “AS IS” 48 | AND “AS AVAILABLE” BASIS. LINKEDIN MAKES NO REPRESENTATION OR WARRANTY, 49 | WHETHER EXPRESS OR IMPLIED, ABOUT THE LICENSED MATERIALS, INCLUDING ANY 50 | REPRESENTATION THAT THE LICENSED MATERIALS WILL BE FREE OF ERRORS, BUGS OR 51 | INTERRUPTIONS, OR THAT THE LICENSED MATERIALS ARE ACCURATE, COMPLETE OR 52 | OTHERWISE VALID. TO THE FULLEST EXTENT PERMITTED BY LAW, LINKEDIN AND ITS 53 | AFFILIATES DISCLAIM ANY IMPLIED OR STATUTORY WARRANTY OR CONDITION, INCLUDING 54 | ANY IMPLIED WARRANTY OR CONDITION OF MERCHANTABILITY OR FITNESS FOR A 55 | PARTICULAR PURPOSE, AVAILABILITY, SECURITY, TITLE AND/OR NON-INFRINGEMENT. 56 | YOUR USE OF THE LICENSED MATERIALS IS AT YOUR OWN DISCRETION AND RISK, AND 57 | YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGE THAT RESULTS FROM USE OF THE 58 | LICENSED MATERIALS TO YOUR COMPUTER SYSTEM OR LOSS OF DATA. NO ADVICE OR 59 | INFORMATION, WHETHER ORAL OR WRITTEN, OBTAINED BY YOU FROM US OR THROUGH OR 60 | FROM THE LICENSED MATERIALS WILL CREATE ANY WARRANTY OR CONDITION NOT 61 | EXPRESSLY STATED IN THESE TERMS. 62 | 63 | 5. Limitation of Liability. LINKEDIN SHALL NOT BE LIABLE FOR ANY INDIRECT, 64 | INCIDENTAL, SPECIAL, PUNITIVE, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING 65 | BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER 66 | INTANGIBLE LOSSES . IN NO EVENT WILL LINKEDIN'S AGGREGATE LIABILITY TO YOU 67 | EXCEED $100. THIS LIMITATION OF LIABILITY SHALL: 68 | - i. APPLY REGARDLESS OF WHETHER (A) YOU BASE YOUR CLAIM ON CONTRACT, TORT, 69 | STATUTE, OR ANY OTHER LEGAL THEORY, (B) WE KNEW OR SHOULD HAVE KNOWN ABOUT 70 | THE POSSIBILITY OF SUCH DAMAGES, OR (C) THE LIMITED REMEDIES PROVIDED IN THIS 71 | SECTION FAIL OF THEIR ESSENTIAL PURPOSE; AND 72 | - ii. NOT APPLY TO ANY DAMAGE THAT LINKEDIN MAY CAUSE YOU INTENTIONALLY OR 73 | KNOWINGLY IN VIOLATION OF THESE TERMS OR APPLICABLE LAW, OR AS OTHERWISE 74 | MANDATED BY APPLICABLE LAW THAT CANNOT BE DISCLAIMED IN THESE TERMS. 75 | 76 | 6. Termination. This Agreement automatically terminates upon your breach of 77 | this Agreement or termination of your LinkedIn Learning subscription. On 78 | termination, all licenses granted under this Agreement will terminate 79 | immediately and you will delete the Licensed Materials. Sections 2-7 of this 80 | Agreement survive any termination of this Agreement. LinkedIn may discontinue 81 | the availability of some or all of the Licensed Materials at any time for any 82 | reason. 83 | 84 | 7. Miscellaneous. This Agreement will be governed by and construed in 85 | accordance with the laws of the State of California without regard to conflict 86 | of laws principles. The exclusive forum for any disputes arising out of or 87 | relating to this Agreement shall be an appropriate federal or state court 88 | sitting in the County of Santa Clara, State of California. If LinkedIn does 89 | not act to enforce a breach of this Agreement, that does not mean that 90 | LinkedIn has waived its right to enforce this Agreement. The Agreement does 91 | not create a partnership, agency relationship, or joint venture between the 92 | parties. Neither party has the power or authority to bind the other or to 93 | create any obligation or responsibility on behalf of the other. You may not, 94 | without LinkedIn’s prior written consent, assign or delegate any rights or 95 | obligations under these terms, including in connection with a change of 96 | control. Any purported assignment and delegation shall be ineffective. The 97 | Agreement shall bind and inure to the benefit of the parties, their respective 98 | successors and permitted assigns. If any provision of the Agreement is 99 | unenforceable, that provision will be modified to render it enforceable to the 100 | extent possible to give effect to the parties’ intentions and the remaining 101 | provisions will not be affected. This Agreement is the only agreement between 102 | you and LinkedIn regarding the Licensed Materials, and supersedes all prior 103 | agreements relating to the Licensed Materials. 104 | 105 | Last Updated: March 2019 106 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2021 LinkedIn Corporation 2 | All Rights Reserved. 3 | 4 | Licensed under the LinkedIn Learning Exercise File License (the "License"). 5 | See LICENSE in the project root for license information. 6 | 7 | ATTRIBUTIONS: 8 | 9 | Kubernetes 10 | https://github.com/kubernetes/kubernetes 11 | Lincense: Apache License Version 2.0 12 | https://www.apache.org/licenses/LICENSE-2.0 13 | 14 | 15 | Please note, this project may automatically load third party code from external 16 | repositories (for example, NPM modules, Composer packages, or other dependencies). 17 | If so, such third party code may be subject to other license terms than as set 18 | forth above. In addition, such third party code may also depend on and load 19 | multiple tiers of dependencies. Please review the applicable licenses of the 20 | additional dependencies. 21 | 22 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 23 | 24 | Apache License 25 | Version 2.0, January 2004 26 | https://www.apache.org/licenses/LICENSE-2.0 27 | 28 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 29 | 30 | 1. Definitions. 31 | 32 | "License" shall mean the terms and conditions for use, reproduction, 33 | and distribution as defined by Sections 1 through 9 of this document. 34 | 35 | "Licensor" shall mean the copyright owner or entity authorized by 36 | the copyright owner that is granting the License. 37 | 38 | "Legal Entity" shall mean the union of the acting entity and all 39 | other entities that control, are controlled by, or are under common 40 | control with that entity. For the purposes of this definition, 41 | "control" means (i) the power, direct or indirect, to cause the 42 | direction or management of such entity, whether by contract or 43 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 44 | outstanding shares, or (iii) beneficial ownership of such entity. 45 | 46 | "You" (or "Your") shall mean an individual or Legal Entity 47 | exercising permissions granted by this License. 48 | 49 | "Source" form shall mean the preferred form for making modifications, 50 | including but not limited to software source code, documentation 51 | source, and configuration files. 52 | 53 | "Object" form shall mean any form resulting from mechanical 54 | transformation or translation of a Source form, including but 55 | not limited to compiled object code, generated documentation, 56 | and conversions to other media types. 57 | 58 | "Work" shall mean the work of authorship, whether in Source or 59 | Object form, made available under the License, as indicated by a 60 | copyright notice that is included in or attached to the work 61 | (an example is provided in the Appendix below). 62 | 63 | "Derivative Works" shall mean any work, whether in Source or Object 64 | form, that is based on (or derived from) the Work and for which the 65 | editorial revisions, annotations, elaborations, or other modifications 66 | represent, as a whole, an original work of authorship. For the purposes 67 | of this License, Derivative Works shall not include works that remain 68 | separable from, or merely link (or bind by name) to the interfaces of, 69 | the Work and Derivative Works thereof. 70 | 71 | "Contribution" shall mean any work of authorship, including 72 | the original version of the Work and any modifications or additions 73 | to that Work or Derivative Works thereof, that is intentionally 74 | submitted to Licensor for inclusion in the Work by the copyright owner 75 | or by an individual or Legal Entity authorized to submit on behalf of 76 | the copyright owner. For the purposes of this definition, "submitted" 77 | means any form of electronic, verbal, or written communication sent 78 | to the Licensor or its representatives, including but not limited to 79 | communication on electronic mailing lists, source code control systems, 80 | and issue tracking systems that are managed by, or on behalf of, the 81 | Licensor for the purpose of discussing and improving the Work, but 82 | excluding communication that is conspicuously marked or otherwise 83 | designated in writing by the copyright owner as "Not a Contribution." 84 | 85 | "Contributor" shall mean Licensor and any individual or Legal Entity 86 | on behalf of whom a Contribution has been received by Licensor and 87 | subsequently incorporated within the Work. 88 | 89 | 2. Grant of Copyright License. Subject to the terms and conditions of 90 | this License, each Contributor hereby grants to You a perpetual, 91 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 92 | copyright license to reproduce, prepare Derivative Works of, 93 | publicly display, publicly perform, sublicense, and distribute the 94 | Work and such Derivative Works in Source or Object form. 95 | 96 | 3. Grant of Patent License. Subject to the terms and conditions of 97 | this License, each Contributor hereby grants to You a perpetual, 98 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 99 | (except as stated in this section) patent license to make, have made, 100 | use, offer to sell, sell, import, and otherwise transfer the Work, 101 | where such license applies only to those patent claims licensable 102 | by such Contributor that are necessarily infringed by their 103 | Contribution(s) alone or by combination of their Contribution(s) 104 | with the Work to which such Contribution(s) was submitted. If You 105 | institute patent litigation against any entity (including a 106 | cross-claim or counterclaim in a lawsuit) alleging that the Work 107 | or a Contribution incorporated within the Work constitutes direct 108 | or contributory patent infringement, then any patent licenses 109 | granted to You under this License for that Work shall terminate 110 | as of the date such litigation is filed. 111 | 112 | 4. Redistribution. You may reproduce and distribute copies of the 113 | Work or Derivative Works thereof in any medium, with or without 114 | modifications, and in Source or Object form, provided that You 115 | meet the following conditions: 116 | 117 | (a) You must give any other recipients of the Work or 118 | Derivative Works a copy of this License; and 119 | 120 | (b) You must cause any modified files to carry prominent notices 121 | stating that You changed the files; and 122 | 123 | (c) You must retain, in the Source form of any Derivative Works 124 | that You distribute, all copyright, patent, trademark, and 125 | attribution notices from the Source form of the Work, 126 | excluding those notices that do not pertain to any part of 127 | the Derivative Works; and 128 | 129 | (d) If the Work includes a "NOTICE" text file as part of its 130 | distribution, then any Derivative Works that You distribute must 131 | include a readable copy of the attribution notices contained 132 | within such NOTICE file, excluding those notices that do not 133 | pertain to any part of the Derivative Works, in at least one 134 | of the following places: within a NOTICE text file distributed 135 | as part of the Derivative Works; within the Source form or 136 | documentation, if provided along with the Derivative Works; or, 137 | within a display generated by the Derivative Works, if and 138 | wherever such third-party notices normally appear. The contents 139 | of the NOTICE file are for informational purposes only and 140 | do not modify the License. You may add Your own attribution 141 | notices within Derivative Works that You distribute, alongside 142 | or as an addendum to the NOTICE text from the Work, provided 143 | that such additional attribution notices cannot be construed 144 | as modifying the License. 145 | 146 | You may add Your own copyright statement to Your modifications and 147 | may provide additional or different license terms and conditions 148 | for use, reproduction, or distribution of Your modifications, or 149 | for any such Derivative Works as a whole, provided Your use, 150 | reproduction, and distribution of the Work otherwise complies with 151 | the conditions stated in this License. 152 | 153 | 5. Submission of Contributions. Unless You explicitly state otherwise, 154 | any Contribution intentionally submitted for inclusion in the Work 155 | by You to the Licensor shall be under the terms and conditions of 156 | this License, without any additional terms or conditions. 157 | Notwithstanding the above, nothing herein shall supersede or modify 158 | the terms of any separate license agreement you may have executed 159 | with Licensor regarding such Contributions. 160 | 161 | 6. Trademarks. This License does not grant permission to use the trade 162 | names, trademarks, service marks, or product names of the Licensor, 163 | except as required for reasonable and customary use in describing the 164 | origin of the Work and reproducing the content of the NOTICE file. 165 | 166 | 7. Disclaimer of Warranty. Unless required by applicable law or 167 | agreed to in writing, Licensor provides the Work (and each 168 | Contributor provides its Contributions) on an "AS IS" BASIS, 169 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 170 | implied, including, without limitation, any warranties or conditions 171 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 172 | PARTICULAR PURPOSE. You are solely responsible for determining the 173 | appropriateness of using or redistributing the Work and assume any 174 | risks associated with Your exercise of permissions under this License. 175 | 176 | 8. Limitation of Liability. In no event and under no legal theory, 177 | whether in tort (including negligence), contract, or otherwise, 178 | unless required by applicable law (such as deliberate and grossly 179 | negligent acts) or agreed to in writing, shall any Contributor be 180 | liable to You for damages, including any direct, indirect, special, 181 | incidental, or consequential damages of any character arising as a 182 | result of this License or out of the use or inability to use the 183 | Work (including but not limited to damages for loss of goodwill, 184 | work stoppage, computer failure or malfunction, or any and all 185 | other commercial damages or losses), even if such Contributor 186 | has been advised of the possibility of such damages. 187 | 188 | 9. Accepting Warranty or Additional Liability. While redistributing 189 | the Work or Derivative Works thereof, You may choose to offer, 190 | and charge a fee for, acceptance of support, warranty, indemnity, 191 | or other liability obligations and/or rights consistent with this 192 | License. However, in accepting such obligations, You may act only 193 | on Your own behalf and on Your sole responsibility, not on behalf 194 | of any other Contributor, and only if You agree to indemnify, 195 | defend, and hold each Contributor harmless for any liability 196 | incurred by, or claims asserted against, such Contributor by reason 197 | of your accepting any such warranty or additional liability. 198 | 199 | END OF TERMS AND CONDITIONS 200 | 201 | APPENDIX: How to apply the Apache License to your work. 202 | 203 | To apply the Apache License to your work, attach the following 204 | boilerplate notice, with the fields enclosed by brackets "[]" 205 | replaced with your own identifying information. (Don't include 206 | the brackets!) The text should be enclosed in the appropriate 207 | comment syntax for the file format. We also recommend that a 208 | file or class name and description of purpose be included on the 209 | same "printed page" as the copyright notice for easier 210 | identification within third-party archives. 211 | 212 | Copyright [yyyy] [name of copyright owner] 213 | 214 | Licensed under the Apache License, Version 2.0 (the "License"); 215 | you may not use this file except in compliance with the License. 216 | You may obtain a copy of the License at 217 | 218 | http://www.apache.org/licenses/LICENSE-2.0 219 | 220 | Unless required by applicable law or agreed to in writing, software 221 | distributed under the License is distributed on an "AS IS" BASIS, 222 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 223 | See the License for the specific language governing permissions and 224 | limitations under the License. 225 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitOps Foundations 2 | This is the repository for the LinkedIn Learning course GitOps Foundations. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | ![GitOps Foundations][lil-thumbnail-url] 5 | 6 | If there is one constant in the software industry, it is the need for both speed and accuracy. GitOps can help fill both needs. GitOps is an operational model that extends DevOps with additional concepts that allow teams to accelerate the delivery of cloud native applications in a manner that is more consistent, reliable, transparent, and secure. In this course, instructor Kevin Bowersox walks you through the basics of the GitOps pattern, its key principles, and its practical use. Using hands-on demonstrations with Kubernetes, Kevin explains building blocks such as declarative configuration, automated change delivery, reconciliation, and more. Throughout the course, you’ll be introduced to a variety of tools you can use that take a GitOps approach, including Terraform, Argo CD, Flux, and Flagger. 7 | 8 | ## Instructions 9 | The course uses the Ubuntu operating system to power the hands-on demonstrations. If you are using a Windows workstation you can download and install a virtualization tool to run Ubuntu on a VM or alternatively you can use the [Windows Subsystem for Linux][wsl]. 10 | 11 | This repository contains a folder for each of the tools used within the course. Inside of each folder, you'll find the files for the example demonstrations pertaining to the tool and more information about the prerequisite technologies. 12 | 13 | ## Installing 14 | 1. To follow along with hands-on demonstrations, you must have the following accounts: 15 | - **GitHub** is used as the repository manager that hosts the git repositories used throughout the course. You can sign up for an account on the [GitHub][github] website. 16 | - **DockerHub** is used to store container images that will be ran throughout the course in specific examples. Create an account on the [DockerHub][docker-hub] website. 17 | - **Azure** is the cloud platform used to provision elastic infrastructure such as Kubernetes clusters. You can create a trial account on the [Azure][azure-site] website. 18 | - **CircleCi** is the continuous integration platform used in a single lesson in the course. If you choose to follow along with this lesson, you'll need an account on the platform. A trial account can be obtained on the [CircleCi][circle] website. 19 | 2. To use these exercise files, you must have the following installed: 20 | - **Docker** is used as the underlying container platform for building and running containers. You can download and install Docker for your platform using the [official installation guide][docker-install]. 21 | 4. Clone this repository into your local machine using the terminal (Mac), CMD (Windows), or a GUI tool like SourceTree. 22 | 5. After cloning the repository, login to DockerHub with the following command `docker login`. 23 | 6. Once logged into DockerHub execute the `setup.sh` script with the following command `./setup.sh [DockerHub Username]`. 24 | 25 | 26 | ### Instructor 27 | 28 | Kevin Bowersox 29 | 30 | Web application developer 31 | 32 | 33 | 34 | Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/kevin-bowersox). 35 | 36 | [lil-course-url]: https://www.linkedin.com/learning/gitops-foundations 37 | [lil-thumbnail-url]: https://cdn.lynda.com/course/2892009/2892009-1625008421822-16x9.jpg 38 | 39 | 40 | 41 | 42 | [0]: # (Replace these placeholder URLs with actual course URLs) 43 | 44 | [docker-hub]: https://hub.docker.com/ 45 | [azure-site]: https://azure.microsoft.com/en-us/ 46 | [circle]: https://circleci.com/ 47 | [docker-install]: https://docs.docker.com/engine/install/ 48 | [wsl]: https://docs.microsoft.com/en-us/windows/wsl/about 49 | [github]:https://github.com/ 50 | 51 | -------------------------------------------------------------------------------- /arc/README.md: -------------------------------------------------------------------------------- 1 | # Azure Arc Demonstration 2 | This directory contains the example materials used in the Azure Arc demonstration that is part of the LinkedIn Learning course `GitOps Foundations`. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | 5 | In this demonstration we deploy a containerized application onto a local k3s Kubernetes cluster using the Flux operator within Azure Arc's GitOps support. 6 | 7 | ## Required Tools 8 | 1. **Docker** is used as the underlying container platform for building and running containers. You can download and install Docker for your platform using the [official installation guide][docker-install]. 9 | 2. **k3d** is used to manage and establish the underlying k3s kubernetes cluster that runs ArgoCD. You can download and install k3d using their [getting started guide][k3d-start]. 10 | 3. **kubectl** is a command line tool used to run commands against the Kubernetes cluster. You can download and install kubectl by following the installation instructions on the [official site][kube-site]. 11 | 4. **Azure CLI** is a command line interface that is used with Azure Cloud platform. You can download and install the Azure CLI by following the instructions on the [official website][azurecli-start]. 12 | 5. **CircleCI** is the continuous integration platform used in a single lesson in the course. If you choose to follow along with this lesson, you'll need an account on the platform. A trial account can be obtained on the [CircleCi][circle] website. The configuration for the build can be found in the `.circleci` directory in the app repository. Configuration in the platform requires that a `DockerHub` context be established with `DOCKERHUB_USER` and `DOCKERHUB_PASSWORD` variables set respectively. 13 | 14 | ## Instructions 15 | This folder contains the example files for the Azure Arc demonstration. Prior to applying these manifests on the Kubernetes cluster with GitOps you must build and store the container images into DockerHub using these [instructions][setup-instructions]. After completing those instructions, follow along with the steps in the course to deploy the resources to the cluster. 16 | 17 | ## Commands 18 | The following commands are used in the demonstrations. They are provided within the readme file so that you can copy and paste them while working through the course. 19 | 20 | 1. Create a new cluster with k3d 21 | 22 | ``` 23 | k3d cluster create arccluster 24 | ``` 25 | 26 | 2. Patch a Kubernetes Deployment 27 | ``` 28 | kubectl patch deployment gitops-foundations --namespace argocd-exercise -p '{"spec":{"template":{"spec":{"containers":[{"name":"gitops-foundations","image":"[Your DockerHub ID goes here]/gitops-foundations:1.0"}]}}}}' 29 | ``` 30 | 31 | [0]: # (Replace these placeholder URLs with actual course URLs) 32 | 33 | [lil-course-url]: https://www.linkedin.com/learning/ 34 | [lil-thumbnail-url]: http:// 35 | [k3d-start]: https://k3d.io/#installation 36 | [docker-install]: https://docs.docker.com/engine/install/ 37 | [kube-site]: https://kubernetes.io/docs/tasks/tools/ 38 | [azurecli-start]: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli 39 | [setup-instructions]: https://github.com/LinkedInLearning/gitops-foundations-env-2892009#installing 40 | [circle]: https://circleci.com/ 41 | -------------------------------------------------------------------------------- /arc/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: gitops-foundations 5 | namespace: arc-exercise 6 | labels: 7 | app: gitops-foundations 8 | spec: 9 | replicas: 3 10 | selector: 11 | matchLabels: 12 | app: gitops-foundations 13 | template: 14 | metadata: 15 | labels: 16 | app: gitops-foundations 17 | spec: 18 | containers: 19 | - name: gitops-foundations 20 | image: {dockerHubUsername}/gitops-foundations:2.0 21 | imagePullPolicy: IfNotPresent 22 | ports: 23 | - containerPort: 8080 24 | livenessProbe: 25 | httpGet: 26 | path: /actuator/health 27 | port: 8080 28 | initialDelaySeconds: 5 29 | periodSeconds: 10 30 | failureThreshold: 2 31 | -------------------------------------------------------------------------------- /arc/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: arc-exercise 5 | -------------------------------------------------------------------------------- /arc/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: gitops-foundations 5 | namespace: arc-exercise 6 | spec: 7 | type: NodePort 8 | selector: 9 | app: gitops-foundations 10 | ports: 11 | - port: 8080 12 | targetPort: 8080 13 | nodePort: 30000 14 | -------------------------------------------------------------------------------- /argo/README.md: -------------------------------------------------------------------------------- 1 | # Argo CD Demonstration 2 | This directory contains the example materials used in the Argo CD demonstration that is part of the LinkedIn Learning course `GitOps Foundations`. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | In this demonstration we deploy a containerized application onto Argo CD using a GitOps approach. 5 | 6 | ## Required Tools 7 | 1. **Docker** is used as the underlying container platform for building and running containers. You can download and install Docker for your platform using the [official installation guide][docker-install]. 8 | 2. **k3d** is used to manage and establish the underlying k3s kubernetes cluster that runs Argo CD. You can download and install k3d using their [getting started guide][k3d-start]. 9 | 3. **kubectl** is a command line tool used to run commands against the Kubernetes cluster. You can download and install kubectl by following the installation instructions on the [official site][kube-site]. 10 | 4. **Argo CD** is the GitOps operator that runs in the cluster and applies the example manifests. You can download and install Argo CD by following the tools [getting started guide][argo-start]. 11 | 12 | ## Instructions 13 | This folder contains the example files for the Argo CD demonstration. Prior to applying these manifests on the Kubernetes cluster with GitOps you will must build and store the container images into DockerHub using these [instructions][setup-instructions]. After completing those instructions, follow along with the steps in the course to deploy the resources to the cluster. 14 | 15 | ## Commands 16 | The following commands are used in the demonstrations. They are provided within the readme file so that you can copy and paste them while working through the course. 17 | 18 | 1. Get Cluster Node IP with kubectl 19 | 20 | ``` 21 | kubectl get nodes -o wide 22 | ``` 23 | 24 | 2. Patch a Kubernetes Deployment 25 | ``` 26 | kubectl patch deployment gitops-foundations --namespace argocd-exercise -p '{"spec":{"template":{"spec":{"containers":[{"name":"gitops-foundations","image":"[Your DockerHub ID goes here]/gitops-foundations:1.0"}]}}}}' 27 | ``` 28 | 29 | [0]: # (Replace these placeholder URLs with actual course URLs) 30 | 31 | [lil-course-url]: https://www.linkedin.com/learning/ 32 | [lil-thumbnail-url]: http:// 33 | [k3d-start]: https://k3d.io/#installation 34 | [docker-install]: https://docs.docker.com/engine/install/ 35 | [kube-site]: https://kubernetes.io/docs/tasks/tools/ 36 | [argo-start]: https://argoproj.github.io/argo-cd/getting_started/ 37 | [setup-instructions]: https://github.com/LinkedInLearning/gitops-foundations-env-2892009#installing 38 | -------------------------------------------------------------------------------- /argo/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: gitops-foundations 5 | namespace: argocd-exercise 6 | labels: 7 | app: gitops-foundations 8 | spec: 9 | replicas: 3 10 | selector: 11 | matchLabels: 12 | app: gitops-foundations 13 | template: 14 | metadata: 15 | labels: 16 | app: gitops-foundations 17 | spec: 18 | containers: 19 | - name: gitops-foundations 20 | image: {dockerHubUsername}/gitops-foundations:1.0 21 | imagePullPolicy: IfNotPresent 22 | ports: 23 | - containerPort: 8080 24 | livenessProbe: 25 | httpGet: 26 | path: /actuator/health 27 | port: 8080 28 | initialDelaySeconds: 5 29 | periodSeconds: 10 30 | failureThreshold: 2 31 | -------------------------------------------------------------------------------- /argo/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: argocd-exercise 5 | -------------------------------------------------------------------------------- /argo/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: gitops-foundations 5 | namespace: argocd-exercise 6 | spec: 7 | type: NodePort 8 | selector: 9 | app: gitops-foundations 10 | ports: 11 | - port: 8080 12 | targetPort: 8080 13 | nodePort: 30000 14 | -------------------------------------------------------------------------------- /flagger/README.md: -------------------------------------------------------------------------------- 1 | # Flagger Demonstration 2 | This directory contains the example materials used in the Flagger demonstration that is part of the LinkedIn Learning course `GitOps Foundations`. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | In this demonstration we use a canary deployment to progressively deliver a containerized application onto an AKS Kubernetes cluster using Flagger. 5 | 6 | ## Required Tools 7 | 1. **Terraform** is used to provision the underlying Kubernetes cluster that runs the workloads of the example cloud native application. You can download and install Terraform for your platform using the [official installation guide][terraform-install]. 8 | 2. **kubectl** is a command line tool used to run commands against the Kubernetes cluster. You can download and install kubectl by following the installation instructions on the [official site][kube-site]. 9 | 3. **Azure CLI** is a command line interface that is used with Azure Cloud platform. You can download and install the Azure CLI by following the instructions on the [official website][azurecli-start]. 10 | 4. **Flux** is a continuous deployment tool that uses a GitOps approach to manage operations of workloads on a Kubernetes clusters. You can download and install Flux by following the instructions in the getting [started guide][flux-start]. 11 | 5. **Helm** is a package manager for Kubernetes. You can download and install the Helm by following the instructions on the [official website][helm-start]. 12 | 5. **Flagger** is a progressive delivery tool that can be used for advanced deployment procedures on Kubernetes clusters. You can download and install Flagger by following the instructions in the [getting started guide][flagger-start]. 13 | 14 | ## Instructions 15 | This folder contains the example files for the Flagger demonstration. Prior to applying these manifests on the Kubernetes cluster with GitOps you must build and store the container images into DockerHub using these [instructions][setup-instructions]. After completing those instructions, follow along with the steps in the course to deploy the resources to the cluster. 16 | 17 | Before starting the Flagger exercise, you must have provisioned a new kubernetes cluster on Azure with Terraform and have bootstrapped Flux in the cluster. Flux must be configured to sync to the flagger directory in this repository. `kubectl` should also be configured with the AKS cluster. 18 | 19 | Both Flagger and NGINX are installed using helm charts, so before starting the exercise make sure Helm is installed. 20 | 21 | ## Commands 22 | The following commands are used in the demonstrations. They are provided within the readme file so that you can copy and paste them while working through the course. 23 | 24 | 1. Add the NGINX Controller Helm Repository 25 | ``` 26 | helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx 27 | ``` 28 | 29 | 2. Create a Namespace for the NGINX Controller 30 | ``` 31 | kubectl create ns ingress-nginx 32 | ``` 33 | 34 | 3. Install the Controller into the Namespace 35 | ``` 36 | helm upgrade -i ingress-nginx ingress-nginx/ingress-nginx \ 37 | --namespace ingress-nginx \ 38 | --set controller.metrics.enabled=true \ 39 | --set controller.podAnnotations."prometheus\.io/scrape"=true \ 40 | --set controller.podAnnotations."prometheus\.io/port"=10254 41 | 42 | ``` 43 | 44 | 4. Add the Flagger Helm Repository 45 | ``` 46 | helm repo add flagger https://flagger.app 47 | ``` 48 | 49 | 5. Install Flagger using the Helm Chart and Configure it with Prometheus 50 | ``` 51 | helm upgrade -i flagger flagger/flagger \ 52 | --namespace ingress-nginx \ 53 | --set prometheus.install=true \ 54 | --set meshProvider=nginx 55 | ``` 56 | 57 | ``` 58 | http://{dockerHubUsername}.westus2.cloudapp.azure.com 59 | ``` 60 | 6. Create the Source Definition 61 | ``` 62 | flux create source git gitops-foundations \ 63 | --url=https://github.com/Kevin-Bowersox-Courses/gitops-foundations-env-2892009.git \ 64 | --branch=main \ 65 | --interval=30s \ 66 | --export > ./clusters/cluster1/gitops-foundations-source.yaml 67 | ``` 68 | 69 | 7. Create the Kustomization 70 | ``` 71 | flux create kustomization gitops-foundations \ 72 | --source=gitops-foundations \ 73 | --path=./flagger \ 74 | --prune=true \ 75 | --validation=client \ 76 | --interval=1m \ 77 | --export > ./clusters/cluster1/gitops-foundations-kustomization.yaml 78 | ``` 79 | 80 | 8. Install the Loadbalancer 81 | ``` 82 | helm upgrade -i flagger-loadtester flagger/loadtester --namespace flagger-exercise 83 | ``` 84 | 85 | 9. Watch the Canaries 86 | ``` 87 | watch kubectl get canaries --all-namespaces 88 | ``` 89 | 90 | 10. Describe the Canary Deployment 91 | ``` 92 | kubectl describe canary/gitops-foundations -n flagger-exercise 93 | ``` 94 | 95 | 96 | [0]: # (Replace these placeholder URLs with actual course URLs) 97 | 98 | [lil-course-url]: https://www.linkedin.com/learning/ 99 | [lil-thumbnail-url]: http:// 100 | [k3d-start]: https://k3d.io/#installation 101 | [docker-install]: https://docs.docker.com/engine/install/ 102 | [kube-site]: https://kubernetes.io/docs/tasks/tools/ 103 | [azurecli-start]: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli 104 | [setup-instructions]: https://github.com/LinkedInLearning/gitops-foundations-env-2892009#installing 105 | [flux-start]: https://fluxcd.io/docs/get-started/ 106 | [flagger-start]: https://docs.flagger.app/ 107 | [terraform-install]: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/azure-get-started 108 | [helm-start]: https://helm.sh/docs/intro/install/ 109 | 110 | 111 | -------------------------------------------------------------------------------- /flagger/canary.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: flagger.app/v1beta1 2 | kind: Canary 3 | metadata: 4 | name: gitops-foundations 5 | namespace: flagger-exercise 6 | spec: 7 | provider: nginx 8 | targetRef: 9 | apiVersion: apps/v1 10 | kind: Deployment 11 | name: gitops-foundations 12 | ingressRef: 13 | apiVersion: networking.k8s.io/v1beta1 14 | kind: Ingress 15 | name: gitops-foundations 16 | autoscalerRef: 17 | apiVersion: autoscaling/v2beta2 18 | kind: HorizontalPodAutoscaler 19 | name: gitops-foundations-hpa 20 | progressDeadlineSeconds: 60 21 | service: 22 | port: 80 23 | targetPort: 8080 24 | name: gitops-foundations-service 25 | analysis: 26 | interval: 10s 27 | threshold: 10 28 | maxWeight: 50 29 | stepWeight: 5 30 | # NGINX Prometheus checks 31 | metrics: 32 | - name: request-success-rate 33 | thresholdRange: 34 | min: 99 35 | interval: 1m 36 | webhooks: 37 | - name: acceptance-test 38 | type: pre-rollout 39 | url: http://flagger-loadtester.flagger-exercise/ 40 | timeout: 30s 41 | metadata: 42 | type: bash 43 | cmd: "curl -s gitops-foundations-service-canary:80 | grep ." 44 | - name: load-test 45 | url: http://flagger-loadtester.flagger-exercise/ 46 | timeout: 5s 47 | metadata: 48 | cmd: "hey -z 1m -q 10 -c 2 http://{dockerHubUsername}.westus2.cloudapp.azure.com/" 49 | -------------------------------------------------------------------------------- /flagger/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: gitops-foundations 5 | namespace: flagger-exercise 6 | labels: 7 | app: gitops-foundations 8 | spec: 9 | replicas: 3 10 | selector: 11 | matchLabels: 12 | app: gitops-foundations 13 | template: 14 | metadata: 15 | labels: 16 | app: gitops-foundations 17 | spec: 18 | containers: 19 | - name: gitops-foundations 20 | image: {dockerHubUsername}/gitops-foundations:1.0 21 | imagePullPolicy: IfNotPresent 22 | ports: 23 | - containerPort: 8080 24 | -------------------------------------------------------------------------------- /flagger/hpa.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: autoscaling/v2beta2 2 | kind: HorizontalPodAutoscaler 3 | metadata: 4 | name: gitops-foundations-hpa 5 | namespace: flagger-exercise 6 | spec: 7 | scaleTargetRef: 8 | apiVersion: apps/v1 9 | kind: Deployment 10 | name: gitops-foundations 11 | minReplicas: 2 12 | maxReplicas: 4 13 | metrics: 14 | - type: Resource 15 | resource: 16 | name: cpu 17 | target: 18 | type: Utilization 19 | averageUtilization: 99 20 | -------------------------------------------------------------------------------- /flagger/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: gitops-foundations 5 | namespace: flagger-exercise 6 | labels: 7 | app: gitops-foundations 8 | annotations: 9 | kubernetes.io/ingress.class: "nginx" 10 | spec: 11 | rules: 12 | - host: {dockerHubUsername}.westus2.cloudapp.azure.com 13 | http: 14 | paths: 15 | - backend: 16 | serviceName: gitops-foundations-service 17 | servicePort: 80 18 | -------------------------------------------------------------------------------- /flagger/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: flagger-exercise 5 | -------------------------------------------------------------------------------- /flux/README.md: -------------------------------------------------------------------------------- 1 | # Flux Demonstration 2 | This directory contains the example materials used in the Flux demonstration that is part of the LinkedIn Learning course `GitOps Foundations`. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | In this demonstration we deploy a containerized application onto an AKS Kubernetes cluster using the Flux operator. 5 | 6 | ## Required Tools 7 | 1. **Terraform** is used to provision the underlying Kubernetes cluster that runs the workloads of the example cloud native application. You can download and install Terraform for your platform using the [official installation guide][terraform-install]. 8 | 2. **kubectl** is a command line tool used to run commands against the Kubernetes cluster. You can download and install kubectl by following the installation instructions on the [official site][kube-site]. 9 | 3. **Azure CLI** is a command line interface that is used with Azure Cloud platform. You can download and install the Azure CLI by following the instructions on the [official website][azurecli-start]. 10 | 4. **Flux** is a continuous deployment tool that uses a GitOps approach to manage operations of workloads on a Kubernetes clusters. You can download and install Flux by following the instructions in the getting [started guide][flux-start]. 11 | 12 | 13 | ## Instructions 14 | This folder contains the example files for the Flux demonstration. Prior to applying these manifests on the Kubernetes cluster with GitOps you must build and store the container images into DockerHub using these [instructions][setup-instructions]. After completing those instructions, follow along with the steps in the course to deploy the resources to the cluster. 15 | 16 | The application will be made available on Azure via a Loadbalancer that uses some built in integration with Azure to establish a DNS label. The configuration of the service uses your DockerHub username to establish the DNS label and it will vary based on the region you have deployed the workload. It should look something like this: 17 | ``` 18 | [DockerHubId].[AzureRegion].cloudapp.azure.com 19 | ``` 20 | 21 | ## Commands 22 | The following commands are used in the demonstrations. They are provided within the readme file so that you can copy and paste them while working through the course. 23 | 24 | 1. Flux Installation Script 25 | 26 | ``` 27 | curl -s https://fluxcd.io/install.sh | sudo bash 28 | ``` 29 | 30 | 2. Bootstrap the Flux Config Repository 31 | 32 | For Personal Accounts: 33 | ``` 34 | flux bootstrap github \ 35 | --owner=$GITHUB_USER \ 36 | --repository=flux-clusters-config \ 37 | --branch=main \ 38 | --path=./clusters/cluster1 \ 39 | --personal 40 | ``` 41 | 42 | For Organizational Accounts: 43 | ``` 44 | flux bootstrap github \ 45 | --owner=Kevin-Bowersox-Courses \ 46 | --repository=flux-clusters-config \ 47 | --branch=main \ 48 | --path=./clusters/cluster1 49 | ``` 50 | 51 | 3. Create a Source to Point Flux to the Desired State 52 | ``` 53 | flux create source git gitops-foundations \ 54 | --url=https://github.com/Kevin-Bowersox-Courses/gitops-foundations-env-2892009.git \ 55 | --branch=main \ 56 | --interval=30s \ 57 | --export > ./clusters/cluster1/gitops-foundations-source.yaml 58 | ``` 59 | 60 | 4. Create a Kustomization to Deploy the Desired State Found in the Source 61 | ``` 62 | flux create kustomization gitops-foundations \ 63 | --source=gitops-foundations \ 64 | --path=./flux \ 65 | --prune=true \ 66 | --validation=client \ 67 | --interval=1m \ 68 | --export > ./clusters/cluster1/gitops-foundations-kustomization.yaml 69 | ``` 70 | 71 | 5. Watch the Kustomization 72 | ``` 73 | watch flux get kustomizations 74 | ``` 75 | 76 | [0]: # (Replace these placeholder URLs with actual course URLs) 77 | 78 | [lil-course-url]: https://www.linkedin.com/learning/ 79 | [lil-thumbnail-url]: http:// 80 | [k3d-start]: https://k3d.io/#installation 81 | [docker-install]: https://docs.docker.com/engine/install/ 82 | [kube-site]: https://kubernetes.io/docs/tasks/tools/ 83 | [azurecli-start]: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli 84 | [setup-instructions]: https://github.com/LinkedInLearning/gitops-foundations-env-2892009#installing 85 | [flux-start]: https://fluxcd.io/docs/get-started/ 86 | [flagger-start]: https://docs.flagger.app/ 87 | [terraform-install]: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/azure-get-started 88 | [helm-start]: https://helm.sh/docs/intro/install/ 89 | 90 | 91 | -------------------------------------------------------------------------------- /flux/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: gitops-foundations 5 | namespace: flux-exercise 6 | labels: 7 | app: gitops-foundations 8 | spec: 9 | replicas: 3 10 | selector: 11 | matchLabels: 12 | app: gitops-foundations 13 | template: 14 | metadata: 15 | labels: 16 | app: gitops-foundations 17 | spec: 18 | containers: 19 | - name: gitops-foundations 20 | image: {dockerHubUsername}/gitops-foundations:1.0 21 | imagePullPolicy: IfNotPresent 22 | ports: 23 | - containerPort: 8080 24 | livenessProbe: 25 | httpGet: 26 | path: /actuator/health 27 | port: 8080 28 | initialDelaySeconds: 5 29 | periodSeconds: 10 30 | failureThreshold: 2 31 | -------------------------------------------------------------------------------- /flux/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: flux-exercise 5 | -------------------------------------------------------------------------------- /flux/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: gitops-foundations 5 | annotations: 6 | service.beta.kubernetes.io/azure-dns-label-name: {dockerHubUsername} 7 | namespace: flux-exercise 8 | spec: 9 | type: LoadBalancer 10 | selector: 11 | app: gitops-foundations 12 | ports: 13 | - port: 80 14 | targetPort: 8080 15 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type f -exec sed -i 's/{dockerHubUsername}/'$1'/g' {} + 3 | -------------------------------------------------------------------------------- /terraform/README.md: -------------------------------------------------------------------------------- 1 | # Terraform Demonstration 2 | This directory contains the example materials used in the Terraform demonstration that is part of the LinkedIn Learning course `GitOps Foundations`. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | 5 | In this demonstration we bootstrap the AKS cluster on Azure that provides the underlying container orchestration platform for deployment of our cloud native application using a GitOps approach. The underlying cluster is used throughout the final lessons of the course and is expected to be reprovisioned for each tool (Flux & Flagger) 6 | 7 | ## Required Tools 8 | 1. **Terraform** is used as the underlying container platform for building and running containers. You can download and install Docker for your platform using the [official installation guide][docker-install]. 9 | 2. **kubectl** is a command line tool used to run commands against the Kubernetes cluster. You can download and install kubectl by following the installation instructions on the [official site][kube-site]. 10 | 3. **Azure CLI** is a command line interface that is used with Azure Cloud platform. You can download and install the Azure CLI by following the instructions on the [official website][azurecli-start]. 11 | 12 | ## Instructions 13 | This folder contains the example files for the Terraform demonstration. Prior to applying these manifests on the Kubernetes cluster with GitOps you must build and store the container images into DockerHub using these [instructions][setup-instructions]. After completing those instructions, follow along with the steps in the course to deploy the resources to the cluster. 14 | 15 | ## Commands 16 | The following commands are used in the demonstrations. They are provided within the readme file so that you can copy and paste them while working through the course. 17 | 18 | 1. Login to Azure via the CLI 19 | 20 | ``` 21 | az login 22 | ``` 23 | 24 | 2. Create an Active Directory Service Account 25 | ``` 26 | az ad sp create-for-rbac --skip-assignment 27 | ``` 28 | 29 | 3. Initiate the Terraform Workspace 30 | ``` 31 | terraform init 32 | ``` 33 | 34 | 4. Apply the Terraform Plan 35 | ``` 36 | terraform apply 37 | ``` 38 | 39 | 5. Connect the New Cluster to Kubectl (Must be ran in Terraform Directory) 40 | ``` 41 | az aks get-credentials --resource-group $(terraform output -raw resource_group_name) --name $(terraform output -raw kubernetes_cluster_name) 42 | ``` 43 | 44 | [0]: # (Replace these placeholder URLs with actual course URLs) 45 | 46 | [lil-course-url]: https://www.linkedin.com/learning/ 47 | [lil-thumbnail-url]: http:// 48 | [k3d-start]: https://k3d.io/#installation 49 | [docker-install]: https://docs.docker.com/engine/install/ 50 | [kube-site]: https://kubernetes.io/docs/tasks/tools/ 51 | [azurecli-start]: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli 52 | [setup-instructions]: https://github.com/LinkedInLearning/gitops-foundations-env-2892009#installing 53 | -------------------------------------------------------------------------------- /terraform/aks-k8s-cluster.tf: -------------------------------------------------------------------------------- 1 | resource "random_pet" "prefix" {} 2 | 3 | terraform { 4 | required_providers { 5 | azurerm = { 6 | source = "hashicorp/azurerm" 7 | version = "2.42.0" 8 | } 9 | } 10 | 11 | required_version = "~> 0.14" 12 | } 13 | 14 | provider "azurerm" { 15 | features {} 16 | } 17 | 18 | resource "azurerm_resource_group" "k8s" { 19 | name = "${random_pet.prefix.id}-rg" 20 | location = "West US 2" 21 | } 22 | 23 | resource "azurerm_kubernetes_cluster" "k8s" { 24 | name = "${random_pet.prefix.id}-aks" 25 | location = azurerm_resource_group.k8s.location 26 | resource_group_name = azurerm_resource_group.k8s.name 27 | dns_prefix = "${random_pet.prefix.id}-k8s" 28 | 29 | default_node_pool { 30 | name = "default" 31 | node_count = 2 32 | vm_size = "Standard_D2_v2" 33 | os_disk_size_gb = 30 34 | } 35 | 36 | service_principal { 37 | client_id = var.id 38 | client_secret = var.password 39 | } 40 | 41 | role_based_access_control { 42 | enabled = true 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /terraform/install_terraform.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl 2 | curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - 3 | sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" 4 | sudo apt-get update && sudo apt-get install terraform 5 | -------------------------------------------------------------------------------- /terraform/outputs.tf: -------------------------------------------------------------------------------- 1 | output "resource_group_name" { 2 | value = azurerm_resource_group.k8s.name 3 | } 4 | 5 | output "kubernetes_cluster_name" { 6 | value = azurerm_kubernetes_cluster.k8s.name 7 | } 8 | 9 | # output "host" { 10 | # value = azurerm_kubernetes_cluster.k8s.kube_config.0.host 11 | # } 12 | 13 | # output "client_key" { 14 | # value = azurerm_kubernetes_cluster.k8s.kube_config.0.client_key 15 | # } 16 | 17 | # output "client_certificate" { 18 | # value = azurerm_kubernetes_cluster.k8s.kube_config.0.client_certificate 19 | # } 20 | 21 | # output "kube_config" { 22 | # value = azurerm_kubernetes_cluster.k8s.kube_config_raw 23 | # } 24 | 25 | # output "cluster_username" { 26 | # value = azurerm_kubernetes_cluster.k8s.kube_config.0.username 27 | # } 28 | 29 | # output "cluster_password" { 30 | # value = azurerm_kubernetes_cluster.k8s.kube_config.0.password 31 | # } 32 | -------------------------------------------------------------------------------- /terraform/terraform.tfvars: -------------------------------------------------------------------------------- 1 | id="Your Service ID goes here" 2 | password="Your Service Password goes here" 3 | -------------------------------------------------------------------------------- /terraform/variables.tf: -------------------------------------------------------------------------------- 1 | variable "id" { 2 | description = "Service username" 3 | } 4 | 5 | variable "password" { 6 | description = "AKS password" 7 | } 8 | --------------------------------------------------------------------------------