<p>This is my first time using GitLab for EKS and I feel so lost. I've been following the docs and so far I</p>
<ul>
<li>Created a project on GitLab that contains my kubernetes manifest files</li>
<li>Created a config.yaml in that project in the directory .gitlab/agents/stockagent</li>
</ul>
<p>Here's the <strong>config.yaml</strong>, my project name is &quot;Stock-Market-API-K8s&quot; and my k8s manifests are in the root directory of that project</p>
<pre class="lang-yaml prettyprint-override"><code>ci_access:
  projects:
    - id: &quot;root/Stock-Market-API-K8s&quot;
</code></pre>
<p>In my root directory of my project, I also have a <strong>.gitlab-ci.yml</strong> file and here's the contents of that</p>
<pre class="lang-yaml prettyprint-override"><code>deploy:
  image:
    name: mpriv32/stock-api:latest
    entrypoint: ['']
  script:
    - kubectl config get-contexts
    - kubectl config use-context .gitlab/agents/stockagent
    - kubectl get pods
</code></pre>
<p>Using the default example from the docs, it seems that the get-contexts script is the one that failed. Here's the full error from my logs</p>
<pre class="lang-none prettyprint-override"><code>Executing &quot;step_script&quot; stage of the job script
00:01
Using docker image sha256:58ddf823e9d7ee4c0e75779b7e01dab9b11ac0d985d1b2d2fe6c6b95a849573d for mpriv32/stock-api:latest with digest mpriv32/stock-api@sha256:a2e79a2c3a57327f93e36ec55297a606626e4dc8d72e469dd4dc2f3c1f589bac ...
$ kubectl config get-contexts
/bin/bash: line 123: kubectl: command not found
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
</code></pre>
<p>Here's my <strong>job.yaml</strong> file for my kubernetes pod, just in case it plays a factor at all</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: stock-api
  labels:
    app: stock-api

spec:
  containers:
  - name: stock-api
    image: mpriv32/stock-api:latest
    envFrom:
    - secretRef:
        name: api-credentials
  restartPolicy: Never
</code></pre>

MP32
<p>In your case, I guess the image(mpriv32/stock-api:latest) that you are using doesn't have a dependency kubectl as a global executable, please use an image as an example - bitnami/kubectl which &quot;contains&quot; kubectl</p>
<pre><code>deploy:
  image:
    name: bitnami/kubectl
</code></pre>
<p>the image keyword is the name of the Docker image the Docker executor uses to run CI/CD jobs.
For more information <a href="https://docs.gitlab.com/ee/ci/docker/using_docker_images.html" rel="nofollow noreferrer">https://docs.gitlab.com/ee/ci/docker/using_docker_images.html</a></p>
<p>Or you can build your docker image on top of bitnami/kubectl</p>
<pre><code>FROM bitnami/kubectl:1.20.9 as kubectl

FROM ubuntu-or-whatever-image:tag

# Do whatever you need to with the
# ubuntu-or-whatever-image:tag image, then:

COPY --from=kubectl /opt/bitnami/kubectl/bin/kubectl /usr/local/bin/
</code></pre>
<p>Or you can go with the approach of building an image from the scratch by
installing there the dependencies that you are using</p>
<p>smth like</p>
<pre><code>FROM ubuntu:18.10

WORKDIR /root

COPY bootstrap.sh ./

RUN apt-get update &amp;&amp; apt-get -y install --no-install-recommends \
    gnupg \
    curl \
    wget \
    git \
    apt-transport-https \
    ca-certificates \
    zsh \
    &amp;&amp; rm -rf /var/lib/apt/lists/*

ENV SHELL /usr/bin/zsh

# Install kubectl
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - &amp;&amp; \
    echo &quot;deb https://apt.kubernetes.io/ kubernetes-xenial main&quot; | tee -a /etc/apt/sources.list.d/kubernetes.list &amp;&amp; \
    apt-get update &amp;&amp; apt-get -y install --no-install-recommends kubectl
</code></pre>
