<p>I´m trying to download code from gitlab to kubernetes. I have created an ubuntu docker image.</p>

<p>Here is the yaml file. I have created a token from gitlab to download the rep. The problem is that i don´t know where to copy the gitlab token to allow kubernetes to download the code ??</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: syncrepo-gitlab
spec:
  containers:
  - image: fake.eu.io/testseq-362663/ubuntu:latest
    name: gitlab
    volumeMounts:
    - name: git-source
      mountPath: /tmp/git
    env:
    - name: GIT_SYNC_REPO
      value: https://myrep/scripts.git
    - name: GIT_SYNC_DEST
      value: git-sync
    - name: GIT_SYNC_SSH
      value: "true"
  volumes:
  - name: git-source
    emptyDir: {}
</code></pre>

david
<p><strong>Option 1</strong>: Pass it directly as an environment variable:</p>

<pre><code>env:
    - name: GIT_DEPLOY_TOKEN_USERNAME
      value: &lt;deploy_token_username&gt;
    - name: GIT_DEPLOY_TOKEN_PASSWORD
      value: &lt;deploy_token_password&gt;
</code></pre>

<p>This is not recommended, because anyone that can see your Pod manifest will see your Gitlab token.</p>

<p><strong>Option 2</strong> Create a <a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer">secret</a> for the token and mount it to the pod.</p>

<pre><code>kubectl create secret generic gitlab-deploy-token -–from-literal=username=&lt;deploy_token_username&gt; -–from-literal=password=&lt;deploy_token_password&gt;
</code></pre>

<p>This will create an encoded secret in your k8s namespace.</p>

<p>To mount the secret:</p>

<pre><code>  - name: GITLAB_DEPLOY_TOKEN_USERNAME
    valueFrom:
      secretKeyRef:
        name: gitlab-deploy-token
        key: username
  - name: GITLAB_DEPLOY_TOKEN_PASSWORD
    valueFrom:
      secretKeyRef:
        name: gitlab-deploy-token
        key: password
</code></pre>

<p>Now, in your pod, you can:</p>

<pre><code>git clone http://$GITLAB_DEPLOY_TOKEN_USERNAME:$GITLAB_DEPLOY_TOKEN_PASSWORD@gitlab.example.com/tanuki/awesome_project.git
</code></pre>

<blockquote>
  <p>Note: Special characters such as $, *, and ! require escaping. If the
  password you are using has special characters, you need to escape them
  using the \ character. For example, if your actual password is
  S!B*d$zDsb, you should execute the command this way: kubectl create
  secret generic dev-db-secret --from-literal=username=devuser
  --from-literal=password=S!B\*d\$zDsb You do not need to escape
  special characters in passwords from files (--from-file).</p>
</blockquote>
