Experiment No. 10 Title: Create the GitHub Account to demonstrate CI/CD pipeline using Cloud Platform.
Experiment No. 10
Title: Create the GitHub Account to demonstrate CI/CD pipeline using Cloud Platform.
The objective of this experiment is to help you create a GitHub account and set up a basic CI/CD pipeline on GCP. You will learn how to connect your GitHub repository to GCP, configure CI/CD using Cloud Build, and automatically deploy web pages to an Apache web server when code is pushed to your repository.
Continuous Integration and Continuous Deployment (CI/CD) pipelines are essential for automating the deployment of web applications. In this experiment, we will guide you through creating a GitHub account and setting up a basic CI/CD pipeline using Google Cloud Platform (GCP) to copy web pages for an Apache HTTP web application.
Continuous Integration and Continuous Deployment (CI/CD) is a crucial practice in modern software development. It involves automating the processes of code integration, testing, and deployment to ensure that software changes are consistently and reliably delivered to production. GitHub, Google Cloud Platform (GCP), and Amazon Web Services (AWS) are popular tools and platforms that, when combined, enable a powerful CI/CD pipeline.
GitHub: GitHub is a web-based platform for version control and collaboration. It allows developers to host and manage their source code repositories, track changes, collaborate with others, and automate workflows.
Google Cloud Platform (GCP): GCP is a cloud computing platform that provides a wide range of cloud services, including computing, storage, databases, machine learning, and more. It can be used to host applications and services.
Amazon Web Services (AWS): AWS is another cloud computing platform that offers a comprehensive set of cloud services. It is often used for hosting infrastructure, containers, databases, and more.
Basic CI/CD Workflow:
A basic CI/CD workflow using GitHub, GCP, and AWS typically includes the following steps:
Code Development: Developers work on code changes and commit them to a GitHub repository.
Continuous Integration (CI):
GitHub Actions or a CI tool like Jenkins is used to automatically build, test, and package the application whenever code changes are pushed to the repository.
Automated tests are executed to ensure code quality.
Continuous Deployment (CD):
Once code changes pass CI, the application can be automatically deployed to a staging environment.
Integration and acceptance tests are performed in the staging environment.
Deployment to Production:
If all tests in the staging environment pass, the application can be automatically deployed to the production environment in GCP or AWS.
Monitoring and Logging:
Monitoring tools are used to track the application's performance and detect issues.
Logging and analytics tools are used to gain insights into application behavior.
Any issues or failures detected in production are reported back to the development team for further improvements.
The cycle repeats as new code changes are developed and deployed.
Benefits of Basic CI/CD with GitHub, GCP, and AWS:
Automation: CI/CD automates repetitive tasks, reducing the risk of human error and speeding up the delivery process.
Consistency: CI/CD ensures that all code changes go through the same testing and deployment processes, leading to consistent and reliable results.
Faster Time to Market: Automated deployments enable faster delivery of new features and bug fixes to users.
Improved Collaboration: GitHub's collaboration features enable teams to work together seamlessly, and CI/CD pipelines keep everyone on the same page.
Scalability: Cloud platforms like GCP and AWS provide scalable infrastructure to handle varying workloads.
Efficiency: Developers can focus on writing code while CI/CD pipelines take care of building, testing, and deploying applications.
A computer with internet access
A Google Cloud Platform account (https://cloud.google.com/)
A GitHub account (https://github.com/)
Step 1: Create a GitHub Account
Visit the GitHub website (https://github.com/).
Click on the "Sign Up" button and follow the instructions to create your GitHub account.
Step 2: Create a Sample GitHub Repository
Log in to your GitHub account.
Click the "+" icon in the top-right corner and select "New Repository."
Give your repository a name (e.g., "my-web-pages") and provide an optional description.
Choose the repository visibility (public or private).
Click the "Create repository" button.
Step 3: Set Up a Google Cloud Platform Project
Log in to your Google Cloud Platform account.
Create a new GCP project by clicking on the project drop-down in the GCP Console (https://console.cloud.google.com/).
Click on "New Project" and follow the prompts to create a project.
Step 4: Connect GitHub to Google Cloud Build
In your GCP Console, navigate to "Cloud Build" under the "Tools" section.
Click on "Triggers" in the left sidebar.
Click the "Connect Repository" button.
Select "GitHub (Cloud Build GitHub App)" as the source provider.
Authorise Google Cloud Build to access your GitHub account.
Choose your GitHub repository ("my-web-pages" in this case) and branch.
Step 5: Create a CI/CD Configuration File
In your GitHub repository, create a configuration file named cloudbuild.yaml. This file defines the CI/CD pipeline steps.
Add a simple example configuration to copy web pages to an Apache web server. Here's an example:
- name: 'gcr.io/cloud-builders/gsutil'
args: ['-m', 'rsync', '-r', 'web-pages/', 'gs://your-bucket-name']
Replace 'gs://your-bucket-name' with the actual Google Cloud Storage bucket where your Apache web server serves web pages.
Commit and push this file to your GitHub repository.
Step 6: Trigger the CI/CD Pipeline
Make changes to your web pages or configuration.
Push the changes to your GitHub repository.
Go to your GCP Console and navigate to "Cloud Build" > "Triggers."
You should see an automatic trigger for your repository. Click the trigger to see details.
Click "Run Trigger" to manually trigger the CI/CD pipeline.
Step 7: Monitor the CI/CD Pipeline
In the GCP Console, navigate to "Cloud Build" to monitor the progress of your build and deployment.
Once the pipeline is complete, your web pages will be copied to the specified Google Cloud Storage bucket.
Step 8: Access Your Deployed Web Pages
Configure your Apache web server to serve web pages from the Google Cloud Storage bucket.
Access your deployed web pages by visiting the appropriate URL.
In this experiment, you created a GitHub account, set up a basic CI/CD pipeline on Google Cloud Platform, and deployed web pages to an Apache web server. This demonstrates how CI/CD can automate the deployment of web content, making it easier to manage and update web applications efficiently.
Exercise / Questions:
What is the primary purpose of Continuous Integration and Continuous Deployment (CI/CD) in software development, and how does it benefit development teams using GitHub, GCP, and AWS?
Explain the role of GitHub in a CI/CD pipeline. How does GitHub facilitate version control and collaboration in software development?
What are the key services and offerings provided by Google Cloud Platform (GCP) that are commonly used in CI/CD pipelines, and how do they contribute to the automation and deployment of applications?
Similarly, describe the essential services and tools offered by Amazon Web Services (AWS) that are typically integrated into a CI/CD workflow.
Walk through the basic steps of a CI/CD pipeline from code development to production deployment, highlighting the responsibilities of each stage.
How does Continuous Integration (CI) differ from Continuous Deployment (CD)? Explain how GitHub Actions or a similar CI tool can be configured to build and test code automatically.
In the context of CI/CD, what is a staging environment, and why is it important in the deployment process? How does it differ from a production environment?
What are the primary benefits of using automation for deployment in a CI/CD pipeline, and how does this automation contribute to consistency and reliability in software releases?
Discuss the significance of monitoring, logging, and feedback loops in a CI/CD workflow. How do these components help in maintaining and improving application quality and performance?
In terms of scalability and flexibility, explain how cloud platforms like GCP and AWS enhance the CI/CD process, especially when dealing with variable workloads and resource demands.