You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/gitlab-managed-runners/_index.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@ draft: true
5
5
cascade:
6
6
draft: true
7
7
8
-
minutes_to_complete: 30
8
+
minutes_to_complete: 40
9
9
10
10
who_is_this_for: This is an Introductory topic for DevOps professionals who are looking to build a CI/CD pipeline with GitLab on Google Axion using GitLab-Hosted runners.
11
11
12
12
learning_objectives:
13
13
- Create a GitLab Project
14
14
- Understand basic pipeline script structure and how to use it
15
-
- Build and test a simple CI/CD pipeline Using Gitlab-hosted runners
15
+
- Build and test a simple CI/CD pipeline using Gitlab-hosted runners which will build and produce a tiny docker image from a simple "Hello world" "C" language program. The image will be built to run on Arm64 machines and will be saved in Gitlab Registery to be used later.
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/gitlab-managed-runners/info.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,9 @@ A GitLab Runner works with GitLab CI/CD to run jobs in a pipeline. It acts as an
15
15
16
16
3. Multi-architecture support: GitLab runners support multiple architectures including - **`x86/amd64`** and **`arm64`**.
17
17
18
-
## What is Google Axion?
19
-
Axion is Google's first Arm-based server processor, built using the Armv9 Neoverse V2 CPU. The VM instances are part of the **`C4A`** family of compute instances. To learn more about Google Axion refer to this [page](http://cloud.google.com/products/axion/) .
20
18
21
19
{{% notice Note %}}
22
-
All The information provided in the next section are from GitLab official Pages and it's provided here for convenience and can be changed by Gitlab at anytime. Please refer to the [Gitlab Documentation](https://docs.gitlab.com/ci/runners/hosted_runners/) for more details and for the latest updates.
20
+
All The information provided in the next section are from GitLab official Pages and it's provided here for convenience and can be changed by Gitlab at anytime. Please refer to the [Gitlab Documentation](https://docs.gitlab.com/ci/runners/hosted_runners/) for more details and for the latest updates. This section is optional.
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/gitlab-managed-runners/pipeline.md
+98-59Lines changed: 98 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,83 +8,122 @@ layout: learningpathall
8
8
9
9
## How to Create a CI/CD Pipeline with Gitlab-hosted Runners?
10
10
11
-
To create the pipeline we only need to create a new **`.gitlab-ci.yml`** file in our Project and define it's stages. Nothing else is needed since Gtilab-hosted runners are readily available to any Project and doesn't need to be created or instantiated by the Gitlab users.
11
+
To create the pipeline you only need to create a new **`.gitlab-ci.yml`** file in your Project and define it's stages. Nothing else is needed since Gtilab-hosted runners are readily avilable to any Project and doesn't need to be created or instantiated by the Gitlab users.
12
12
13
-
Once we run our pipeline with the correct **`tags`** Gitlab will create everything that we need and yep it is as simple as that.
13
+
Once you run your pipeline with the correct **`tags`** Gitlab will create everything that you need and yep it is as simple as that.
14
+
15
+
## How are you going to test your pipeline functionality?
16
+
17
+
You will test the pipeline by building a Docker image from a simple C language "Hello World" program which can run on Arm64 instances/machines and to do that you will need to create the following files:
18
+
19
+
1)**`main.c`** File: which is the main program that will get executed when we will run your Docker image later. I only provided a simple example but please feel free to use any program that you like. Although, I advise to start with this simple program to test that everything is working then use anything later after by changing the **`main.c`** file.
20
+
21
+
```c
22
+
//main.c
23
+
#include<stdio.h>
24
+
25
+
intmain(void) {
26
+
printf("Hello from an Arm64 Docker image built on GitLab hosted Arm runners!\n");
27
+
return 0;
28
+
}
29
+
```
30
+
31
+
2) **`DockerFile`** File: This file has a set of instruction for Docker on how to create a Docker image. It simply instructs the Docker on your runner on how to build and package your **``hello``** app into a Docker image. This produces a tiny image and will run on Arm64 hosts as long as the binary is Arm64 (which it will be, since we’re building on an Arm runner).
32
+
33
+
```DockerFile
34
+
# DockerFile
35
+
# syntax=docker/dockerfile:1
36
+
37
+
FROM alpine:3.20 AS build
38
+
RUN apk add --no-cache build-base
39
+
WORKDIR /src
40
+
COPY main.c .
41
+
RUN gcc -O2 -static -s -o hello main.c
42
+
43
+
FROM scratch
44
+
COPY --from=build /src/hello /hello
45
+
ENTRYPOINT ["/hello"]
46
+
47
+
```
48
+
49
+
3) Optionally **`.dockerignore`** file: This file instructs Docker to ignor certain files that has nothing to do with the image that it will create.
50
+
51
+
```.dockerignore
52
+
.git
53
+
.gitlab-ci.yml
54
+
```
55
+
56
+
4) You will also need to create a YML file as I mentioned before which I will explain in more details in the next section.
57
+
58
+
To Create any of those files simply follow the same steps in the next section but instead of choosing **`.gitlab-ci.yml`** file just change the name to each of the corresponding file names above. It is very important to create the 3 files from this section first because once you create and commit/save the **`.gitlab-ci.yml`** file, it will simply run the pipeline. If the other 3 files don't exist at that time then the pipeline will fail.
14
59
15
60
## How to Create .gitlab-ci.yml file in a Gitlab Project?
16
61
17
-
1. Start by going to the main project page where we will need to Create the CI/CD pipeline.
62
+
1. Start by going to the main project page where you will need to Create the CI/CD pipeline.
18
63
19
-
2.We can choose to create **`.gitlab-ci.yml`** file by using one of the 2 options circled in red in the image below.
20
-

64
+
2.You can choose to create **`.gitlab-ci.yml`** file by using one of the 2 options circled in red in the image below.
65
+

21
66
22
-
Option1: We can Click on **`Set up CI/CD`** button/link and follow the wizard to create an empty **`.gitlab-ci.yml`** file.
67
+
Option1: You can Click on **`Set up CI/CD`** button/link and follow the wizad to create an empty **`.gitlab-ci.yml`** file.
23
68
24
69
Option2: Click on the "+" button. From the popup menu click on **`New File`** option and name the file **`.gitlab-ci.yml`** and then click on **`Commit Changes`** button on the top right hand side like in the image below (Add any message as your commit message).
25
70

26
71
27
-
3. A page like the one in the image below will be visible with our**`.gitlab-ci.yml`** file. From here, we will need to Click on the **`Edit`** button. A menu will pop up, We will click on **`Edit in pipeline Editor`** which will allow us to add our CD/CD script.
28
-

72
+
3. A page like the one in the image below will be visible with your**`.gitlab-ci.yml`** file. From here, you will need to Click on the **`Edit`** button. A menu will pop up, you will click on **`Edit in pipeline Editor`** which will allow you to add your CD/CD script.
73
+

29
74
30
75
4. In the pipeline editor, just copy and paste the following YML script and click on commit changes (Add any relevent message as your commit update message).
31
76
```YML
32
-
# This file is a template, and might need editing before it works on your project.
33
-
# This is a sample GitLab CI/CD configuration file that should run without any modifications.
34
-
# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts,
35
-
# it uses echo commands to simulate the pipeline execution.
36
-
#
37
-
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
38
-
# Stages run in sequential order, but jobs within stages run in parallel.
39
-
#
40
-
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/#stages
41
-
#
42
-
# You can copy and paste this template into a new `.gitlab-ci.yml` file.
43
-
# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword.
44
-
#
45
-
# To contribute improvements to CI/CD templates, please follow the Development guide at:
lint-test-job: # This job also runs in the test stage.
73
-
stage: test # It can run at the same time as unit-test-job (in parallel).
74
-
tags:
75
-
- saas-linux-small-arm64 #Instruct Gitlab to use it's own Hosted runners that use Linux on Arm64 instance of size small.
84
+
# Talk to docker:dind over TLS (default behavior for docker:dind)
85
+
DOCKER_HOST: "tcp://docker:2376"
86
+
DOCKER_TLS_CERTDIR: "/certs"
87
+
DOCKER_CERT_PATH: "/certs/client"
88
+
DOCKER_TLS_VERIFY: "1"
89
+
90
+
#Second Section
91
+
build_test_push:
92
+
stage: build
93
+
tags: # This tag is used to specify the size of the runner for each stage but it can be defined on the top of the file if you want to use the same exact runner size for all the stages in your pipeline
94
+
- saas-linux-small-arm64
95
+
image: docker:27
96
+
services:
97
+
- name: docker:27-dind
98
+
before_script:
99
+
- uname -m
100
+
# install lscpu (provided by util-linux) which is used to identify the CPU used for this stage runner
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/gitlab-managed-runners/project.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ weight: 10
6
6
layout: learningpathall
7
7
---
8
8
9
-
## Where Should We Start?
9
+
## Where Should you Start?
10
10
11
11
Start by logging into your GitLab account or create a new one in the [Gitlab](https://gitlab.com/) main page.
12
12
13
-
We will need to a new project/repo that will contain all our project files including our**`CI/CD`** pipeline configuration file.
13
+
You will need to a new project/repo that will contain all your project files including your**`CI/CD`** pipeline configuration file.
14
14
15
-
We can also choose to use any previously created projects in our Gitlab account. Simply open your previously created project. If that is the case then skip the rest of the steps in the current page and move to the next steps in this tutorial.
15
+
You can also choose to use any previously created projects in your Gitlab account. Simply open your previously created project, If that is the case then skip the rest of the steps in the current page and move to the next steps in this tutorial.
16
16
17
17
## Create a New Project in Gitlab
18
18
@@ -21,17 +21,17 @@ We can also choose to use any previously created projects in our Gitlab account.
21
21
2. Click on the **`New Project`** button on the top right hand side as the image below.
3.We will get a new screen like the image below with multiple options. You can choose any of the 2 options highlighted in red from the image below.
24
+
3.You will get a new screen like the image below with multiple options. You can choose any of the 2 options highlighted in red from the image below.
25
25
26
26
{{% notice Note %}}
27
-
If we chose option 2 then we will need to choose **`GitLab CI/CD components`** option from the list of templates.
27
+
If you chose option 2 then you will need to choose the**`GitLab CI/CD components`** option from the list of templates.
28
28
{{%/notice%}}
29
29
30
30

31
31
32
-
4. Regardles of which option we choose, We will get a screen like the image below where we need to fill-in fields highlighted in red. The first field is the **`Project Name`** which we will name it **`CI-CD Runner`**. In the second field we need to choose any option from the **`Project Url`** list then click on the **`Create Project`** button at the end of the page.
32
+
4. Regardles of which option you choose, you will get a screen like the image below where you will need to fill-in the fields highlighted in red. The first field is the **`Project Name`** which you can name it **`CI-CD Runner`**. In the second field you need to choose any option from the **`Project Url`** list then click on the **`Create Project`** button at the end of the page.
33
33

34
34
35
-
##### **If we did everything correctly then we should get a screen like the one in the image below.**
35
+
##### **If you did everything correctly then you should get a screen like the one in the image below.**
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/gitlab-managed-runners/results.md
+35-6Lines changed: 35 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,16 +10,18 @@ layout: learningpathall
10
10
11
11
The Pipeline script has multiple sections where each section instructs the pipeline operator on what todo or use and how each Stage looks like.
12
12
13
-
### First Section: Stages
13
+
### First Section: The stages
14
14
15
-
In this section we are describing how many sequential stages will our pipeline have and what are their names (ex. **`Build, Test and Deploy`**). If we would like all the stages or jobs to run simultaneously then we simply don't define this section.
15
+
In this section you are describing how many squentional stages that your pipeline will have and what are their names (ex. **`Build, Test and Push`**). If you would like all the stages or jobs to run simultinously then you simply don't define this section.
16
16
17
-
### Second Section: Build-Job part of the Build stage
17
+
I am also defining some **`Variables`** that I will use in the other sections for simplisty.
18
18
19
-
In this section we are defining the Build-Job as part of the Build stage. This stage will run on Gitlab-Hosted runner that uses Linux OS on Arm64 instance of size small.
19
+
### Second Section: build_test_push part for the Build stage
20
+
21
+
In this section you are defining the build_test_push as the Build stage. This stage will run on Gitlab-Hosted runner that uses Linux OS on Arm64 instance of size small. I used the **`lscpu`** command to print out the CPU information for reference.
20
22
21
23
{{% notice Important Note %}}
22
-
Gitlab offers 3 Arm64 based Instances that use Linux as their OS.
24
+
Gitlab offers 3 Arm64 based Instances that use Linux as their OS. In the Free tier you can only use the small version.
23
25
24
26
- saas-linux-small-arm64
25
27
- saas-linux-medium-arm64
@@ -29,7 +31,11 @@ For more information about all Arm and other available Gitlab-hosted runners che
29
31
30
32
{{%/notice%}}
31
33
32
-
### Other Sections:
34
+
I am also saving my Docker image in GitLab registery because it's the easiest way to do that but you can modify your pipeline to save your image in any other registery that you prefer. To get the Gitlab registery creditiationals I am using **`$CI`** variables that are defined in the Gitlab enviornment and saving them in Docker for simplisty. Please note it's always recommended to encrypt your information or save it in a sercrets/passwords manages.
35
+
36
+
### Third Section:
37
+
38
+
You will notice that in this stage I am simply testing that I am able to get the image that I saved in my registery before and pushing it back as the latest version.
33
39
34
40
The rest of the other sections follow the same pattern. You will notice that the **`Test`** stage for example has 2 Jobs in it (unit-test-job and lint-test-job). The **`Deploy`** stage here has only 1 Job called **`deploy-job`**.
35
41
As you get to learn more YML scripting you will be able to add a lot more complex functionality to your pipelines.
@@ -46,6 +52,29 @@ From the left hand side panel, Navigate to **`Build`** then to **`Pipeline`** th
46
52
To check the status of your pipeline and to check the output of any of it's Jobs simply click on any of the **`Jobs`** as the image below (with red rectangle around them).
You can also download the docker image that you saved in your gitlab registery and run it on an Arm64 instance/box for testing using the following bash script.
docker run --rm registry.gitlab.com/<namespace>/<project>:latest
61
+
```
62
+
63
+
If everything works correctly you should see an output like in the box below.
64
+
65
+
```output
66
+
Hello from an Arm64 Docker image built on GitLab hosted Arm runners!
67
+
```
68
+
69
+
You can also check your Gitlab Registery by going to your project then:
70
+
71
+
- Go to Deploy → Container Registry
72
+
- You should see new-docker
73
+
- With tags like latest and **`<commit-sha>`**
74
+
75
+
If it’s there, the registry did its job.
76
+
77
+
49
78
## Gitlab Helpful tools
50
79
51
80
If you navigate to your pipeline editor from before you will notice that there are more tabs in that page other than the **`Edit`** tab. 
0 commit comments