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 github action for upload image. Complete makefile to build arm64 image. Fix bug: can not find nodes #197

Merged
merged 6 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 56 additions & 0 deletions .github/workflows/upload_operator_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Upload Operator Images

on:
workflow_dispatch: {}
push:
tags:
- v*

permissions: read-all

jobs:
Upload:
permissions:
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#authenticating-to-package-registries-on-github
packages: write
strategy:
matrix:
arch: [ amd64, arm64 ]
image:
[ chaosblade-operator ]
outputs:
image_tag: ${{ steps.image_tag.outputs.image_tag }}
runs-on: ubuntu-20.04
steps:
- name: Extract Image Tag
id: image_tag
shell: bash
run: |
IMAGE_TAG=${GITHUB_REF##*/}
echo "::set-output name=image_tag::$(echo $IMAGE_TAG)"

- name: Login to GitHub Container registry
uses: docker/login-action@v1
with:
registry: chaosbladeio
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Build Image
run: |
make docker-build
make docker-build-arm64

- name: Upload Image
env:
IMAGE_TAG: ${{ steps.image_tag.outputs.image_tag }}
ARCH: ${{ matrix.arch }}
IMAGE: ${{ matrix.image }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: |
# ${VAR,,} convert VAR to lower case
docker push chaosbladeio/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE:$IMAGE_TAG
docker push chaosbladeio/${GITHUB_REPOSITORY_OWNER,,}/$IMAGE:$IMAGE_TAG-arm64

# - name: Build and push Docker images
# uses: docker/[email protected]
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GO=env $(GO_ENV) $(GO_MODULE) go
UNAME := $(shell uname)

ifeq ($(BLADE_VERSION), )
BLADE_VERSION=1.7.0
BLADE_VERSION=1.7.1
endif
ifeq ($(BLADE_VENDOR), )
BLADE_VENDOR=community
Expand Down Expand Up @@ -37,15 +37,19 @@ build_all: pre_build build docker-build

docker-build:
GOOS="linux" GOARCH="amd64" go build $(GO_FLAGS) -o build/_output/bin/chaosblade-operator cmd/manager/main.go
docker build -f build/Dockerfile -t chaosblade-operator:${BLADE_VERSION} .
docker build -f build/image/amd/Dockerfile -t chaosbladeio/chaosblade-operator:${BLADE_VERSION} .

docker-build-arm64:
GOOS="linux" GOARCH="arm64" go build $(GO_FLAGS) -o build/_output/bin/chaosblade-operator cmd/manager/main.go
docker build -f build/image/arm/Dockerfile -t chaosbladeio/chaosblade-operator-arm64:${BLADE_VERSION} .

#operator-sdk 0.19.0 build
build_all_operator: pre_build build build_image
build_image:
operator-sdk build --go-build-args="$(GO_FLAGS)" chaosblade-operator:${BLADE_VERSION}
operator-sdk build --go-build-args="$(GO_FLAGS)" chaosbladeio/chaosblade-operator:${BLADE_VERSION}

build_image_arm64:
GOOS="linux" GOARCH="arm64" operator-sdk build --go-build-args="$(GO_FLAGS)" chaosblade-operator-arm64:${BLADE_VERSION}
GOOS="linux" GOARCH="arm64" operator-sdk build --go-build-args="$(GO_FLAGS)" chaosbladeio/chaosblade-operator-arm64:${BLADE_VERSION}

# only build_fuse and yaml
build_linux:
Expand All @@ -62,7 +66,7 @@ build_arm64:
-v $(shell echo -n ${GOPATH}):/go \
-v $(shell pwd):/go/src/github.com/chaosblade-io/chaosblade-operator \
-w /go/src/github.com/chaosblade-io/chaosblade-operator \
chaosblade-build-arm:latest
chaosbladeio/chaosblade-build-arm:latest

pre_build:
mkdir -p $(BUILD_TARGET_BIN) $(BUILD_TARGET_YAML)
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions build/image/arm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM multiarch/alpine:arm64-edge as builder

ENV OPERATOR=/usr/local/bin/chaosblade-operator
COPY build/_output/bin/chaosblade-operator /usr/local/bin/

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest

ENV OPERATOR=/usr/local/bin/chaosblade-operator \
CHAOSBLADE_HOME=/opt/chaosblade

COPY --from=builder ${OPERATOR} /usr/local/bin/
COPY build/bin /usr/local/bin

RUN /usr/local/bin/user_setup

ENTRYPOINT ["/usr/local/bin/entrypoint"]
6 changes: 5 additions & 1 deletion exec/node/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ var resourceFunc = func(ctx context.Context, client2 *channel.Client, flags map[
logrusField.Warningf("can not find the node by %s name, %v", name, err)
continue
}
if model.MapContains(node.Labels, requirements) {
if len(requirements) > 0 {
if model.MapContains(node.Labels, requirements) {
nodes = append(nodes, node)
}
} else {
nodes = append(nodes, node)
}
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/chaosblade-io/chaosblade-operator

require (
github.com/chaosblade-io/chaosblade-exec-cri v1.7.0
github.com/chaosblade-io/chaosblade-exec-os v1.7.0
github.com/chaosblade-io/chaosblade-spec-go v1.7.0
github.com/chaosblade-io/chaosblade-exec-cri v1.7.1
github.com/chaosblade-io/chaosblade-exec-os v1.7.1
github.com/chaosblade-io/chaosblade-spec-go v1.7.1
github.com/ethercflow/hookfs v0.3.0
github.com/go-logr/logr v0.2.1 // indirect
github.com/go-logr/zapr v0.2.0 // indirect
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,13 @@ github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tj
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw=
github.com/chaosblade-io/chaosblade-exec-cri v1.7.0 h1:TOqA0UZS317dISb3nTwGR1Dlyr0HqsrwT5buamjZ20I=
github.com/chaosblade-io/chaosblade-exec-cri v1.7.0/go.mod h1:ka3BMJWLJd18DXt8no68WcYD8oVuhN5GeCyDf8uFK3s=
github.com/chaosblade-io/chaosblade-exec-os v1.7.0 h1:Y0V4a2LqGwVxqvVORGkXS6Y9xx1CuTWhihneGmrdAAY=
github.com/chaosblade-io/chaosblade-exec-os v1.7.0/go.mod h1:e8TuopYAESkl5ZgSjfnDL03KwO09tmA1H6Y8oPNZElw=
github.com/chaosblade-io/chaosblade-spec-go v1.7.0 h1:kmh5I9ludZW9GNYEjkk1NLKEYJqtZSxLAojrbs4kOow=
github.com/chaosblade-io/chaosblade-exec-cri v1.7.1 h1:+8Q6XTvFiXpI61oFfOHdVvMp+27/bKFeIkxOz5Ef4hA=
github.com/chaosblade-io/chaosblade-exec-cri v1.7.1/go.mod h1:Epb7aK95LkXsyT4qS7nUNcZb+1T9n3uuDXjJ1raO+rk=
github.com/chaosblade-io/chaosblade-exec-os v1.7.1 h1:1v5FszYQOFm4tdxTRJuF8DM54Rd1bs90zWeyjE6Wke8=
github.com/chaosblade-io/chaosblade-exec-os v1.7.1/go.mod h1:e8TuopYAESkl5ZgSjfnDL03KwO09tmA1H6Y8oPNZElw=
github.com/chaosblade-io/chaosblade-spec-go v1.7.0/go.mod h1:GMDRCEt9jw2+PdX+S2eKBg4ES6PENRc7xsLohWJWM6s=
github.com/chaosblade-io/chaosblade-spec-go v1.7.1 h1:6umonDJj6UW0WjKy9DnWQMe4kdFHdgAIzlLSlSucpFA=
github.com/chaosblade-io/chaosblade-spec-go v1.7.1/go.mod h1:GMDRCEt9jw2+PdX+S2eKBg4ES6PENRc7xsLohWJWM6s=
github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw=
github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
Expand Down