Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Openstack Gitlab Executor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pi-Lab
Infrastructure
Openstack Gitlab Executor
Commits
7b03b930
Commit
7b03b930
authored
2 years ago
by
istmxrein
Browse files
Options
Downloads
Patches
Plain Diff
add feature to use floating ipv4 address for ssh connection (default)
parent
14d8e314
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Dockerfile
+9
-4
9 additions, 4 deletions
Dockerfile
entrypoint.sh
+1
-1
1 addition, 1 deletion
entrypoint.sh
env.py
+3
-2
3 additions, 2 deletions
env.py
prepare.py
+11
-2
11 additions, 2 deletions
prepare.py
run.py
+4
-1
4 additions, 1 deletion
run.py
with
28 additions
and
10 deletions
Dockerfile
+
9
−
4
View file @
7b03b930
...
@@ -11,18 +11,23 @@ LABEL maintainer="Max Reinheimer <max@reinheimer.dev>" \
...
@@ -11,18 +11,23 @@ LABEL maintainer="Max Reinheimer <max@reinheimer.dev>" \
description="A GitLab runner image with openstack custom executor." \
description="A GitLab runner image with openstack custom executor." \
io.k8s.description="A GitLab runner image with openstack custom executor."
io.k8s.description="A GitLab runner image with openstack custom executor."
COPY
cleanup.py env.py config.sh prepare.py run.py requirements.txt /data/
COPY
requirements.txt /data/
COPY
entrypoint.sh /usr/bin/entrypoint
WORKDIR
/data
RUN
apt-get update
&&
apt-get
-y
install
curl dumb-init gcc libffi-dev
&&
\
RUN
apt-get update
&&
apt-get
-y
install
curl dumb-init gcc libffi-dev
&&
\
curl
-L
--output
/usr/bin/gitlab-runner
"
${
GITLAB_RUNNER_URL
}
"
&&
\
curl
-L
--output
/usr/bin/gitlab-runner
"
${
GITLAB_RUNNER_URL
}
"
&&
\
pip3
install
-r
/data/requirements.txt
&&
\
pip3
install
-r
/data/requirements.txt
&&
\
chmod
+x
/data/
*
/usr/bin/entrypoint
/usr/bin/gitlab-runner
&&
\
chmod
+x /usr/bin/gitlab-runner
&&
\
useradd
--comment
'GitLab Runner'
--create-home
gitlab-runner
--shell
/bin/bash
&&
\
useradd
--comment
'GitLab Runner'
--create-home
gitlab-runner
--shell
/bin/bash
&&
\
apt-get remove
-y
gcc curl
&&
apt autoremove
-y
&&
apt-get clean
apt-get remove
-y
gcc curl
&&
apt autoremove
-y
&&
apt-get clean
COPY
cleanup.py env.py config.sh prepare.py run.py /data/
COPY
entrypoint.sh /usr/bin/entrypoint
RUN
chmod
+x /data/
*
/usr/bin/entrypoint
USER
gitlab-runner
USER
gitlab-runner
WORKDIR
/data
ENTRYPOINT
["dumb-init", "--"]
ENTRYPOINT
["dumb-init", "--"]
CMD
["entrypoint"]
CMD
["entrypoint"]
This diff is collapsed.
Click to expand it.
entrypoint.sh
+
1
−
1
View file @
7b03b930
#!/bin/bash
#!/bin/bash
trap
cleanup SIGTERM
trap
cleanup SIGTERM
SIGINT
cleanup
()
{
cleanup
()
{
gitlab-runner unregister
--all-runners
gitlab-runner unregister
--all-runners
...
...
This diff is collapsed.
Click to expand it.
env.py
+
3
−
2
View file @
7b03b930
...
@@ -9,7 +9,8 @@ KEY_PAIR_NAME = os.getenv("CUSTOM_ENV_KEY_PAIR_NAME") or os.getenv("KEY_PAIR_NAM
...
@@ -9,7 +9,8 @@ KEY_PAIR_NAME = os.getenv("CUSTOM_ENV_KEY_PAIR_NAME") or os.getenv("KEY_PAIR_NAM
SECURITY_GROUPS
=
os
.
getenv
(
"
CUSTOM_ENV_SECURITY_GROUPS
"
)
or
os
.
getenv
(
"
SECURITY_GROUPS
"
)
SECURITY_GROUPS
=
os
.
getenv
(
"
CUSTOM_ENV_SECURITY_GROUPS
"
)
or
os
.
getenv
(
"
SECURITY_GROUPS
"
)
USERNAME
=
os
.
getenv
(
"
CUSTOM_ENV_USERNAME
"
)
or
os
.
getenv
(
"
USERNAME
"
)
USERNAME
=
os
.
getenv
(
"
CUSTOM_ENV_USERNAME
"
)
or
os
.
getenv
(
"
USERNAME
"
)
PRIVATE_KEY_PATH
=
f
"
{
os
.
getenv
(
'
HOME
'
)
}
/priv_key
"
PRIVATE_KEY_PATH
=
f
"
{
os
.
getenv
(
'
HOME
'
)
}
/priv_key
"
SSH_TIMEOUT
=
os
.
getenv
(
"
CUSTOM_ENV_SSH_TIMEOUT
"
)
or
os
.
getenv
(
"
SSH_TIMEOUT
"
)
or
"
30
"
SSH_TIMEOUT
=
os
.
getenv
(
"
CUSTOM_ENV_SSH_TIMEOUT
"
)
or
os
.
getenv
(
"
SSH_TIMEOUT
"
)
or
"
20
"
FLOATING_IP_NETWORK
=
os
.
getenv
(
"
FLOATING_IP_NETWORK
"
)
or
"
public
"
SSH_IP_VERSION
=
os
.
getenv
(
"
SSH_IP_VERSION
"
)
or
"
4
"
BUILD_FAILURE_EXIT_CODE
=
os
.
getenv
(
"
BUILD_FAILURE_EXIT_CODE
"
)
BUILD_FAILURE_EXIT_CODE
=
os
.
getenv
(
"
BUILD_FAILURE_EXIT_CODE
"
)
SYSTEM_FAILURE_EXIT_CODE
=
os
.
getenv
(
"
SYSTEM_FAILURE_EXIT_CODE
"
)
SYSTEM_FAILURE_EXIT_CODE
=
os
.
getenv
(
"
SYSTEM_FAILURE_EXIT_CODE
"
)
This diff is collapsed.
Click to expand it.
prepare.py
+
11
−
2
View file @
7b03b930
...
@@ -26,13 +26,22 @@ def provision_server(
...
@@ -26,13 +26,22 @@ def provision_server(
security_groups
=
[{
"
name
"
:
group
}
for
group
in
env
.
SECURITY_GROUPS
.
split
()],
security_groups
=
[{
"
name
"
:
group
}
for
group
in
env
.
SECURITY_GROUPS
.
split
()],
networks
=
[{
"
uuid
"
:
network
.
id
}],
networks
=
[{
"
uuid
"
:
network
.
id
}],
)
)
return
conn
.
compute
.
wait_for_server
(
server
,
wait
=
600
)
server
=
conn
.
compute
.
wait_for_server
(
server
,
wait
=
600
)
if
env
.
SSH_IP_VERSION
==
"
4
"
:
ips
=
conn
.
available_floating_ip
(
network
=
env
.
FLOATING_IP_NETWORK
,
server
=
server
)
conn
.
compute
.
add_floating_ip_to_server
(
server
,
ips
.
floating_ip_address
,
fixed_address
=
None
)
return
server
def
get_server_ip
(
def
get_server_ip
(
conn
:
openstack
.
connection
.
Connection
,
server
:
openstack
.
compute
.
v2
.
server
.
Server
conn
:
openstack
.
connection
.
Connection
,
server
:
openstack
.
compute
.
v2
.
server
.
Server
)
->
str
:
)
->
str
:
return
list
(
conn
.
compute
.
server_ips
(
server
))[
0
].
address
if
env
.
SSH_IP_VERSION
==
"
4
"
:
return
list
(
conn
.
compute
.
server_ips
(
server
))[
2
].
address
else
:
return
list
(
conn
.
compute
.
server_ips
(
server
))[
0
].
address
def
check_ssh
(
ip
:
str
)
->
None
:
def
check_ssh
(
ip
:
str
)
->
None
:
...
...
This diff is collapsed.
Click to expand it.
run.py
+
4
−
1
View file @
7b03b930
...
@@ -9,7 +9,10 @@ import env
...
@@ -9,7 +9,10 @@ import env
def
get_server_ip
(
conn
:
openstack
.
connection
.
Connection
)
->
str
:
def
get_server_ip
(
conn
:
openstack
.
connection
.
Connection
)
->
str
:
server
=
list
(
conn
.
compute
.
servers
(
name
=
env
.
VM_NAME
,
status
=
"
ACTIVE
"
))[
0
]
server
=
list
(
conn
.
compute
.
servers
(
name
=
env
.
VM_NAME
,
status
=
"
ACTIVE
"
))[
0
]
return
list
(
conn
.
compute
.
server_ips
(
server
))[
0
].
address
if
env
.
SSH_IP_VERSION
==
"
4
"
:
return
list
(
conn
.
compute
.
server_ips
(
server
))[
2
].
address
else
:
return
list
(
conn
.
compute
.
server_ips
(
server
))[
0
].
address
def
execute_script_on_server
(
ssh
:
paramiko
.
client
.
SSHClient
,
script_path
:
str
)
->
int
:
def
execute_script_on_server
(
ssh
:
paramiko
.
client
.
SSHClient
,
script_path
:
str
)
->
int
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment