Skip to content

Commit

Permalink
Merge pull request #116 from spotahome/slok/update-k8s-1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
slok authored Oct 7, 2021
2 parents 452ee9c + 6a5fa49 commit a1c2bce
Show file tree
Hide file tree
Showing 14 changed files with 749 additions and 181 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
ignore:
# Ignore Kubernetes dependencies to have full control on them.
- dependency-name: "k8s.io/*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "docker"
directory: "/docker/dev"
schedule:
interval: "daily"
34 changes: 23 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ jobs:
name: Check
runs-on: ubuntu-latest
# Execute the checks inside the container instead the VM.
container: golangci/golangci-lint:v1.24.0-alpine
container: golangci/golangci-lint:v1.42.1-alpine
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- run: ./hack/scripts/check.sh

unit-test:
name: Unit test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v2-beta
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.17
- run: make ci-unit-test

integration-test:
Expand All @@ -28,14 +28,26 @@ jobs:
needs: [check, unit-test]
strategy:
matrix:
kubernetes: [1.15.7, 1.16.4, 1.17.0, 1.18.0]
kubernetes: [1.17.17, 1.18.19, 1.19.11, 1.20.7, 1.21.1, 1.22.0]
env:
KIND_VERSION: v0.7.0
KIND_VERSION: v0.11.1
steps:
- uses: actions/checkout@v1
- run: curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
- run: curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v${{ matrix.kubernetes }}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- run: KUBERNETES_VERSION=${{ matrix.kubernetes }} make ci-integration-test
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Execute tests
env:
KIND_VERSION: v0.11.1
run: |
# Get dependencies.
echo "Getting dependencies..."
curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v${{ matrix.kubernetes }}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Start cluster.
echo "Executing ${{ matrix.kubernetes }} Kubernetes tests..."
KUBERNETES_VERSION=${{ matrix.kubernetes }} make ci-integration-test
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NOTE: Breaking release in controllers.
- Refactor internal controller queue into a decorator implementation approach.
- Remove `Delete` method from `controller.Handler` and simplify to only `Handle` method
- Add `DisableResync` flag on controller configuration to disable the resync of all resources.
- Update Kubernetes libraries for 1.22.

## [0.8.0] - 2019-12-11

Expand Down
4 changes: 2 additions & 2 deletions controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (
func newNamespaceRetriever(client kubernetes.Interface) controller.Retriever {
return controller.MustRetrieverFromListerWatcher(&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Namespaces().List(options)
return client.CoreV1().Namespaces().List(context.TODO(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Namespaces().Watch(options)
return client.CoreV1().Namespaces().Watch(context.TODO(), options)
},
})
}
Expand Down
14 changes: 9 additions & 5 deletions docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM golang:1.14
FROM golang:1.17

ARG GOLANGCI_LINT_VERSION="1.25.0"
ARG GOLANGCI_LINT_VERSION="1.42.1"
ARG MOCKERY_VERSION="2.9.2"
ARG ostype=Linux

RUN apt-get update && apt-get install -y \
Expand All @@ -11,9 +12,12 @@ RUN apt-get update && apt-get install -y \

RUN wget https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz && \
tar zxvf golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz --strip 1 -C /usr/local/bin/ && \
rm golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz

RUN go get -u github.com/vektra/mockery/...
rm golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz && \
\
wget https://github.com/vektra/mockery/releases/download/v${MOCKERY_VERSION}/mockery_${MOCKERY_VERSION}_Linux_x86_64.tar.gz && \
tar zxvf mockery_${MOCKERY_VERSION}_Linux_x86_64.tar.gz -C /tmp && \
mv /tmp/mockery /usr/local/bin/ && \
rm mockery_${MOCKERY_VERSION}_Linux_x86_64.tar.gz

# Create user.
ARG uid=1000
Expand Down
4 changes: 2 additions & 2 deletions examples/config-custom-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func run() error {
// Create our retriever so the controller knows how to get/listen for pod events.
retr := controller.MustRetrieverFromListerWatcher(&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return k8scli.CoreV1().Pods("").List(options)
return k8scli.CoreV1().Pods("").List(context.Background(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return k8scli.CoreV1().Pods("").Watch(options)
return k8scli.CoreV1().Pods("").Watch(context.Background(), options)
},
})

Expand Down
4 changes: 2 additions & 2 deletions examples/controller-concurrency-handling/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ func run() error {
// Create our retriever so the controller knows how to get/listen for pod events.
retr := controller.MustRetrieverFromListerWatcher(&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return k8scli.CoreV1().Pods("").List(options)
return k8scli.CoreV1().Pods("").List(context.Background(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return k8scli.CoreV1().Pods("").Watch(options)
return k8scli.CoreV1().Pods("").Watch(context.Background(), options)
},
})

Expand Down
4 changes: 2 additions & 2 deletions examples/leader-election-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func run() error {
// Create our retriever so the controller knows how to get/listen for pod events.
retr := controller.MustRetrieverFromListerWatcher(&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return k8scli.CoreV1().Pods("").List(options)
return k8scli.CoreV1().Pods("").List(context.Background(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return k8scli.CoreV1().Pods("").Watch(options)
return k8scli.CoreV1().Pods("").Watch(context.Background(), options)
},
})

Expand Down
4 changes: 2 additions & 2 deletions examples/metrics-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ func run() error {
// Create our retriever so the controller knows how to get/listen for pod events.
retr := controller.MustRetrieverFromListerWatcher(&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return k8scli.CoreV1().Pods("").List(options)
return k8scli.CoreV1().Pods("").List(context.Background(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return k8scli.CoreV1().Pods("").Watch(options)
return k8scli.CoreV1().Pods("").Watch(context.Background(), options)
},
})

Expand Down
8 changes: 4 additions & 4 deletions examples/multi-resource-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ func run() error {
Retriever: controller.MustRetrieverFromListerWatcher(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return k8scli.AppsV1().Deployments("").List(options)
return k8scli.AppsV1().Deployments("").List(context.Background(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return k8scli.AppsV1().Deployments("").Watch(options)
return k8scli.AppsV1().Deployments("").Watch(context.Background(), options)
},
},
),
Expand All @@ -97,10 +97,10 @@ func run() error {
Retriever: controller.MustRetrieverFromListerWatcher(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return k8scli.AppsV1().StatefulSets("").List(options)
return k8scli.AppsV1().StatefulSets("").List(context.Background(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return k8scli.AppsV1().StatefulSets("").Watch(options)
return k8scli.AppsV1().StatefulSets("").Watch(context.Background(), options)
},
},
),
Expand Down
66 changes: 59 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,64 @@
module github.com/spotahome/kooper/v2

require (
github.com/prometheus/client_golang v1.7.1
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.6.1
k8s.io/api v0.17.4
k8s.io/apimachinery v0.17.4
k8s.io/client-go v0.17.4
github.com/prometheus/client_golang v1.11.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
k8s.io/api v0.22.2
k8s.io/apimachinery v0.22.2
k8s.io/client-go v0.22.2
)

go 1.14
require (
cloud.google.com/go v0.97.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.21 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.16 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/evanphx/json-patch v4.11.0+incompatible // indirect
github.com/go-logr/logr v1.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.31.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20211006190231-62292e806868 // indirect
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 // indirect
golang.org/x/sys v0.0.0-20211006225509-1a26e0398eed // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.20.0 // indirect
k8s.io/kube-openapi v0.0.0-20210929172449-94abcedd1aa4 // indirect
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

go 1.17
Loading

0 comments on commit a1c2bce

Please sign in to comment.