<p>I have some specific questions regarding <code>gitlab-ci</code> and <code>runner</code>:</p>

<ol>
<li><p>If my specific runner is configured in kubernetes cluster then how code mirroring happens into runner from Gitlab code repository </p></li>
<li><p>How does the build happens in runner when it is configured within kubernetes cluster?</p></li>
<li><p>When using any docker image in my .gitlab-ci.yml, how does those images are pulled by runner and how does commands mentioned within "script" tag are executed into those docker containers? Does runner creates pods within the kubernetes cluster (where runner is configured) with the image mentioned within .gitlab-ci.yml, and executes commands within those containers?</p></li>
<li><p>Any additional explanations or references to learning material on how Gitlab runner works internally is highly appreciated.</p></li>
</ol>

<p>I'm assuming when you say your GitLab Runner is configured in Kubernetes you mean you're using the Kubernetes executor. I marked the sections relevant to your questions. </p>

<p><strong>(1)</strong> GitLab CI pulls the code from the repository (if public it's not an issue, but you can also use a <a href="https://docs.gitlab.com/runner/security/index.html#usage-of-private-docker-images-with-if-not-present-pull-policy" rel="nofollow noreferrer">private registry</a>). Basically a helper image is used to clone the repository and download any artifacts into a container.</p>

<p>The Kubernetes executor lets you use an existing Kubernetes cluster to execute your pipeline/build step by calling the Kubernetes cluster API and creating a new Pod, with both build and services containers for each job. <strong>(3)</strong></p>

<p>A <a href="https://docs.gitlab.com/runner/executors/kubernetes.html" rel="nofollow noreferrer">more detailed view of the steps</a> a Runner takes: </p>

<blockquote>
  <ul>
  <li>Prepare: Create the Pod against the Kubernetes Cluster. This creates the containers required for the build and services to run.</li>
  <li>Pre-build: Clone, restore cache and download artifacts from previous stages. This is run on a special container as part of the Pod. <strong>(2)</strong></li>
  <li>Build: User build.</li>
  <li>Post-build: Create cache, upload artifacts to GitLab. This also uses the special container as part of the Pod.</li>
  </ul>
</blockquote>

<p>The <a href="https://gitlab.com/gitlab-org/gitlab-runner/tree/master" rel="nofollow noreferrer">GitLab repository for the runners</a> might also be interesting for you.</p>
