I am trying to follow the GitLab example code for using kaniko as outlined here. The only thing I have changed is that I am using the v1.7.0-debug tag instead of simply debug.
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:v1.7.0-debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
My build job is stalling out at the following line:
Running with gitlab-runner 14.4.0 (4b9e985a)
on gitlab-runner-gitlab-runner-84d476ff5c-mkt4s HMty8QBu
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: gitlab-runner
Using Kubernetes executor with image gcr.io/kaniko-project/executor:v1.7.0-debug ...
Using attach strategy to execute scripts...
Preparing environment
00:03
Waiting for pod gitlab-runner/runner-hmty8qbu-project-31186441-concurrent-0bbt8x to be running, status is Pending
Running on runner-hmty8qbu-project-31186441-concurrent-0bbt8x via gitlab-runner-gitlab-runner-84d476ff5c-mkt4s...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/...
Created fresh repository.
Checking out 4d05d22b as ci...
Skipping Git submodules setup
Executing "step_script" stage of the job script
It just stops at Executing "step_script" and never moves on. I've researched all over and read through as much documentation as I can find but am unable to troubleshoot this issue.
Setup
Amazon EKS version 1.21
GitLab Runner Helm Chart version 0.34.0
kaniko executor image v1.7.0-debug
This ended up being an issue with how the Kubernetes runner itself was configured inside of the runner configuration toml. The default container image we were using for our runners required a modification to the PATH environment variable so we were using the environment configuration setting to do this as outlined here. It seems that this PATH variable did not include the busybox shell defined in the kaniko debug image. We have since moved that PATH change inside our Docker image where it should've been in the first place and things are working as expected.
Related
I am a beginner and I want to try to integrate Artillery on Gitlab CI/CD, so I looked for Artillery's documentation and found the steps on how to do it. I followed the instructions and use this sample configuration found in the documentation:
artillery:
image:
name: artilleryio/artillery:latest
entrypoint: [""]
script: |
mkdir reports
/home/node/artillery/bin/artillery run --output reports/report.json tests/performance/socket-io.yml
/home/node/artillery/bin/artillery report --output reports/report reports/report.json
artifacts:
paths:
- reports
source: https://www.artillery.io/docs/guides/integration-guides/gitlab-ci-cd
I committed the file and the pipeline starts to run, but after awhile it failed and the error was:
Error: /bin/sh: eval: line 125: /home/node/artillery/bin/artillery: not found
Here's the full log:
Running with gitlab-runner 15.3.0~beta.42.gdb7789ca (db7789ca)
on blue-4.shared.runners-manager.gitlab.com/default J2nyww-s
Preparing the "docker+machine" executor
Using Docker executor with image artilleryio/artillery:latest ...
Pulling docker image artilleryio/artillery:latest ...
Using docker image sha256:27f94fdd50befb4a245e7352f51747330c3b05922133681869c822460f9065a2 for artilleryio/artillery:latest with digest artilleryio/artillery#sha256:1637c7dd4ed15020612faef63f7e0be6200634c7336ad1bf5b60bab4b5f797b0 ...
Preparing environment
00:02
Running on runner-j2nyww-s-project-38396163-concurrent-0 via runner-j2nyww-s-shared-1660008636-37f7076a...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/trial304/artillery-load-test/.git/
Created fresh repository.
Checking out 51807ad5 as main...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
Using docker image sha256:27f94fdd50befb4a245e7352f51747330c3b05922133681869c822460f9065a2 for artilleryio/artillery:latest with digest artilleryio/artillery#sha256:1637c7dd4ed15020612faef63f7e0be6200634c7336ad1bf5b60bab4b5f797b0 ...
$ mkdir reports # collapsed multi-line command
/bin/sh: eval: line 125: /home/node/artillery/bin/artillery: not found
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 127
I've been looking for an answer anywhere, but I can't find any solution to fix the pipeline error.
Your inputs are very welcome, thank you!
if you run this, you can get a shell so that you can view the contents of directories:
docker run -it --rm --entrypoint /bin/sh artilleryio/artillery:latest
Looking at the contents of that directory, I believe what you are looking for is the run command:
/home/node/artillery/bin/run
You can view available command by running run -h. So I believe you are wanting this:
/home/node/artillery/bin/run run --output reports/report.json tests/performance/socket-io.yml
/home/node/artillery/bin/run report --output reports/report reports/report.json
I'm facing an strange behaviour.
Below my .gitlab-ci.yml
image: node:latest
stages:
- release
release:
image: registry.gitlab.com/gitlab-org/release-cli
stage: release
script:
- release-cli create --name release-branch-$CI_JOB_ID --description "desc" --tag-name job-$CI_JOB_ID --ref $CI_COMMIT_SHA
The pipeline is finishing with the following error:
Running with gitlab-runner 14.6.0 (5316d4ac)
on shell-runner gmyChsa1
Preparing the "shell" executor
Using Shell executor...
Preparing environment
Running on myserver.com...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /home/gitlab-runner/builds/gmyChsa1/0/kleyson-sr/changelog-test/.git/
Checking out 21ab4cac as main...
Removing desc.md
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ release-cli create --name release-branch-$CI_JOB_ID --description "desc" --tag-name job-$CI_JOB_ID --ref $CI_COMMIT_SHA
bash: line 137: release-cli: command not found
Cleaning up project directory and file based variables
ERROR: Job failed: exit status 1
The stage release is not pulling and using the release-cli image instead of the global node:latest image.
How can I fix that ?
PS.: Running the pipeline in a local gitlab server.
Running with gitlab-runner 14.6.0 (5316d4ac)
on shell-runner gmyChsa1
Your job is using a GitLab runner configured with the shell executor. This means that the image: directive is ignored entirely.
To use an image: you will need to use a runner configured with a docker/kubernetes/custom executor that supports running jobs in an image.
This has been driving me nuts as I think I'm exactly following the documentation by GitLab for setting up DIND using socket in GitLab Runner so I can run docker commands in Gitlab CI job. But it keeps giving the following error -
Running with gitlab-runner 14.0.0 (3b6f852e)
on Gitlab-HiddenLayer-Group-Runner GosSpAyH
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: gitlab
Using Kubernetes executor with image docker:19.03.12 ...
Using attach strategy to execute scripts...
Preparing environment
00:07
Waiting for pod gitlab/runner-gosspayh-project-27874308-concurrent-0qkp2h to be running, status is Pending
Waiting for pod gitlab/runner-gosspayh-project-27874308-concurrent-0qkp2h to be running, status is Pending
ContainersNotReady: "containers with unready status: [build helper]"
ContainersNotReady: "containers with unready status: [build helper]"
Running on runner-gosspayh-project-27874308-concurrent-0qkp2h via gitlab-runner-gitlab-runner-6984874897-l9z5z...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/GosSpAyH/0/hiddenlayer/hl-tech-blog/.git/
Created fresh repository.
Checking out c48b6257 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ docker info
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
Cleaning up file based variables
00:01
ERROR: Job failed: command terminated with exit code 1
Here is my toml configuration in values.yaml for GitLab Runner installation in my private Kubernetes cluster.
config: |
[[runners]]
url = "https://gitlab.com/"
executor = "docker"
privileged = true
[runners.docker]
tls_verify = false
image = "docker:19.03.12"
privileged = true
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
[runners.cache]
Insecure = false
and my .gitlab-ci.yml is the following -
image: docker:19.03.12
variables:
DOCKER_DRIVER: overlay2
before_script:
- docker info
- echo "$CI_REGISTRY_USER | $CI_REGISTRY_PASSWORD | $CI_REGISTRY"
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build:
stage: build
# Default branch leaves tag empty (= latest tag)
# All other branches are tagged with the escaped branch name (commit ref slug)
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
else
tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" -f deploy/Dockerfile .
- docker push "$CI_REGISTRY_IMAGE${tag}"
Note: I'm intentionally leaving the docker-dind service from the .gitlab-ci.yaml file because the documentation says it is not needed.
Additional Information:
Kubernetes Version: 1.20
Gitlab Runner Version: 14.0.0
Running docker commands in CIs is a pretty common workflow and I'm starting to think if it's this difficult to setup, I may as well go back to old ways with using Jenkins.
See if upgrading to GitLab 14.3 (September 2021) would help:
Support for Kubernetes 1.20
In GitLab 14.3, we added support to Kubernetes version 1.20.
GitLab users can benefit from having recent cluster versions in many features, such as the GitLab Kubernetes Agent, Auto DevOps and Cluster Management Project.
You can find the list of supported versions and related timelines in our documentation.
See Documentation and Epic.
Description: Attempting to create a simple pipeline to create a cloudformation stack in an aws account.
Looks like its failing to find a script referenced in the documentation below, but I thought cloudformation cli commands were now supported in gitlab 13.9?
Gitlab Version:13.9
CI/CD variables setup:
See required ones here.
https://docs.gitlab.com/ee/ci/cloud_deployment/
gitlab yaml file
variables:
REGION: us-east-2
CI_AWS_CF_STACK_NAME: 'gitlabTestStack'
CI_AWS_CF_CREATE_STACK_FILE: 'aws/aws-test-stack.yaml'
deploy:
stage: deploy
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
script:
- gl-cloudprovision create-stack
Output
on PDOCK009-Runner-TestAutomation6 UrKKxyCW
Preparing the "docker" executor
Using Docker executor with image registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest ...
Pulling docker image registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest ...
Using docker image sha256:a39347bds862894f38dabf38f1fddfa0avbc1dc3070ca12400fd0a8d33e7178 for registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest ...
Preparing environment
Running on runner-urkkxycw-project-1427-concurrent-0 via 9cdf65ce059d...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/jackoneill/aws-deploy/.git/
Created fresh repository.
From <URL>
* [new ref] fbf7a9b966f0be1e2db8fbf7a983c02c90ed8saxc2323x -> refs/pipelines/65421
* [new branch] master -> origin/master
Checking out fbf7a9 master...
Skipping Git submodules setup
Restoring cache
Downloading artifacts
00:02
Running before_script and script
00:02
$ gl-cloudprovision create-stack
/usr/bin/bash: line 103: gl-cloudprovision: command not found
Running after_script
Uploading artifacts for failed job
00:02
ERROR: Job failed: exit code 1
Looks like you need to change image to
image: 'registry.gitlab.com/gitlab-org/cloud-deploy/aws-cloudformation:latest'
and script from
- gl-cloudprovision create-stack
to
- gl-cloudformation create-stack
I would like to build and push docker images to my local nexus repo with GitLab CI
This is my current CI file:
image: docker:latest
services:
- docker:dind
before_script:
- docker info
- docker login -u some_user -p nexus-rfit some_host
stages:
- build
build-deploy-ubuntu-image:
stage: build
script:
- docker build -t some_host/dev-image:ubuntu ./ubuntu/
- docker push some_host/dev-image:ubuntu
only:
- master
when: manual
I also have a job for an alpine docker image, but when I want to run any of it it's failing with the following error:
Checking out 13102ac4 as master...
Skipping Git submodules setup
$ docker info
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERROR: Job failed: exit code 1
So technically the docker daemon in the image isn't running, but I have no idea why.
GitLab folks have a reference on their docs about using docker-build inside docker-based jobs: https://docs.gitlab.com/ce/ci/docker/using_docker_build.html#use-docker-in-docker-executor. Since you seem to have everything in place (i.e. the right image for the job and the additional docker:dind service), it's most likely a runner-config issue.
If you look at the second step in the docs:
Register GitLab Runner from the command line to use docker and privileged mode:
[...]
Notice that it's using the privileged mode to start the build and service containers. If you want to use docker-in-docker mode, you always have to use privileged = true in your Docker containers.
Probably you're using a runner that was not configured in privileged mode and hence can't properly run the docker daemon inside. You can directly edit the /etc/gitlab-runner/config.toml on your registered runner to add that option.
(Also, read on the section on the docs for some more info about the performance related to the storage driver you choose/your runner supports when using dind)