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

KubeIP v2 #117

Merged
merged 68 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
be08841
use golangci-lint linter, fix multiple issues
alexei-led Sep 20, 2023
5dd9cf5
fix build and push
alexei-led Sep 20, 2023
7d8fea6
refactor main support plain text and json log
alexei-led Sep 20, 2023
8a072f5
cleanup and fix errors
alexei-led Sep 20, 2023
5cf6968
get rid of global logrus
alexei-led Sep 20, 2023
98ac15c
get rid of global logrus
alexei-led Sep 20, 2023
c0fcbfb
v2 draft
alexei-led Sep 21, 2023
ced5718
rename docker image to kubeip-agent
alexei-led Sep 21, 2023
cae3589
new flags: retry interval and retry attempts
alexei-led Sep 21, 2023
9756313
node type added
alexei-led Sep 21, 2023
2f608cd
node type added
alexei-led Sep 21, 2023
1ac1b82
explore k8s node
alexei-led Sep 26, 2023
d6b101d
explore k8s node
alexei-led Sep 26, 2023
f1066c1
pass or discover node name
alexei-led Sep 26, 2023
d7bbc17
test with fake k8s client
alexei-led Sep 26, 2023
36cf72d
multi-arch build speedup
alexei-led Sep 26, 2023
85df4ee
skip non ip addresses
alexei-led Sep 26, 2023
fbc62a0
get instance id from providerID
alexei-led Sep 26, 2023
e1b1f21
draft gcp implementation completed
alexei-led Oct 8, 2023
875947d
more tests with mocks
alexei-led Oct 9, 2023
ee062c1
mock GCP list and test
alexei-led Oct 9, 2023
91a552f
test list with multiple pages
alexei-led Oct 9, 2023
26bc9e5
simplify wait for op
alexei-led Oct 9, 2023
e3bd245
abstract GCP API for easier mock gen
alexei-led Oct 10, 2023
0e8e769
test wait operation
alexei-led Oct 10, 2023
cb83ccf
implement aws eip assigner
alexei-led Oct 11, 2023
3bee1db
remove obsolete code
alexei-led Oct 12, 2023
abe16ea
test address list sort
alexei-led Oct 12, 2023
f393e7e
test aws eip assign
alexei-led Oct 12, 2023
b5e7a98
release static IP on graceful shutdown (optional)
alexei-led Oct 12, 2023
18a21b4
test gcp static ip assign
alexei-led Oct 12, 2023
20dec2d
fix linter error
alexei-led Oct 12, 2023
9beeab9
README draft
alexei-led Oct 12, 2023
c5f2a53
AWS TF example (draft)
alexei-led Oct 13, 2023
a7c746f
AWS TF example (draft)
alexei-led Oct 13, 2023
475fcdd
cleanup tf script
alexei-led Oct 13, 2023
8bbcdaf
eks and gke TF draft
alexei-led Oct 15, 2023
409e79f
fix docker exec
alexei-led Oct 15, 2023
1647227
work on gke example
alexei-led Oct 15, 2023
9c4201c
create k8s resources on eks
alexei-led Oct 15, 2023
b8d38c6
fix daemonset
alexei-led Oct 16, 2023
0e012c8
made gke demo to work
alexei-led Oct 16, 2023
c2a5f83
private GCP API access; do not fail on wait
alexei-led Oct 16, 2023
9dbb3bd
mod tidy
alexei-led Oct 16, 2023
305e33d
remove debug from build
alexei-led Oct 16, 2023
59f9d44
debug log and vpc-native for gke
alexei-led Oct 16, 2023
4bd6b26
add ephemeral public IP on Unassign after removing static public IP
alexei-led Oct 17, 2023
80cbaab
moer robust ip assignment
alexei-led Oct 17, 2023
c026a82
check if address already assigned
alexei-led Oct 17, 2023
f1ac54c
check if address already assigned
alexei-led Oct 17, 2023
65c1ff3
retry assign ephemeral ip on shutdown
alexei-led Oct 17, 2023
715d0c5
TF for AWS working draft
alexei-led Oct 18, 2023
88a25b8
working EKS example
alexei-led Oct 18, 2023
4e29f25
attach/dettach eip to eth0 only
alexei-led Oct 19, 2023
1a18ce3
prevent reassosiation
alexei-led Oct 19, 2023
e91ddd5
add resources to daemonset and set priority class name
alexei-led Oct 19, 2023
fe49c45
update readme with examples
alexei-led Oct 19, 2023
6df52bb
update readme with v1
alexei-led Oct 19, 2023
1ee40cd
enhance readme
alexei-led Oct 19, 2023
de8ecce
spuppress complexity linter
alexei-led Oct 22, 2023
e06ccfe
sonarcloud config added
alexei-led Oct 22, 2023
17e59dd
lint output
alexei-led Oct 22, 2023
8587eaa
keep test artifacts
alexei-led Oct 22, 2023
3bb79ad
configure sonarcloud action
alexei-led Oct 22, 2023
b96bb7d
fix linter error
alexei-led Oct 22, 2023
714375b
configure sonarcloud action
alexei-led Oct 22, 2023
f68da89
Merge branch 'master' into v2-main
alexei-led Oct 22, 2023
e8470c8
Merge branch 'master' into v2-main
alexei-led Oct 22, 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
116 changes: 79 additions & 37 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: build

on:
workflow_dispatch:
push:
branches:
- '*'
Expand All @@ -18,60 +19,101 @@ on:

jobs:

docker-build:
validate:

runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message,'[skip ci]') }}
container: golang:1.21-alpine
steps:
- name: checkout
uses: actions/checkout@v4

- name: test
shell: sh
env:
CGO_ENABLED: 0
run: |
apk --update add ca-certificates tzdata make git bash
make lint
make test-json

- name: upload test results
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: test-reports
if-no-files-found: ignore
path: |
test-report.out
coverage.out
golangci-lint.out

- name: SonarCloud scan
uses: SonarSource/sonarcloud-github-action@master
if: ${{ always() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}


docker-build:

runs-on: ubuntu-latest
needs: validate
# build only on master branch and tags
if: ${{ !contains(github.event.head_commit.message,'[skip ci]') && (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) }}
steps:
- uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v4

- name: get short sha
id: short_sha
run: echo ::set-output name=sha::$(git rev-parse --short HEAD)

- name: get version
id: version
run: echo ::set-output name=version::$([[ -z "${{ github.event.pull_request.number }}" ]] && echo "sha-${{ steps.short_sha.outputs.sha }}" || echo "pr-${{ github.event.pull_request.number }}")

- name: set up QEMU
uses: docker/setup-qemu-action@v3

- name: set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: decide on tag
id: prep
run: |
DOCKER_IMAGE=${{ github.repository }}
VERSION=noop
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT

- name: login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: prepare meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}-agent
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
labels: |
github.run.id=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
org.opencontainers.image.title=kubeip-agent
org.opencontainers.image.description=kubeip agent
org.opencontainers.image.vendor=DoiT International

- name: build and push
id: docker_build
uses: docker/build-push-action@v5
with:
build-args: |
VERSION=${{ steps.version.outputs.version }}
COMMIT=${{ steps.short_sha.outputs.sha }}
BRANCH=${{ github.ref_name }}
push: true
platforms: |
linux/amd64
linux/arm64
tags: ${{ steps.prep.outputs.tags }}

- name: image digest
run: echo ${{ steps.docker_build.outputs.digest }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
55 changes: 43 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
# code coverage
.cover
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
.bin

# Test binary, built with `go test -c`
*.test
.run

# Local environment
.env
.in
.out

# Local .terraform directories
**/.terraform/*

# Sonar Scanner
.scannerwork/

# git repo
.git
# .tfstate files
*.tfstate
*.tfstate.*

# IDE customization

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# IDE support files
.idea
.vscode

# binaries
.bin
# MacOS file system metadata
.DS_Store

# env customization
.env
.in
# local credentials
.credentials

# Test binary, build with `go test -c`
*.test
# Keep out some temporary example code and temprary file
example_code/
older/
temp/

# Dependency directories (remove the comment below to include it)
vendor/

tmp/
146 changes: 146 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
run:
# which dirs to skip
skip-dirs:
- mocks
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 5m
# Exit code when at least one issue was found.
# Default: 1
issues-exit-code: 2
# Include test files or not.
# Default: true
tests: false
# allow parallel run
allow-parallel-runners: true

linters-settings:
govet:
check-shadowing: true
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
misspell:
locale: US
ignore-words:
- "cancelled"
goimports:
local-prefixes: github.com/golangci/golangci-lint
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- rangeValCopy
- unnamedResult
- whyNoLint
- wrapperFunc
funlen:
lines: 105
statements: 50

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- asciicheck
- bidichk
- bodyclose
# - containedctx
# - contextcheck disabled because of generics
- dupword
- decorder
# - depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
# - exhaustivestruct TODO: check how to fix it
- exportloopref
# - forbidigo TODO: configure forbidden code patterns
# - forcetypeassert
- funlen
- gci
# - gochecknoglobals TODO: remove globals from code
# - gochecknoinits TODO: remove main.init
- gocognit
- goconst
- gocritic
- gocyclo
# - godox
- goerr113
- gofmt
- goimports
- gomnd
# - gomoddirectives
- gosec
- gosimple
- govet
- goprintffuncname
- grouper
- importas
# - ireturn TODO: not sure if it is a good linter
- ineffassign
- interfacebloat
- loggercheck
- maintidx
- makezero
- misspell
- nakedret
# - nestif
- nilerr
- nilnil
# - noctx
- nolintlint
- prealloc
- predeclared
- promlinter
- reassign
- revive
# - rowserrcheck disabled because of generics
# - staticcheck doesn't work with go1.19
# - structcheck disabled because of generics
- stylecheck
- tenv
- testableexamples
- typecheck
- unconvert
- unparam
- unused
# - varnamelen TODO: review naming
# - varcheck depricated 1.49
# - wastedassign disabled because of generics
- whitespace
- wrapcheck
# - wsl

issues:
exclude-rules:
- path: _test\.go
linters:
- funlen
- bodyclose
- gosec
- dupl
- gocognit
- goconst
- gocyclo
exclude:
- Using the variable on range scope `tt` in function literal
Loading