title: How can I deploy something to a k8s cluster via a k8s gitlab-ci runner?
body: <p><strong>cat /etc/redhat-release:</strong></p>
  
  <pre><code>CentOS Linux release 7.2.1511 (Core)
  </code></pre>
  
  <p><strong>docker version:</strong></p>
  
  <pre><code>Client:
   Version:         1.13.1
   API version:     1.26
   Package version: &lt;unknown&gt;
   Go version:      go1.8.3
   Git commit:      774336d/1.13.1
   Built:           Wed Mar  7 17:06:16 2018
   OS/Arch:         linux/amd64
  
  Server:
   Version:         1.13.1
   API version:     1.26 (minimum version 1.12)
   Package version: &lt;unknown&gt;
   Go version:      go1.8.3
   Git commit:      774336d/1.13.1
   Built:           Wed Mar  7 17:06:16 2018
   OS/Arch:         linux/amd64
   Experimental:    false
  </code></pre>
  
  <p><strong>kubectl version:</strong></p>
  
  <pre><code>Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.5", GitCommit:"f01a2bf98249a4db383560443a59bed0c13575df", GitTreeState:"clean", BuildDate:"2018-03-19T15:59:24Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
  Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T20:55:30Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
  </code></pre>
  
  <p><strong>gitlab version:</strong> 10.6-ce</p>
  
  <p><strong>gitlab runner image:</strong> gitlab/gitlab-runner:alpine-v10.3.0</p>
  
  <p>I just integrated a kubernetes cluster (not GKE, just a k8s cluster deployed by myself) to a gitlab project, and then installed a gitlab-runner on which.</p>
  
  <p>All of this, followed <a href="http://gitlab.xinpinget.com/help/user/project/clusters/index.md#adding-an-existing-kubernetes-cluster" rel="nofollow noreferrer">Adding an existing Kubernetes cluster</a>.</p>
  
  <p>After that, I added a <code>.gitlab-ci.yml</code> with a single stage, and pushed it to the repo. Here is the contents:</p>
  
  <pre><code>build-img:
    stage: docker-build
    script:
  #    - docker build -t $CONTAINER_RELEASE_IMAGE .
  #    - docker tag $CONTAINER_RELEASE_IMAGE $CONTAINER_LATEST_IMAGE
  #    - docker push $CONTAINER_IMAGE
      - env | grep KUBE
      - kubectl --help
    tags:
      - kubernetes
    only:
      - develop
  </code></pre>
  
  <p>Then I got this:</p>
  
  <pre><code>$ env | grep KUBE
  KUBERNETES_PORT_443_TCP_PORT=443
  KUBERNETES_PORT=tcp://10.96.0.1:443
  KUBERNETES_SERVICE_PORT=443
  KUBERNETES_SERVICE_HOST=10.96.0.1
  KUBERNETES_PORT_443_TCP_PROTO=tcp
  KUBERNETES_SERVICE_PORT_HTTPS=443
  KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1
  KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443
  $ kubectl --help
  /bin/bash: line 62: kubectl: command not found
  ERROR: Job failed: error executing remote command: command terminated with non-zero exit code: Error executing in Docker Container: 1
  </code></pre>
  
  <p>The <code>kubectl</code> was not installed in the runner yet, and some env vars like <code>KUBE_TOKEN</code>, <code>KUBE_CA_PEM_FILE</code> or <code>KUBECONFIG</code> are not found, neither(see <a href="https://docs.gitlab.com/ee/user/project/clusters/index.html#deployment-variables" rel="nofollow noreferrer">Deployment variables</a>).</p>
  
  <p>Searched the official docs of gitlab, got nothing.</p>
  
  <p>So, how could I deploy a project via this runner?</p>