<p>I'm new to gitlab ci/cd. I want to deploy gitlab-runner on kubernetes, and I use kubernetes to create two resource:</p>

<p><code>gitlab-runner-configmap.yaml</code></p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: gitlab-runner
  namespace: gitlab
data:
  config.toml: |
    concurrent = 4

    [[runners]]
      name = "Kubernetes Runner"
      url = "http:my-gitlab.com/ci"
      token = "token...."
      executor = "kubernetes"
      tag = "my-runner"
      [runners.kubernetes]
        namespace = "gitlab"
        image = "busybox"
</code></pre>

<p><code>gitlab-runner-deployment.yaml</code></p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: gitlab-runner
  namespace: gitlab
spec:
  replicas: 1
  selector:
    matchLabels:
      name: gitlab-runner
  template:
    metadata:
      labels:
        name: gitlab-runner
    spec:
      containers:
      - args:
        - run
        image: gitlab/gitlab-runner:v11.11.3
        imagePullPolicy: Always
        name: gitlab-runner
        volumeMounts:
        - mountPath: /etc/gitlab-runner
          name: config
        - mountPath: /etc/ssl/certs
          name: cacerts
          readOnly: true
      restartPolicy: Always
      volumes:
      - configMap:
          name: gitlab-runner
        name: config
      - hostPath:
          path: /usr/share/ca-certificates/mozilla
        name: cacerts
</code></pre>

<p>The problem is that after creating the two resource using <code>kubectl apply</code>. I can't see the runner instance in <code>http://my-gitlab.com/admin/runners</code>. I suspect the reason is that I have not register the runner. And I enter the <code>runner</code> pod <code>pod/gitlab-runner-69d894d7f8-pjrxn</code> and register the runner manually through <code>gitlab-runner register</code>, after that I can see the runner instance in <code>http://my-gitlab.com/admin/runners</code>. </p>

<blockquote>
  <p>So am I do anything wrong? Or is it has to manually register the runner inside the pod?</p>
</blockquote>

<p>Thanks.</p>

<p>Indeed you need to explicitly <strong>register</strong> runner on the GitLab server.<br>
For example via:</p>

<pre><code>gitlab-runner register --non-interactive \
    --name $RUNNER_NAME \
    --url $GITLAB_URL \
    --registration-token $GITLAB_REGISTRATION_TOKEN \
    --executor docker \
    --docker-image $DOCKER_IMAGE_BUILDER \
    --tag-list $GITLAB_RUNNER_TAG_LIST \
    --request-concurrency=$GITLAB_RUNNER_CONCURRENCY
</code></pre>

<p>You can pass most of its configuration as arguments.<br>
If you didn't create <code>config.toml</code>, it will generate it for you, including the runner token received from the server on registration.</p>

<p><strong>However</strong>,<br>
as you use Kubernetes, there is a simpler way.<br>
GitLab provides great integration with Kubernetes, all you need to do is attach your cluster once to your project\group: <a href="https://docs.gitlab.com/ee/user/project/clusters/#adding-an-existing-kubernetes-cluster" rel="nofollow noreferrer">https://docs.gitlab.com/ee/user/project/clusters/#adding-an-existing-kubernetes-cluster</a></p>

<p>And then installing a runner is just few clicks in the UI, via what they call "managed apps": <a href="https://docs.gitlab.com/ee/user/clusters/applications.html#gitlab-runner" rel="nofollow noreferrer">https://docs.gitlab.com/ee/user/clusters/applications.html#gitlab-runner</a>  </p>

<p>On this last page you can find links to the Helm chart that they use.<br>
So you can even use it directly yourself.<br>
And you can see there specifically call to <strong>register</strong>:
<a href="https://gitlab.com/charts/gitlab-runner/blob/a4d0201600d0b661c27df8edd4d7c43bde1b835e/templates/configmap.yaml#L65" rel="nofollow noreferrer">configmap.yaml#L65</a></p>
