Git Product home page Git Product logo

delegate-dockerfile's Introduction

Delegate Dockerfile

This repository provides the Harness delegate Dockerfile. You can use this Dockerfile to build custom delegate images.

The repository includes the following versions of the delegate Dockerfile. Please note that if you are building and using your own images then turn auto upgrade off for kubernetes delegates. Read documentation at https://developer.harness.io/docs/platform/Delegates/install-delegates/delegate-upgrades-and-expiration

Dockerfile

Use Dockerfile to create the delegate image with tools. This image includes the following tools by default.

  • kubectl v1.24.3
  • helm v2.13.1
  • helm v3.1.2
  • helm v3.8.0
  • go-template v0.4.2
  • harness-pywinrm v0.4-dev
  • chartmuseum v0.15.0
  • tf-config-inspect v1.2
  • oc v4.2.16
  • kustomize v4.5.4
  • scm

Dockerfile-minimal

Use Dockerfile-minimal to create delegate images without tools. This image includes only the SCM client tool.

Dockerfile-ubuntu

Use Dockerfile-ubuntu to create delegate delegate images which are ubuntu based. This image includes all the same tools of default Dockerfile

:::note You can also replace the existing tools with those that you prefer to use for CI/CD. :::

Build the image

For building the image you need two arguments

  1. TARGETARCH (amd64/arm64)
  2. The build version of delegate

You can get the build version that you should use for your account using the API documented at https://apidocs.harness.io/tag/Delegate-Setup-Resource#operation/publishedDelegateVersion

To learn about the support for delegate version and expiry policy visit https://developer.harness.io/docs/platform/Delegates/install-delegates/delegate-upgrades-and-expiration#delegate-expiration-policy

Here is an example script to get the version which uses curl to fetch and jq to parse

latest_version=$(curl -X GET 'https://app.harness.io/gateway/ng/api/delegate-setup/latest-supported-version?accountIdentifier=<replace_with_account_ideentifier>' -H 'x-api-key: <replace_with_api_key>')

# Extract the build version using jq and some basic string manipulation
build_version=$(echo $latest_version | jq -r '.resource.latestSupportedVersion' | cut -d '.' -f 3)

# Print the build version
echo $build_version

To build your custom image, use the appropriate command and use the build_version you got from the above command:

Dockerfile

docker build -t {TAG} -f Dockerfile --build-arg TARGETARCH=amd64 --build-arg DELEGATEVERSION=<version_from_previous_step> .

Dockerfile-minimal

docker build -t {TAG} -f Dockerfile-minimal --build-arg TARGETARCH=amd64 --build-arg DELEGATEVERSION=<version_from_previous_step> .

Build Image with Custom CA certs

To support a use case where your delegate requires custom CA to be working, but you cannot run delegate container with root user.

The solution is to add custom CA bundle files to the delegate image and run load_certificates.sh script on these CA bundle files.

The load_certificates.sh script will make sure

  1. Your CA certificates are added to delegate's Java truststore located at $JAVA_HOME/lib/security/cacerts
  2. Your CA certificates are added to Redhat OS trust store.
  3. Your CA certificates will be applied to Harness CI pipelines.

To achieve this, please follow the following steps to build your custom delegate image.

  1. Prepare all your CA certificates and put them under a local directory.
  2. Add the two lines below into your delegate docker file. Replace the paths with your choices. Please put them right before the line of USER 1001, because it requires root user to run the script.
  3. Build your docker image

The two lines below will copy all the certificates from local ./my-custom-ca to /opt/harness-delegate/my-ca-bundle/ directory inside the container.

USER root
  
RUN curl -s -L -o delegate.jar $BASEURL/$DELEGATEVERSION/delegate.jar

+ COPY <path to the directory of my local certs> <path to the directory of certs inside the container>

+ RUN bash -c "/opt/harness-delegate/load_certificates.sh <path to the directory of certs inside the container>"

USER 1001

Important notes

  1. Please DO NOT copy your certificates into the folder at /opt/harness-delegate/ca-bundle. This is a reserved folder used for installing additional certificates a delegate starts.
  2. Set the user to root before running the load_certificates.sh script. Then the user back to normal access after you run the script.

delegate-dockerfile's People

Contributors

bharatgoelharness avatar bot-gitexp-user avatar bot2-harness avatar kat-enos avatar raghuatwings avatar smjt-h avatar xingchi-jin avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

delegate-dockerfile's Issues

Error: Invalid or corrupt jarfile delegate.jar

Error: Invalid or corrupt jarfile delegate.jar

Steps to Reproduce

In Dockerfile-ubuntu there is one line that downloads delegate.jar. while execution step. It throws Error: Invalid or corrupt jarfile delegate.jar Error

Download delegate.jar Dockerfile-ubuntu#L77

RUN curl -s -L -o delegate.jar $BASEURL/$DELEGATEVERSION/delegate.jar

Variables

BASEURL = https://app.harness.io/public/shared/delegates
DELEGATEVERSION = 1.0.78904

Information

  • Docker base Image: Ubuntu:20.04

Additional Details

  • In start.sh, jar execution command throws Error: Invalid or corrupt jarfile delegate.jar

Harness Delegate Dockerfile-ubuntu failure

Error: docker run crashes with ": invalid option" in terminal

Steps to Reproduce

Dockerfile-ubuntu docker image failed to execute.

# my build command
docker build -t harness-delegate-docker-image-ubuntu:latest -f Dockerfile-ubuntu --build-arg TARGETARCH=amd64 --build-arg DELEGATEVERSION=78904 .
docker run --cpus=1 --memory=2g \
  -e DELEGATE_NAME=harness-delegate-docker-image-ubuntu \
  -e NEXT_GEN="true" \
  -e DELEGATE_TYPE="DOCKER" \
  -e ACCOUNT_ID=<accountID>\
  -e DELEGATE_TOKEN=<delegate token> \
  -e LOG_STREAMING_SERVICE_URL=https://app.harness.io/gratis/log-service/ \
  -e MANAGER_HOST_AND_PORT=https://app.harness.io/gratis \
  harness-delegate-docker-image-ubuntu:v1

The docker image is unable to run and every time it throws an ": invalid option" error and stops.

image

Please give possible solution ASAP.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.