Контрольні точки
Create a Kubernetes cluster (zone: us-east1-d)
/ 50
Configure and Install Jenkins
/ 50
Setting up Jenkins on Kubernetes Engine
GSP117
In this hands-on lab, you'll learn how to set up Jenkins on Google Kubernetes Engine to help orchestrate your software delivery pipeline.
Objectives
- Creating a Kubernetes cluster with Kubernetes Engine.
- Creating a Jenkins deployment and services.
- Connecting to Jenkins.
Setup and requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
How to start your lab and sign in to the Google Cloud console
-
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:
- The Open Google Cloud console button
- Time remaining
- The temporary credentials that you must use for this lab
- Other information, if needed, to step through this lab
-
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account. -
If necessary, copy the Username below and paste it into the Sign in dialog.
{{{user_0.username | "Username"}}} You can also find the Username in the Lab Details panel.
-
Click Next.
-
Copy the Password below and paste it into the Welcome dialog.
{{{user_0.password | "Password"}}} You can also find the Password in the Lab Details panel.
-
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges. -
Click through the subsequent pages:
- Accept the terms and conditions.
- Do not add recovery options or two-factor authentication (because this is a temporary account).
- Do not sign up for free trials.
After a few moments, the Google Cloud console opens in this tab.
Activate Cloud Shell
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
- Click Activate Cloud Shell at the top of the Google Cloud console.
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
- (Optional) You can list the active account name with this command:
- Click Authorize.
Output:
- (Optional) You can list the project ID with this command:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Task 1. Prepare the environment
First, you'll prepare your deployment environment and download a sample application.
- Set the default Compute Engine zone to
:
- Clone the sample code:
- Navigate to the sample code directory:
Creating a Kubernetes cluster
Now you'll use the Kubernetes Engine to create and manage your Kubernetes cluster.
- Next, provision a Kubernetes cluster using Kubernetes Engine. This step can take several minutes to complete:
The extra scopes enable Jenkins to access Cloud Source Repositories and Google Container Registry.
Test completed task
Click Check my progress to verify your performed task. If you have completed the task successfully you will granted with an assessment score.
- Confirm that your cluster is running:
Example Output:
Look for RUNNING
in the STATUS
column:
- Get the credentials for your cluster. Kubernetes Engine uses these credentials to access your newly provisioned cluster.
- Confirm that you can connect to your cluster:
Example output: If the cluster is running, the URLs of where your Kubernetes components are accessible display:
Task 2. Configure Helm
In this lab, you will use Helm to install Jenkins from the Charts repository. Helm is a package manager that makes it easy to configure and deploy Kubernetes applications. Your Cloud Shell will already have a recent, stable version of Helm pre-installed.
If curious, you can run helm version
in Cloud Shell to check which version you are using and also ensure that Helm is installed.
- Add Helm's
jenkins
chart repository:
- Update the repo to ensure you get the latest list of charts:
Task 3. Configure and install Jenkins
You will use a custom values file to add the Google Cloud specific plugin necessary to use service account credentials to reach your Cloud Source Repository.
- Use the Helm CLI to deploy the chart with your configuration set:
Test completed task
Click Check my progress to verify your performed task. If you have completed the task successfully you will granted with an assessment score.
- Once that command completes ensure the Jenkins pod goes to the Running state and the container is in the READY state. This may take about 2 minutes:
Example output:
- Run the following command to setup port forwarding to the Jenkins UI from the Cloud Shell:
- Now, check that the Jenkins Service was created properly:
Example output:
We are using the Kubernetes Plugin so that our builder nodes will be automatically launched as necessary when the Jenkins master requests them. Upon completion of their work, they will automatically be turned down and their resources added back to the clusters resource pool.
Notice that this service exposes ports 8080
and 50000
for any pods that match the selector
. This will expose the Jenkins web UI and builder/agent registration ports within the Kubernetes cluster.
Additionally, the jenkins-ui
service is exposed using a ClusterIP so that it is not accessible from outside the cluster.
Task 4. Connect to Jenkins
- The Jenkins chart will automatically create an admin password for you. To retrieve it, run:
- To get to the Jenkins user interface, click on the Web Preview button in cloud shell, then click Preview on port 8080:
- You should now be able to log in with the username
admin
and your auto-generated password.
You now have Jenkins set up in your Kubernetes cluster!
Test your understanding
Below are multiple-choice questions to reinforce your understanding of this lab's concepts. Answer them to the best of your abilities.
Congratulations!
Finish your quest
This self-paced lab is part of the Google Cloud Skills Boost Quest, Google Cloud Solutions I: Scaling Your Infrastructure. A quest is a series of related labs that form a learning path. Completing this quest earns you a badge to recognize your achievement. You can make your badge or badges public and link to them in your online resume or social media account. Enroll in this quest and get immediate completion credit. See the Google Cloud Skills Boost catalog for all available quests.
Take your next lab
Continue your quest with Continuous Delivery Pipelines with Spinnaker and Kubernetes Engine, or check out these suggestions:
- Autoscaling an Instance Group with Stackdriver Custom Metrics
- Deploying Memcached on Kubernetes Engine
Next steps / learn more
Here are some follow-up steps :
- Learn more about Jenkins on Kubernetes Engine best practices.
- Learn about how to configure Jenkins for Kubernetes Engine.
- Learn about how to set up continuous deployment to Kubernetes Engine using Jenkins.
Google Cloud training and certification
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated August 15, 2022
Lab Last Tested August 15, 2022
Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.