skip to Main Content

I’m working on building a Gitlab-CI pipeline that deploys an Spring Boot application to a Kubernetes cluster hosted on DigitalOcean.
Fortunately, I’m right at the beginning of doing this so there’s very little bloat, and I figured I’d just test that I had everything wired correctly before I went ahead and built some crazy stuff.

Essentially I’ve got a Gitlab-CI job that pulls this image: digitalocean/doctl:1.87.0 and I then attempt to run a number of doctl commands in the script section of the job. The results of this very simple "deploy" script:

deploy-to-kubernetes:
  stage: deploy
  image: digitalocean/doctl:1.87.0
  script:
    - doctl --help

looked like this:

Error: unknown command "sh" for "doctl"
Run 'doctl --help' for usage.
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 255

After doing a bit of digging and googling and searching and head-scratching, I hit upon this post, and figured it may apply to the doctl image too, so I then updated my Gitlab-CI job to this:

deploy-to-kubernetes:
  stage: deploy
  image:
    name: digitalocean/doctl:1.87.0
    entrypoint: [""]
  script:
    - doctl --help

and the result was this:

$ doctl --help
/bin/bash: line 128: doctl: command not found
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 1

I’m pretty sure I’m doing something absolutely idiotic, but I can’t figure out what that is, so if anybody could help out that would be really appreciated, and if you need more information, let me know.

FYI: This is my first question ever posted on StackOverflow, so any feedback on what I need to change, improve etc is greatly appreciated!

Thanks!

3

Answers


  1. $PATH contains default values in this image. But doctl available in /app/doctl. So you can use it this way: /app/doctl %command% (eg, /app/doctl version)

    Login or Signup to reply.
  2. I ran into the same problem and opted to just use a regular alpine container and install the doctl tool myself. It’s a workaround though.

    deploy-to-kubernetes:
      stage: deploy
      image: debian:11.6-slim
      before_script:
        - apt update && apt -y upgrade && apt-get install -y curl
        - curl -Lo doctl.tar.gz https://github.com/digitalocean/doctl/releases/download/v1.91.0/doctl-1.91.0-linux-amd64.tar.gz && tar xf doctl.tar.gz
        - chmod u+x doctl
        - mv doctl /usr/local/bin/doctl
      script:
        - doctl --help
    
    Login or Signup to reply.
  3. I had the same issue, here is job that works for me:

    "Deploy to DigitalOcean":
      image:
        name: digitalocean/doctl:latest
        entrypoint: [""]
      stage: deploy
      needs:
        - job: "Test Docker image"
      script:
        - /app/doctl auth init
        - /app/doctl apps create-deployment $DIGITALOCEAN_STUDENT_BACKEND_ID
      only:
        - master
    

    But it also requires DIGITALOCEAN_ACCESS_TOKEN variable with DigitalOcean token

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search