Skip to content

Commit fc646d6

Browse files
authored
Merge pull request #707 from dusdjhyeon/ubi-migration
UBI migration of Images - go-runner
2 parents f051d5a + 6257c1a commit fc646d6

File tree

10 files changed

+187
-215
lines changed

10 files changed

+187
-215
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
# Install golang
1313
- uses: actions/setup-go@v2
1414
with:
15-
go-version: 1.18
15+
go-version: '1.20'
1616

1717
- uses: actions/checkout@v2
1818
with:
@@ -56,7 +56,7 @@ jobs:
5656
# Install golang
5757
- uses: actions/setup-go@v2
5858
with:
59-
go-version: 1.18
59+
go-version: '1.20'
6060

6161
- uses: actions/checkout@v2
6262
with:
@@ -80,6 +80,7 @@ jobs:
8080
file: build/Dockerfile
8181
platforms: linux/amd64,linux/arm64
8282
tags: litmuschaos/go-runner:ci
83+
build-args: LITMUS_VERSION=3.10.0
8384

8485
trivy:
8586
needs: pre-checks
@@ -91,7 +92,7 @@ jobs:
9192

9293
- name: Build an image from Dockerfile
9394
run: |
94-
docker build -f build/Dockerfile -t docker.io/litmuschaos/go-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64
95+
docker build -f build/Dockerfile -t docker.io/litmuschaos/go-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64 --build-arg LITMUS_VERSION=3.10.0
9596
9697
- name: Run Trivy vulnerability scanner
9798
uses: aquasecurity/trivy-action@master

.github/workflows/push.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
# Install golang
1414
- uses: actions/setup-go@v2
1515
with:
16-
go-version: 1.18
16+
go-version: '1.20'
1717
- uses: actions/checkout@v2
1818

1919
#TODO: Add Dockerfile linting
@@ -43,7 +43,7 @@ jobs:
4343
# Install golang
4444
- uses: actions/setup-go@v2
4545
with:
46-
go-version: 1.18
46+
go-version: '1.20'
4747
- uses: actions/checkout@v2
4848

4949
- name: Set up QEMU
@@ -69,4 +69,5 @@ jobs:
6969
push: true
7070
file: build/Dockerfile
7171
platforms: linux/amd64,linux/arm64
72-
tags: litmuschaos/go-runner:ci
72+
tags: litmuschaos/go-runner:ci
73+
build-args: LITMUS_VERSION=3.10.0

.github/workflows/release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
# Install golang
1313
- uses: actions/setup-go@v2
1414
with:
15-
go-version: 1.18
15+
go-version: '1.20'
1616
- uses: actions/checkout@v2
1717

1818
#TODO: Add Dockerfile linting
@@ -28,7 +28,7 @@ jobs:
2828
# Install golang
2929
- uses: actions/setup-go@v2
3030
with:
31-
go-version: 1.18
31+
go-version: '1.20'
3232
- uses: actions/checkout@v2
3333

3434
- name: Set Tag
@@ -67,4 +67,5 @@ jobs:
6767
push: true
6868
file: build/Dockerfile
6969
platforms: linux/amd64,linux/arm64
70-
tags: litmuschaos/go-runner:${{ env.RELEASE_TAG }},litmuschaos/go-runner:latest
70+
tags: litmuschaos/go-runner:${{ env.RELEASE_TAG }},litmuschaos/go-runner:latest
71+
build-args: LITMUS_VERSION=3.10.0

.github/workflows/run-e2e-on-pr-commits.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
# Install golang
1818
- uses: actions/setup-go@v5
1919
with:
20-
go-version: 1.18
20+
go-version: '1.20'
2121

2222
- uses: actions/checkout@v2
2323
with:
@@ -74,7 +74,7 @@ jobs:
7474
# Install golang
7575
- uses: actions/setup-go@v5
7676
with:
77-
go-version: 1.18
77+
go-version: '1.20'
7878

7979
- uses: actions/checkout@v2
8080
with:
@@ -133,7 +133,7 @@ jobs:
133133
# Install golang
134134
- uses: actions/setup-go@v5
135135
with:
136-
go-version: 1.18
136+
go-version: '1.20'
137137

138138
- uses: actions/checkout@v2
139139
with:

.github/workflows/security-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
- name: Build an image from Dockerfile
1616
run: |
17-
docker build -f build/Dockerfile -t docker.io/litmuschaos/go-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64
17+
docker build -f build/Dockerfile -t docker.io/litmuschaos/go-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64 --build-arg LITMUS_VERSION=3.9.0
1818
1919
- name: Run Trivy vulnerability scanner
2020
uses: aquasecurity/trivy-action@master

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ image-push:
7272
@echo "--> Push go-runner image"
7373
@echo "------------------------"
7474
@echo "Pushing $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)"
75-
@docker buildx build . --push --file build/Dockerfile --progress plane --platform linux/arm64,linux/amd64 --no-cache --tag $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
75+
@docker buildx build . --push --file build/Dockerfile --progress plain --platform linux/arm64,linux/amd64 --no-cache --tag $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
7676

7777

7878
.PHONY: build-amd64
7979
build-amd64:
8080
@echo "-------------------------"
8181
@echo "--> Build go-runner image"
8282
@echo "-------------------------"
83-
@sudo docker build --file build/Dockerfile --tag $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETARCH=amd64
83+
@sudo docker build --file build/Dockerfile --tag $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETARCH=amd64 --build-arg LITMUS_VERSION=3.9.0
8484

8585
.PHONY: push-amd64
8686
push-amd64:

build/Dockerfile

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Multi-stage docker build
22
# Build stage
3-
FROM golang:1.18 AS builder
3+
FROM golang:1.20 AS builder
44

55
ARG TARGETOS=linux
66
ARG TARGETARCH
@@ -14,27 +14,98 @@ RUN export GOOS=${TARGETOS} && \
1414
RUN CGO_ENABLED=0 go build -o /output/experiments ./bin/experiment
1515
RUN CGO_ENABLED=0 go build -o /output/helpers ./bin/helper
1616

17-
FROM alpine:3.15.0 AS dep
17+
# Packaging stage
18+
FROM registry.access.redhat.com/ubi9/ubi:9.4
19+
20+
LABEL maintainer="LitmusChaos"
21+
22+
ARG TARGETARCH
23+
ARG LITMUS_VERSION
1824

1925
# Install generally useful things
20-
RUN apk --update add \
21-
sudo \
22-
iproute2 \
23-
iptables
26+
RUN yum install -y \
27+
sudo \
28+
sshpass \
29+
procps
30+
31+
# tc binary
32+
RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iproute-6.2.0-6.el9_4.$(uname -m).rpm
33+
RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iproute-tc-6.2.0-6.el9_4.$(uname -m).rpm
34+
35+
# iptables
36+
RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iptables-libs-1.8.10-2.el9.$(uname -m).rpm
37+
RUN yum install -y https://dl.fedoraproject.org/pub/epel/9/Everything/$(uname -m)/Packages/i/iptables-legacy-libs-1.8.10-2.2.el9.$(uname -m).rpm
38+
RUN yum install -y https://dl.fedoraproject.org/pub/epel/9/Everything/$(uname -m)/Packages/i/iptables-legacy-1.8.10-2.2.el9.$(uname -m).rpm
2439

40+
# stress-ng
41+
RUN yum install -y https://yum.oracle.com/repo/OracleLinux/OL9/appstream/$(uname -m)/getPackage/Judy-1.0.5-28.el9.$(uname -m).rpm
42+
RUN yum install -y https://yum.oracle.com/repo/OracleLinux/OL9/appstream/$(uname -m)/getPackage/stress-ng-0.14.00-2.el9.$(uname -m).rpm
2543

26-
# Packaging stage
27-
# Image source: https://github.com/litmuschaos/test-tools/blob/master/custom/hardened-alpine/experiment/Dockerfile
28-
# The base image is non-root (have litmus user) with default litmus directory.
29-
FROM litmuschaos/experiment-alpine
44+
#Installing Kubectl
45+
ENV KUBE_LATEST_VERSION="v1.31.0"
46+
RUN curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/${TARGETARCH}/kubectl -o /usr/bin/kubectl && \
47+
chmod 755 /usr/bin/kubectl
3048

31-
LABEL maintainer="LitmusChaos"
49+
#Installing crictl binaries
50+
RUN curl -L https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.31.1/crictl-v1.31.1-linux-${TARGETARCH}.tar.gz --output crictl-v1.31.1-linux-${TARGETARCH}.tar.gz && \
51+
tar zxvf crictl-v1.31.1-linux-${TARGETARCH}.tar.gz -C /sbin && \
52+
chmod 755 /sbin/crictl
53+
54+
#Installing promql cli binaries
55+
RUN curl -L https://github.com/chaosnative/promql-cli/releases/download/3.0.0-beta6/promql_linux_${TARGETARCH} --output /usr/bin/promql && chmod 755 /usr/bin/promql
56+
57+
#Installing pause cli binaries
58+
RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/pause-linux-${TARGETARCH} --output /usr/bin/pause && chmod 755 /usr/bin/pause
59+
60+
#Installing dns_interceptor cli binaries
61+
RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/dns_interceptor --output /sbin/dns_interceptor && chmod 755 /sbin/dns_interceptor
62+
63+
#Installing nsutil cli binaries
64+
RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/nsutil-linux-${TARGETARCH} --output /sbin/nsutil && chmod 755 /sbin/nsutil
3265

33-
COPY --from=builder /output/ /litmus
34-
COPY --from=dep /usr/bin/sudo /usr/bin/sudo
35-
COPY --from=dep /usr/lib/sudo /usr/lib/sudo
36-
COPY --from=dep /sbin/tc /sbin/
37-
COPY --from=dep /sbin/iptables /sbin/
66+
#Installing nsutil shared lib
67+
RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/nsutil_${TARGETARCH}.so --output /usr/local/lib/nsutil.so && chmod 755 /usr/local/lib/nsutil.so
68+
69+
# Installing toxiproxy binaries
70+
RUN curl -L https://litmus-http-proxy.s3.amazonaws.com/cli/cli/toxiproxy-cli-linux-${TARGETARCH}.tar.gz --output toxiproxy-cli-linux-${TARGETARCH}.tar.gz && \
71+
tar zxvf toxiproxy-cli-linux-${TARGETARCH}.tar.gz -C /sbin/ && \
72+
chmod 755 /sbin/toxiproxy-cli
73+
RUN curl -L https://litmus-http-proxy.s3.amazonaws.com/server/server/toxiproxy-server-linux-${TARGETARCH}.tar.gz --output toxiproxy-server-linux-${TARGETARCH}.tar.gz && \
74+
tar zxvf toxiproxy-server-linux-${TARGETARCH}.tar.gz -C /sbin/ && \
75+
chmod 755 /sbin/toxiproxy-server
76+
77+
ENV APP_USER=litmus
78+
ENV APP_DIR="/$APP_USER"
79+
ENV DATA_DIR="$APP_DIR/data"
80+
81+
# The USERD_ID of user
82+
ENV APP_USER_ID=2000
83+
RUN useradd -s /bin/true -u $APP_USER_ID -m -d $APP_DIR $APP_USER
84+
85+
# change to 0(root) group because openshift will run container with arbitrary uid as a member of root group
86+
RUN chgrp -R 0 "$APP_DIR" && chmod -R g=u "$APP_DIR"
87+
88+
# Giving sudo to all users (required for almost all experiments)
89+
RUN echo 'ALL ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
90+
91+
WORKDIR $APP_DIR
92+
93+
COPY --from=builder /output/ .
94+
95+
COPY --from=docker:27.0.3 /usr/local/bin/docker /sbin/docker
96+
RUN chmod 755 /sbin/docker
97+
98+
# Set permissions and ownership for the copied binaries
99+
RUN chmod 755 ./experiments ./helpers && \
100+
chown ${APP_USER}:0 ./experiments ./helpers
101+
102+
# Set ownership for binaries in /sbin and /usr/bin
103+
RUN chown ${APP_USER}:0 /sbin/* /usr/bin/* && \
104+
chown root:root /usr/bin/sudo && \
105+
chmod 4755 /usr/bin/sudo
38106

39107
# Copying Necessary Files
40-
COPY ./pkg/cloud/aws/common/ssm-docs/LitmusChaos-AWS-SSM-Docs.yml .
108+
COPY ./pkg/cloud/aws/common/ssm-docs/LitmusChaos-AWS-SSM-Docs.yml ./LitmusChaos-AWS-SSM-Docs.yml
109+
RUN chown ${APP_USER}:0 ./LitmusChaos-AWS-SSM-Docs.yml && chmod 755 ./LitmusChaos-AWS-SSM-Docs.yml
110+
111+
USER ${APP_USER}

chaoslib/litmus/http-chaos/helper/http-helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const NoProxyToKill = "you need to specify whom to kill"
225225
// it is using nsenter command to enter into network namespace of target container
226226
// and execute the proxy related command inside it.
227227
func killProxy(pid int, source string) error {
228-
stopProxyServerCommand := fmt.Sprintf("sudo nsenter -t %d -n sudo kill -9 $(ps aux | grep [t]oxiproxy | awk 'FNR==1{print $1}')", pid)
228+
stopProxyServerCommand := fmt.Sprintf("sudo nsenter -t %d -n sudo kill -9 $(ps aux | grep [t]oxiproxy | awk 'FNR==2{print $2}')", pid)
229229
log.Infof("[Chaos]: Stopping proxy server")
230230

231231
if err := common.RunBashCommand(stopProxyServerCommand, "failed to stop proxy server", source); err != nil {

go.mod

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/litmuschaos/litmus-go
22

3-
go 1.18
3+
go 1.20
44

55
require (
66
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24
@@ -15,8 +15,8 @@ require (
1515
github.com/pkg/errors v0.9.1
1616
github.com/sirupsen/logrus v1.8.1
1717
github.com/spf13/cobra v1.1.1
18-
github.com/stretchr/testify v1.7.0
19-
google.golang.org/api v0.48.0
18+
github.com/stretchr/testify v1.8.1
19+
google.golang.org/api v0.126.0
2020
gopkg.in/yaml.v2 v2.4.0
2121
k8s.io/api v0.26.0
2222
k8s.io/apimachinery v0.26.0
@@ -25,7 +25,8 @@ require (
2525
)
2626

2727
require (
28-
cloud.google.com/go v0.83.0 // indirect
28+
cloud.google.com/go/compute v1.21.0 // indirect
29+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
2930
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
3031
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
3132
github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 // indirect
@@ -44,10 +45,13 @@ require (
4445
github.com/godbus/dbus/v5 v5.0.4 // indirect
4546
github.com/gogo/protobuf v1.3.2 // indirect
4647
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
47-
github.com/golang/protobuf v1.5.2 // indirect
48-
github.com/google/go-cmp v0.5.6 // indirect
48+
github.com/golang/protobuf v1.5.3 // indirect
49+
github.com/google/go-cmp v0.5.9 // indirect
4950
github.com/google/gofuzz v1.1.0 // indirect
50-
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
51+
github.com/google/s2a-go v0.1.4 // indirect
52+
github.com/google/uuid v1.3.0 // indirect
53+
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
54+
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
5155
github.com/googleapis/gnostic v0.5.5 // indirect
5256
github.com/imdario/mergo v0.3.12 // indirect
5357
github.com/inconshreveable/mousetrap v1.0.0 // indirect
@@ -60,18 +64,18 @@ require (
6064
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
6165
github.com/pmezard/go-difflib v1.0.0 // indirect
6266
github.com/spf13/pflag v1.0.5 // indirect
63-
go.opencensus.io v0.23.0 // indirect
67+
go.opencensus.io v0.24.0 // indirect
6468
golang.org/x/crypto v0.16.0 // indirect
6569
golang.org/x/net v0.19.0 // indirect
66-
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
70+
golang.org/x/oauth2 v0.10.0 // indirect
6771
golang.org/x/sys v0.15.0 // indirect
6872
golang.org/x/term v0.15.0 // indirect
6973
golang.org/x/text v0.14.0 // indirect
7074
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
7175
google.golang.org/appengine v1.6.7 // indirect
72-
google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 // indirect
73-
google.golang.org/grpc v1.38.0 // indirect
74-
google.golang.org/protobuf v1.26.0 // indirect
76+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
77+
google.golang.org/grpc v1.58.3 // indirect
78+
google.golang.org/protobuf v1.31.0 // indirect
7579
gopkg.in/inf.v0 v0.9.1 // indirect
7680
gopkg.in/yaml.v3 v3.0.1 // indirect
7781
k8s.io/klog/v2 v2.80.1 // indirect

0 commit comments

Comments
 (0)