diff --git a/.github/workflows/shared.yml b/.github/workflows/shared.yml index e11173d..8c1962f 100644 --- a/.github/workflows/shared.yml +++ b/.github/workflows/shared.yml @@ -10,7 +10,7 @@ on: type: boolean jobs: - build-pkg: + build-and-release: name: CI-PKGs runs-on: ubuntu-latest steps: @@ -26,28 +26,20 @@ jobs: run: ./create_packages - name: Test Package run: sudo ./ci_test + - name: Build Docker Image + run: | + ./create_docker build + # Publish release - uses: ncipollo/release-action@v1 if: ${{ inputs.publish_steps }} with: - artifacts: "zabbix-agent-extensions*.deb,zabbix-agent-extensions-*.rpm" - build-docker: - name: CI-Docker - runs-on: ubuntu-latest - environment: "Docker Upload" - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 + artifacts: "zabbix-agent-extensions*.deb,zabbix-agent-extensions-*.rpm,zabbix-agent-daemonset-kubernetes-release.yaml" - name: Login to Docker Hub if: ${{ inputs.publish_steps }} uses: docker/login-action@v3 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build - run: | - ./create_docker build - name: Publish docker images if: ${{ inputs.publish_steps }} run: | diff --git a/.gitignore b/.gitignore index 3e56e44..686a1b5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.deb *.rpm *.idea +zabbix-agent-daemonset-kubernetes-release.yaml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bb4a654..0000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: bash -dist: jammy -sudo: required -before_install: -- sudo apt-get update -- sudo apt-get install ruby-dev build-essential debhelper devscripts rpm xalan wget -y -script: -- set -e -- gem install fpm -- ./create_packages -- ./ci_test -notifications: - email: - recipients: - - ms-travisci@256bit.org - on_success: change - on_failure: always -deploy: - provider: releases - api_key: - secure: kySI7Haw3FrObyZQXW1lL6wY6ONJPZWIvKAPkOh1ZMsm4nubHOeQt4+zGL1mk3pVCNmSZUxjiQyPN5o74UCuWsObQZcbfxrEVJQ5MaBEIom7HNG0Uyw1tHO5jJJR3U+0MuVse4TtUPnM86tdMGSLJZqPOg6A1t+ORsPnjNoEizLtyeF84TiXjAnCQtx9XiL6tglT2mUYZKgTQMiKyFPmUtNTetQf/TKr6oaM2w63hhf6sOyCIYtzqIFc4CDBYmiGj5sFGXlP9PnLNGQnkqTjpC3694vcy2Ak9WOCwa3qDsLKMIvd1B2olBTUAZbiUf8pWnTwfXWPVlYepuS6FdkKF+uE/Y/TTvX0WshegoLPhp8hnVFMQIkOSor68ZxjOa3u8SXwYlD5lNB6g6eXNQKBCiQ8lxeGwu0aH33lWfmAoQOJmWZM/Mjo0jT/bxP3Ry1FFD17SSX5wQSn27nvTmmSrC4HacLsoM7HrdoSE3ZhcV0jPnwL9FuGGnc5k28ggNyVlu5n/f2vXpH3WQ9mbTCTl6MMoC6E7K/kGQBmR230EOtRA7pvYuE71l689S5U9DQ+97uG9LZqk83lhmWzZOzjVXno9fvFjY9ypkCYhgxSTkl3VFghTYRfEEONjoLGr0TKFkrz4QuNUBFqO/5IG1w+mUyxmEeAAihL8Odv9xiNYpM= - file_glob: true - file: - - "zabbix-agent-extensions*.noarch.rpm" - - "zabbix-agent-extensions*_all.deb" - skip_cleanup: true - on: - repo: scoopex/zabbix-agent-extensions - tags: true - branches: - only: - - master - - /^v\d+(\.\d+)+$/ diff --git a/Dockerfile b/Dockerfile index c863edc..766ff8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,14 +2,16 @@ FROM zabbix/zabbix-agent:ubuntu-7.2-latest ARG BUILD_DATE +ARG BUILD_VERSION + USER 0 ADD /docker-scripts /tmp/setup RUN chmod 755 /tmp/setup/*.sh RUN /tmp/setup/01_phase_base.sh -ADD zabbix-agent-extensions_*_all.deb /tmp/setup +ADD zabbix-agent-extensions_${BUILD_VERSION}_all.deb /tmp/setup RUN /tmp/setup/04_install_agent_extensions.sh -RUN /tmp/setup/05_perform_upgrade.sh +RUN /tmp/setup/05_perform_upgrade_and_cleanup.sh ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"] diff --git a/create_docker b/create_docker index 8018bee..c79fc1b 100755 --- a/create_docker +++ b/create_docker @@ -89,7 +89,12 @@ buildDocker(){ set -x docker rmi ${IMAGE_NAME}:${VERSION} set -e - docker build --progress plain --build-arg BUILD_DATE="$(date "+%Y-%m-%d")" -t ${IMAGE_NAME}:${VERSION} -f Dockerfile . + docker build --progress plain \ + --build-arg BUILD_DATE="$(date "+%Y-%m-%d")" \ + --build-arg BUILD_VERSION="$VERSION" \ + -t ${IMAGE_NAME}:${VERSION} -f Dockerfile . + sed "~s,${IMAGE_REPO}/${IMAGE_NAME}:latest,${IMAGE_REPO}/${IMAGE_NAME}:${VERSION}," zabbix-agent-daemonset-kubernetes.yaml > \ + zabbix-agent-daemonset-kubernetes-release.yaml set +xe } diff --git a/docker-scripts/04_install_agent_extensions.sh b/docker-scripts/04_install_agent_extensions.sh index fae2e8b..2893e90 100755 --- a/docker-scripts/04_install_agent_extensions.sh +++ b/docker-scripts/04_install_agent_extensions.sh @@ -1,6 +1,7 @@ #!/bin/bash +set -xe cd /tmp/setup ls -l /tmp/setup -dpkg -i *.deb +dpkg -i "zabbix-agent-extensions_${BUILD_VERSION?The version of the extension}_all.deb" sed -i '~s,/var/lib/zabbix/:/sbin/nologin,/var/lib/zabbix/:/bin/bash,' /etc/passwd diff --git a/docker-scripts/05_perform_upgrade.sh b/docker-scripts/05_perform_upgrade_and_cleanup.sh similarity index 100% rename from docker-scripts/05_perform_upgrade.sh rename to docker-scripts/05_perform_upgrade_and_cleanup.sh diff --git a/zabbix-agent-daemonset-kubernetes.yaml b/zabbix-agent-daemonset-kubernetes.yaml index 7e62d01..84ea503 100644 --- a/zabbix-agent-daemonset-kubernetes.yaml +++ b/zabbix-agent-daemonset-kubernetes.yaml @@ -19,7 +19,7 @@ spec: labels: name: zabbix-agent spec: - # this toleration is to have the daemonset runnable on master nodes + # this toleration is to have the daemonset runnable also on master nodes # tolerations: # - key: node-role.kubernetes.io/master # effect: NoSchedule @@ -43,7 +43,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName - - name: ZBX_ACTIVESERVERS + - name: ZBX_SERVER_HOST value: "zabbix-proxy" - name: ZBX_PASSIVESERVERS value: "127.0.0.1,zabbix-proxy" @@ -77,5 +77,5 @@ metadata: name: zabbix-agent-extensions-include namespace: "infra-zabbix-agent" data: - "zabbix-agent-extensions-include.conf": | - Include=/usr/share/zabbix-agent-extensions/include.d/*.conf + "zabbix-agent-extensions-include-extra.conf": | + # Extra