Compare commits

...

1 Commits

Author SHA1 Message Date
Thomas Klaehn
fce506d77f description of gitlab runner installation 2016-12-13 14:24:54 +01:00
4 changed files with 84 additions and 234 deletions

View File

@ -4,6 +4,8 @@ DEP := \
config/headfoot.tex \ config/headfoot.tex \
config/sourcelst.tex \ config/sourcelst.tex \
content.tex \ content.tex \
gitlab-runner.tex \
title.tex \
Makefile Makefile
all: $(MAIN) all: $(MAIN)

View File

@ -1,241 +1,66 @@
\section{Installation} \section{Introduction}
\subsection{SD card preparation} Gitlab-ci uses so called runners to execute the build jobs defined in the build
\subsubsection{Partitions} job file of a repository. A runner is a seperate tool and can be installed on
Format the SD card with two new partitions: any machine. The type of connection is configurable. The intentions of these concept are:\\
\lstsetbash
\begin{lstlisting}
fdisk /dev/mmcblk0
\end{lstlisting}
\begin{enumerate}
\item Type \textbf{o} to erase all former partitions
\item Type \textbf{p} to list all existing partitions
\item Type \textbf{n}, then \textbf{p} to create the boot partition. Press
\textbf{RETURN} to accept the first sector, then \textbf{+100M} for the
last sector
\item Type \textbf{t}, then \textbf{c} to set the partition type to FAT32
\item Type \textbf{n}, then \textbf{p} to create the root partition. Press
\textbf{RETURN} to accept the first sector, then \textbf{RETURN} for the
last sector
\item Type \textbf{w} to write the new partition table
\end{enumerate}
\subsubsection{File systems}
Create the file systems for the new partitions:
\begin{lstlisting}
mkfs.vfat /dev/mmcblk0p1
mkfs.ext4 /dev/mmcblk0p2
\end{lstlisting}
Create mount points and mount the new partitions:
\begin{lstlisting}
mkdir boot
mkdir root
mount /dev/mmcblk0p1 boot
mount /dev/mmcblk0p2 root
\end{lstlisting}
\subsubsection{Download and extract root file system}
\begin{lstlisting}
wget http://archlinuxarm.org/os/\
ArchLinuxARM-rpi-2-latest.tar.gz
bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
sync
mv root/boot/* boot
\end{lstlisting}
Enable ssh root login:
\begin{lstlisting}
vim root/etc/ssh/sshd\_config
\end{lstlisting}
Find \texttt{\#PermitRootLogin yes} and uncommend it
\begin{lstlisting}
PermitRootLogin yes
\end{lstlisting}
Unmount both partitions
\begin{lstlisting}
umount boot root
\end{lstlisting}
\section{Configuration}
\subsection{User management}
\subsubsection{Create new user}
\begin{lstlisting}
useradd -m -g users -G wheel -s /bin/bash tkl
\end{lstlisting}
\begin{tabular}{ l l }
\texttt{-m} & create user name home directory\\
\texttt{-g} & initial login group\\
\texttt{-G} & list of supplementary groups - comma separated\\
\texttt{-s} & path and file name of default login shell\\
\end{tabular}\\
Set password for the new user:
\begin{lstlisting}
passwd tkl
\end{lstlisting}
Enable wheel group members as sudoers:
\begin{lstlisting}
EDITOR=vim visudo
\end{lstlisting}
Uncomment:
\begin{lstlisting}
%wheel ALL=(ALL) ALL
\end{lstlisting}
\subsection{Aliasing}
\begin{lstlisting}
cd ~
vi .bashrc
\end{lstlisting}
Add:\\
\texttt{alias vi='vim'}
\subsection{Customize vim}
Edit \texttt{.vimrc}:
\begin{lstlisting}
syntax on "Syntax highlightning
set number "Line numbering
\end{lstlisting}
\subsection{Wifi}
Configure wifi network:
\begin{lstlisting}
wifi-menu
\end{lstlisting}
Enable wifi network permanent:
\begin{lstlisting}
netctl enable wlan0-<network_name>
\end{lstlisting}
\subsubsection{Deactivate wifi device sleep mode}
\begin{lstlisting}
pacman -S iw
echo ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", \
RUN+="/usr/bin/iw dev \%k set power\_save off\" \
> etc/udev/rules.d/70-wifi-powersave.rules
\end{lstlisting}
\subsection{Ssh key login}
\begin{itemize} \begin{itemize}
\item Create \texttt{.ssh/} folder in users home directory \item{remove (build) environmental dependency from ci server}
\item Copy public key file (i.e. \texttt{id\_rsa.pub}) into \texttt{.ssh} \item{multipe runners to parallize multiple builds}
folder
\item Authorize public key:
\begin{lstlisting}
cat id_rsa.pub >> authorized_keys
\end{lstlisting}
\end{itemize} \end{itemize}
The Runner has to be installed on a machine with a proper environment (compiler,
...) installed for the dedicated project it is used for. Figure \ref{fig:gitlab-runner-interaction} illustrates
the interaction of a local workstation, the gitlab(-ci) server and the
gitlab-ci-multi-runner.
\begin{figure}
\begin{center}
\input{gitlab-runner.tex}
\caption{Gitlab-ci - runner interaction}
\label{fig:gitlab-runner-interaction}
\end{center}
\end{figure}
\subsection{Interfaces} \section{Installation of gitlab-ci-multi-runner}
\subsubsection{I2C} The Installation of the runner depends on the operating system of the host and
To enable i2c interface edit \texttt{/boot/config.txt}. \\ is described here: \hyperlink{https://docs.gitlab.com/runner/install/}{\texttt{https://docs.gitlab.com/runner/install}}
Uncomment \texttt{\#device\_tree\_param=i2c\_arm=on}\\ \section{Installation of a dedicated runner}
Load i2c modules while boot: \subsection{Prerequisites}
\begin{lstlisting} To install a dedicated runner prerequisites has to be fullfilled:
/etc/modules-load.d/raspberry.conf
i2c-dev
i2c-bcm2708
\end{lstlisting}
Install package \texttt{i2c-tools}
Test i2c bus after reboot:
\begin{lstlisting}
i2cdetect -y 1
\end{lstlisting}
Set permissions for i2c device access:
\begin{lstlisting}
/etc/udev/rules.d/99-i2c.rules
KERNEL=="i2c-1", MODE="0777"
\end{lstlisting}
\subsubsection{SPI}
To enable spi interface edit \texttt{/boot/config.txt}. \\
Uncomment \texttt{\#device\_tree\_param=spi=on}
\subsubsection{GPIO}
Create an udev rule to enable others than root accessing the gpio files:
\begin{lstlisting}
/etc/udev/rules.d/98-gpio.rules
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c 'chown -R root:gpio\
/sys/class/gpio; chmod -R 0777 /sys/class/gpio; chown -R \
root:gpio /sys/devices/virtual/gpio; chmod -R 0777 \
/sys/devices/virtual/gpio'"
\end{lstlisting}
\subsection{tools}
\begin{itemize} \begin{itemize}
\item \texttt{fakeroot} \item{Url of gitlab ci coordinator}
\item \texttt{gcc} \item{Registation token of that server}
\item \texttt{git} \item{Tags - if the build job defines tags to identify runners}
\item \texttt{make}
\item \texttt{patch}
\item \texttt{python2, python2-pip}
\item \texttt{wget}
\end{itemize} \end{itemize}
\subsection{Hostname} These two informations can be gathered at the runners section of the project's
gitlab repository the runner is installed for. That section is accessible using:\texttt{<gitlab-url>/<project-path>/runners}\\
\textbf{Example:}\\
\texttt{https://novgit05.novero.com/agricola/agricola/runners}
\subsection{Register}
Open a shell an type: \texttt{gitlab-ci-multi-runner register}. An interactive
shell opens and requests some inputs (see prequisites).
\lstsetdefault
\begin{lstlisting} \begin{lstlisting}
echo "hostname" > /etc/hostname user@dabbld01:~$ sudo gitlab-ci-multi-runner register
Running in system-mode.
Please enter the gitlab-ci coordinator URL
(e.g. https://gitlab.com/):
https://novgit05.novero.com/ci
Please enter the gitlab-ci token for this runner:
<secret-token>
Please enter the gitlab-ci description for this runner:
[dabbld01]:
my-runner
Please enter the gitlab-ci tags for this runner (comma
separated):
Please enter the executor: shell, docker+machine,
docker-ssh+machine, kubernetes, docker, docker-ssh,
parallels, ssh, virtualbox:
shell
Runner registered successfully. Feel free to start it,
but if it's running already the config should be
automatically reloaded!
\end{lstlisting} \end{lstlisting}
\section{Applications} \subsection{Start as service}
\subsection{I2C-OLED} Open a shell an type: \texttt{gitlab-ci-multi-runner start}
\subsubsection{Oled Test application}
Clone test application:
\begin{lstlisting}
git clone git@dabgit01.internal.novero.com:raspberry/\
oledpi.git
\end{lstlisting}
\subsubsection{Install driver}
Clone oled driver:
\begin{lstlisting}
git clone https://github.com/rm-hull/ssd1306.git
\end{lstlisting}
Install it:
\begin{lstlisting}
python2 setup.py install
\end{lstlisting}
\subsubsection{Dependencies}
\begin{itemize}
\item \texttt{python-smbus/python2-smbus} (AUR)
\item \texttt{i2c-tool-git} (AUR)
\item \texttt{libjpeg-turbo}
\item \texttt{pillow} install using pip \texttt{(pip/pip2 install pillow)}
\end{itemize}
\subsection{Weatherpi}
\subsubsection{Usb weatherstation test application}
Clone test application:
\begin{lstlisting}
git clone git@dabgit01.internal.novero.com:raspberry/\
weatherpi.git
\end{lstlisting}
\subsubsection{Dependencies}
\begin{itemize}
\item \texttt{python2-pyusb} (AUR) (edit \texttt{PKGBUILD} and add
\texttt{'armv7h'} to \texttt{arch})
\item \texttt{libusb-compat}
\end{itemize}
\subsection{MQTT Broker}
Install mosquitto (AUR)\\
Install paho-mqtt client library:\\
\begin{lstlisting}
pip2 install paho-mqtt
\end{lstlisting}
Create config file:
\begin{lstlisting}
cp /etc/mosquitto.conf.example /etc/mosquitto.conf
\end{lstlisting}
Start mosquitto broker service:
\begin{lstlisting}
systemctl enable mosquitto.service
systemctl start mosquitto.service
\end{lstlisting}
\subsubsection{Test}
Subscribe to a topic:
\begin{lstlisting}
mosquitto_sub -t "topic/path"
\end{lstlisting}
Populate a message:
\begin{lstlisting}
mosquitto_pub -t "topic/path" -m "message payload"
\end{lstlisting}

23
gitlab-runner.tex Normal file
View File

@ -0,0 +1,23 @@
\psset{griddots=0,gridlabels=8pt,subgriddiv=5}
\psset{xunit=10mm,yunit=10mm}
\newcommand{\clr}{black}
\psset{fillcolor=white}
\psset{fillstyle=solid}
\psset{linecolor=\clr}
\psset{framearc=.5}
\psset{framesep=20pt}
\psset{arrowsize=10pt}
\begin{pspicture}(12,6)
% \psgrid
\rput(2.5,5){\psframebox{\textcolor{\clr}{Gitlab-ci server}}}
\rput(2.5,1){\psframebox{\textcolor{\clr}{Local workstation}}}
\rput(8.5,3){\psframebox{\textcolor{\clr}{Gitlab-ci-multi-runner}}}
\pscurve[fillstyle=none]{->}(4.6,5)(7.2,5)(8.5,3.9)
\pscurve[fillstyle=none]{<-}(3,4.1)(4,3.2)(5.8,3)
\pscurve[fillstyle=none]{<-}(8,2.1)(7.7,1.4)(8.5,.8)(9.3,1.4)(9,2.1)
\psline{->}(1,1.9)(1,4.1)
\rput(7,5.3){build trigger}
\rput(.5,3){push}
\rput(4,2.6){build result}
\rput(8.5,.5){build}
\end{pspicture}

View File

@ -1,4 +1,4 @@
\newcommand{\docname}{HowTo} \newcommand{\docname}{Gitlab-ci}
\newcommand{\prjname}{arch linux on raspberry pi} \newcommand{\prjname}{gitlab-ci-multi-runner}
\newcommand{\docversion}{0.1} \newcommand{\docversion}{0.1}
\newcommand{\docauthor}{Thomas Klaehn} \newcommand{\docauthor}{Thomas Klaehn}