课程: GitOps Foundations

Exercise file setup

- [Instructor] To make it easier to follow along with the course, I've placed the working files into LinkedIn Learning's GitHub organization. So inside of the organization, just go ahead and search for gitops and you'll see these two repositories, one for the application source code and another for the infrastructure code that's going to drive our operations. In gitops, it's common to keep the app and the infrastructure code in separate repositories. That allows us to apply distinct security for each repository and to maintain some separation of concerns. Now, if you're going to follow along with the demonstrations, it's best to fork these repositories. So to do that, click on the repository, we'll start with the app repository. And then from here, you just want to click on the fork button in the upper right-hand corner. You may be prompted to select an account or an organization. I've created one for the course, so I'll select that one. That's going to start the process of the fork. So let's navigate back to the LinkedIn Learning organization and we can begin the fork of the environment repository. So I'll just select that repo, and it's the same process. Just click on the fork button, select your account if necessary, and then the fork will start. Now, once we have forked these repositories, we're going to clone them down to our local workstation. To do that, just click on the code button and then copy the link to the repository. We'll take that over into our terminal and here I can just use git and clone that repository. There it was pulled down and then I'm just going to adjust the command to pull the app repository next. All right, so if we take a look, we have both repositories down on our local workstation. So to get started with our setup, we're going to navigate into the application repository and inside of this repository, I want to draw your attention to a few things. First, it contains all of our application source code and you'll notice the Dockerfile. It contains the instructions to package the application into a container image. That container image is going to be pushed to Docker Hub when we run the create_images script as part of our setup. So we'll need to log in to Docker Hub. To do that, we can use the docker login command and then just provide your Docker Hub account name here. You'll then need to provide your credentials. All right, so we're logged in to Docker Hub and now we can use the create_images script. It accepts one argument. It's going to be your Docker Hub account name. So supply that argument, go ahead, issue the script and the container images will start to build. And once they're built, the script will push them up to Docker Hub for you. Okay, it looks like they finished. Let's navigate out to Docker Hub and we can take a peak. So here inside of my account, I'm just going to click on repositories and I'll hit the refresh button. And there we see the new repository created by the script. It's named gitops-foundations. Inside of this repository are two images that we'll be working with throughout the course and deploying on our Kubernetes clusters. Now let's navigate back to GitHub and I want to call your attention to the environment repository. It holds a directory for each toll that we're going to be working with inside of the course. If we navigate into one of these directories, let's say the argo directory, you're going to find the infrastructure as code files. So things like our Kubernetes manifests and Terraform files that we'll be working with in the examples. Inside of these directories, you'll also find a README file that provides additional instructions for working with each tool. It's a great resource. All right, let's go back to the terminal because there is a little bit of configuration that we need to perform for the environment repositories. I'm going to go ahead and clear the screen and then we'll need to navigate back a directory and then navigate into the environment repository. And here you can see it's just a copy of what was in GitHub. And inside of the root, you'll notice the setup.sh script. So we're going to run that and it accepts one argument as well, and that is our Docker Hub account name. So I'm just going to provide that and run the script. Okay, so once we do that, it's going to adjust all the Kubernetes manifests to point to our Docker Hub repository. We can just hop into the argo directory and take a peek at that by looking at one of the yaml files. So there you can see my Docker Hub repository has been appended to the image name. All right, so we're good to go there. Let's step back a directory. And from here, we're going to go ahead and push those changes up to GitHub. So to do that, just add the changes to the repository, and then you'll want to commit them. I'm just going to provide a short message and then you'll want to do a push to your main branch. All right, excellent. That's everything you need if you want to follow along with the course. You're all set up to begin.

内容