Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rockylinux support #196

Merged
merged 32 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ab49d58
Add rocky linux support
Dean-Coakley Feb 2, 2023
9f128b8
Fix centos Docker image. WIP support base image override
Dean-Coakley Feb 10, 2023
5bb5f36
Fix debian baseimage runs
Dean-Coakley Feb 10, 2023
846811d
Fix docker volume mount
Dean-Coakley Feb 10, 2023
b7e2f59
WIP: Add matrix os testing
Dean-Coakley Feb 13, 2023
3f48995
Quote base image tags
Dean-Coakley Feb 13, 2023
d7aa33a
Add GitHub actions matrix testing. PR feedback
Dean-Coakley Feb 14, 2023
3245aef
Build amd64 rpm packages
Dean-Coakley Feb 14, 2023
17f6780
Fix rpm builds
Dean-Coakley Feb 14, 2023
49800d0
Fix rpm packaging
Dean-Coakley Feb 14, 2023
d43b8fc
Fmt bash
Dean-Coakley Feb 14, 2023
d72bef3
Revert logic change
Dean-Coakley Feb 14, 2023
a68c116
Split rocky packaging so only rocky gets arm64 packages
Dean-Coakley Feb 14, 2023
63df835
Fix rocky packaging
Dean-Coakley Feb 14, 2023
efbabae
Disable amd64 matrix for now
Dean-Coakley Feb 14, 2023
1883609
Lint
Dean-Coakley Feb 14, 2023
5f8122a
Use arm runner action and detect OS arch
Dean-Coakley Feb 15, 2023
b26a016
Enlarge image to allow install
Dean-Coakley Feb 15, 2023
41beae6
Test separate arm64 stage
Dean-Coakley Feb 15, 2023
488f5c0
Use go get for go1.15 support
Dean-Coakley Feb 15, 2023
116763b
Remove testing on arm64 for now
Dean-Coakley Feb 15, 2023
2d83288
Merge branch 'main' into add-rocky-support
Dean-Coakley Feb 15, 2023
32570a9
Merge branch 'main' into add-rocky-support
Dean-Coakley Feb 20, 2023
2fba720
Fix goarch builds
Dean-Coakley Feb 20, 2023
d8e3303
Mv centos->rockylinux
Dean-Coakley Feb 20, 2023
f070687
Revert var declaration change
Dean-Coakley Feb 21, 2023
a486e2e
Fix setting CI args
Dean-Coakley Feb 21, 2023
1187119
Override correct Makefile var. Quote integration test data
Dean-Coakley Feb 21, 2023
70c68a2
Fix expected uninstall log map
Dean-Coakley Feb 21, 2023
4745510
Add api integration fixes
Dean-Coakley Feb 21, 2023
7b6118e
Merge branch 'main' into add-rocky-support
Dean-Coakley Feb 21, 2023
9ba41b4
Copy over api dockerfile fixes
Dean-Coakley Feb 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,31 @@ jobs:
- name: Run Component Tests
run: make component-test

integration-test:
name: Integration Tests
integration-tests:
runs-on: ubuntu-22.04
name: Integration Tests
strategy:
matrix:
container:
- image: "rockylinux"
version: "8"
compose-file: "docker-compose-rpm.yml"
- image: "rockylinux"
version: "9"
compose-file: "docker-compose-rpm.yml"
- image: "ubuntu"
version: "22.04"
compose-file: "docker-compose-deb.yml"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run Integration Tests
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
OS_RELEASE="${{ matrix.container.image }}" OS_VERSION="${{ matrix.container.version }}" \
TEST_DOCKER_COMPOSE_FILE="${{ matrix.container.compose-file }}" \
make integration-test

performance-test:
Expand Down
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ DATE = $(shell date +%F_%H-%M-%S)
# | debian | bullseye-slim, buster-slim | |
# | centos | 7 | centos 7 (below 7.4) uses plus-pkgs.nginx.com as PACKAGES_REPO |
# | redhatenterprise | 7, 8, 9 | |
# | rockylinux | 8, 9 | |
# | alpine | 3.13, 3.14, 3.15, 3.16 | |
# | oraclelinux | 7, 8 | |
# | suse | sles12sp5, sle15 | |
# | freebsd | | Not supported |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
OS_RELEASE:=ubuntu
OS_VERSION:=22.04
BASE_IMAGE="docker.io/${OS_RELEASE}:${OS_VERSION}"
IMAGE_TAG=agent_${OS_RELEASE}_${OS_VERSION}
OS_RELEASE ?= ubuntu
OS_VERSION ?= 22.04
BASE_IMAGE = "docker.io/${OS_RELEASE}:${OS_VERSION}"
IMAGE_TAG = "agent_${OS_RELEASE}_${OS_VERSION}"


LDFLAGS = "-w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"
DEBUG_LDFLAGS = "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"


CERTS_DIR := ./build/certs
PACKAGE_PREFIX := nginx-agent
PACKAGES_REPO := "pkgs.nginx.com"
Expand All @@ -45,8 +48,9 @@ else
endif
endif

TEST_BUILD_DIR := build/test
PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}"
TEST_BUILD_DIR := build/test
TEST_DOCKER_COMPOSE_FILE ?= "docker-compose-deb.yml"
PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}"

CERT_CLIENT_CA_CN := client-ca.local
CERT_CLIENT_INT_CN := client-int.local
Expand Down Expand Up @@ -188,9 +192,9 @@ test-component-run: ## Run component tests
performance-test: ## Run performance tests
$(CONTAINER_CLITOOL) run -v ${PWD}:/home/nginx/$(CONTAINER_VOLUME_FLAGS) --rm nginx-agent-benchmark:1.0.0

integration-test: local-deb-package
PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} go test -v ./test/integration/install
PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} go test -v ./test/integration/api
integration-test: local-deb-package local-rpm-package
PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} DOCKER_COMPOSE_FILE=$(TEST_DOCKER_COMPOSE_FILE) go test -v ./test/integration/install
PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} DOCKER_COMPOSE_FILE=${TEST_DOCKER_COMPOSE_FILE} go test -v ./test/integration/api

test-bench: ## Run benchmark tests
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 5 -timeout 2m -bench=. -benchmem metrics_test.go
Expand Down
38 changes: 30 additions & 8 deletions Makefile.packaging
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ GPG_PUBLIC_KEY := .key
DEB_DISTROS?=ubuntu-jammy-22.04 ubuntu-focal-20.04 ubuntu-bionic-18.04 debian-bullseye-11 debian-buster-10
DEB_ARCHS?=arm64 amd64
RPM_DISTROS?=centos-7-x86_64 redhatenterprise-7-x86_64 redhatenterprise-8-x86_64 redhatenterprise-9-x86_64 amazon-2-x86_64 amazon-latest-x86_64 amazon-2017.09-x86_64 suse-12-x86_64 suse-15-x86_64
ROCKY_VERSIONS?=rocky-8 rocky-9
ROCKY_ARCHS?=aarch64 x86_64
RPM_ARCH=x86_64
FREEBSD_DISTROS?="FreeBSD:12:amd64" "FreeBSD:13:amd64"
APK_VERSIONS?=3.13 3.14 3.15 3.16
Expand Down Expand Up @@ -39,27 +41,47 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages
for distro in $(DEB_DISTROS); do \
deb_codename=`echo $$distro | cut -d- -f 2`; \
VERSION=$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename} ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager deb --target ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb; \
cp ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb; \
cp ${PACKAGES_DIR}/deb/${PACKAGE_PREFIX}_$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')~$${deb_codename}_$${arch}.deb; \
done; \
rm -rf ./build/nginx-agent; \
done; \

# Create rpm packages

@GOWORK=off CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent
@for distro in $(RPM_DISTROS); do \
rpm_distro=`echo $$distro | cut -d- -f 1`; \
rpm_distro=`echo $$distro | cut -d- -f 1`; \
rpm_major=`echo $$distro | cut -d- -f 2`; \
rpm_codename='na'; \
if [ "$$rpm_distro" = "centos" ] || [ "$$rpm_distro" = "redhatenterprise" ]; then rpm_codename="el$$rpm_major"; \
elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; fi; \
if [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; fi; \
elif [ "$$rpm_distro" = "amazon" ] && [ "$$rpm_major" = "2" ]; then rpm_codename="amzn$$rpm_major"; \
elif [ "$$rpm_distro" = "suse" ]; then rpm_codename="sles$$rpm_major"; \
fi; \
if [ "$$rpm_codename" != "na" ]; then \
VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=amd64 nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.${RPM_ARCH}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$(RPM_ARCH).rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.${RPM_ARCH}.rpm; \
fi; \
done; \
rm -rf ./build/nginx-agent

# Create rocky rpm packages

@for arch in $(ROCKY_ARCHS); do \
goarch=amd64; \
if [ "$$arch" = "aarch64" ]; then goarch="arm64"; fi; \
GOWORK=off CGO_ENABLED=0 GOARCH=$${goarch} GOOS=linux go build -ldflags=${LDFLAGS} -o ./build/nginx-agent; \
for distro in $(ROCKY_VERSIONS); do \
rpm_distro=`echo $$distro | cut -d- -f 1`; \
rpm_major=`echo $$distro | cut -d- -f 2`; \
rpm_codename='na'; \
if [ "$$rpm_distro" = "rocky" ]; then rpm_codename="rocky$$rpm_major"; fi; \
if [ "$$rpm_codename" != "na" ]; then \
VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager rpm --target $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \
cp $(PACKAGES_DIR)/rpm/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').$${rpm_codename}.ngx.$${arch}.rpm; \
fi; \
done; \
rm -rf ./build/nginx-agent; \
done; \

# Create apk packages
@for arch in $(APK_ARCHS); do \
Expand All @@ -69,7 +91,7 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages
for version in $(APK_VERSIONS); do \
if [ ! -d "$(PACKAGES_DIR)/apk/v$${version}/$${arch}" ]; then mkdir -p $(PACKAGES_DIR)/apk/v$${version}/$${arch}; fi; \
VERSION=$(shell echo ${VERSION} | tr -d 'v') ARCH=$${arch} nfpm pkg --config .nfpm.yaml --packager apk --target $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').apk; \
cp $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').apk ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-v$${version}-$${arch}.apk; \
cp $(PACKAGES_DIR)/apk/v$${version}/$${arch}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v').apk ${GITHUB_PACKAGES_DIR}/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-v$${version}-$${arch}.apk; \
done; \
rm -rf ./build/nginx-agent; \
done; \
Expand All @@ -78,8 +100,8 @@ package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) ## Create final packages

rm -rf ./build/nginx-agent
@GOWORK=off CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags=${LDFLAGS} -o ./build/nginx-agent

docker run -v `pwd`:/nginx-agent/ build-signed-packager:1.0.0
docker run -v ${PWD}:/nginx-agent/ build-signed-packager:1.0.0

echo "DEB packages:"; \
find $(PACKAGES_DIR)/deb ;\
Expand Down
36 changes: 36 additions & 0 deletions scripts/docker/nginx-oss/rockylinux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE} as install-nginx
LABEL maintainer="NGINX Agent Maintainers <[email protected]>"

ARG NGINX_CONF
ARG ENTRY_POINT

WORKDIR /agent
COPY ./ /agent
COPY $ENTRY_POINT /agent/entrypoint.sh

RUN set -x \
&& groupadd --system --gid 101 nginx \
&& adduser -g nginx --system --no-create-home --home /nonexistent --shell /bin/false --uid 101 nginx \
&& usermod -s /sbin/nologin nginx \
&& usermod -L nginx \
&& yum install -y git \
wget \
procps \
make \
vim \
nginx

RUN chmod +x /agent/entrypoint.sh
STOPSIGNAL SIGTERM

EXPOSE 80 443

ENTRYPOINT ["/agent/entrypoint.sh"]


FROM install-nginx as install-agent

ARG PACKAGE_NAME

RUN yum localinstall -y /agent/build/$PACKAGE_NAME.rpm
2 changes: 1 addition & 1 deletion test/integration/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
)

func setupTestContainer(t *testing.T) {
comp, err := compose.NewDockerCompose("docker-compose.yml")
comp, err := compose.NewDockerCompose(os.Getenv("DOCKER_COMPOSE_FILE"))
assert.NoError(t, err, "NewDockerComposeAPI()")

t.Cleanup(func() {
Expand Down
23 changes: 23 additions & 0 deletions test/integration/api/docker-compose-rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.9'

networks:
monitoring:
driver: bridge

services:
agent:
build:
context: ../../../
dockerfile: ./scripts/docker/nginx-oss/rockylinux/Dockerfile
target: install-agent
args:
PACKAGE_NAME: ${PACKAGE_NAME}
BASE_IMAGE: ${BASE_IMAGE}
ENTRY_POINT: "./scripts/docker/nginx-oss/entrypoint.sh"
ports:
- 9091:9091
networks:
- monitoring
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf
14 changes: 14 additions & 0 deletions test/integration/install/docker-compose-rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.9'

services:
agent:
build:
context: ../../../
dockerfile: ./scripts/docker/nginx-oss/rockylinux/Dockerfile
target: install-nginx
args:
PACKAGE_NAME: ${PACKAGE_NAME}
BASE_IMAGE: ${BASE_IMAGE}
ENTRY_POINT: "./scripts/docker/nginx-oss/agentless-entrypoint.sh"
ports:
- 80
18 changes: 12 additions & 6 deletions test/integration/install/install_uninstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (

func setupTestContainer(t *testing.T) {
ctx := context.Background()
comp, err := compose.NewDockerCompose("docker-compose.yml")
comp, err := compose.NewDockerCompose(os.Getenv("DOCKER_COMPOSE_FILE"))
assert.NoError(t, err, "NewDockerComposeAPI()")

t.Cleanup(func() {
Expand Down Expand Up @@ -95,9 +95,9 @@ func TestAgentManualInstallUninstall(t *testing.T) {

assert.LessOrEqual(t, localAgentPkg.Size(), maxFileSize)

// Install Agent and record installation time/install output
dockerAgentPackagePath := getPackagePath(absContainerAgentPackageDir, string(osReleaseContent))
installTime, installLog := installAgent(t, agentContainer, dockerAgentPackagePath, string(osReleaseContent))
// Install Agent inside container and record installation time/install output
containerAgentPackagePath := getPackagePath(absContainerAgentPackageDir, string(osReleaseContent))
installTime, installLog := installAgent(t, agentContainer, containerAgentPackagePath, string(osReleaseContent))

// Check the install time under 30s
assert.LessOrEqual(t, installTime, maxInstallTime)
Expand All @@ -120,6 +120,10 @@ func TestAgentManualInstallUninstall(t *testing.T) {
uninstallLog := uninstallAgent(t, agentContainer, string(osReleaseContent))

// Check uninstall output
if strings.HasSuffix(containerAgentPackagePath, "rpm") {
expectedUninstallLogMsgs["UninstallAgent"] = "Removed:\n nginx-agent"
delete(expectedUninstallLogMsgs, "UninstallAgentPurgingFiles")
}
for _, logMsg := range expectedUninstallLogMsgs {
assert.Contains(t, uninstallLog, logMsg)
}
Expand Down Expand Up @@ -171,7 +175,7 @@ func createInstallCommand(agentPackageFilePath, osReleaseContent string) []strin
if strings.Contains(osReleaseContent, "UBUNTU") || strings.Contains(osReleaseContent, "Debian") {
return []string{"dpkg", "-i", agentPackageFilePath}
} else {
return []string{"yum", "localinstall", agentPackageFilePath}
return []string{"yum", "localinstall", "-y", agentPackageFilePath}
}
}

Expand Down Expand Up @@ -201,7 +205,9 @@ func getPackagePath(pkgDir, osReleaseContent string) string {

if strings.Contains(osReleaseContent, "UBUNTU") || strings.Contains(osReleaseContent, "Debian") {
return pkgPath + ".deb"
} else {
} else if strings.Contains(osReleaseContent, "rhel") || strings.Contains(osReleaseContent, "centos") {
return pkgPath + ".rpm"
} else {
return pkgPath + ".apk"
}
}