Skip to content

Commit

Permalink
Merge pull request #152 from phantomnat/feat/update-k8s
Browse files Browse the repository at this point in the history
Chore: update k8s to 1.29
  • Loading branch information
FogDong authored Nov 20, 2024
2 parents 48259e0 + 3112ccc commit 33c8891
Show file tree
Hide file tree
Showing 12 changed files with 4,152 additions and 452 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ on:

env:
# Common versions
GO_VERSION: '1.20'
GOLANGCI_VERSION: 'v1.49'
KIND_VERSION: 'v0.19.0'
GO_VERSION: '1.22'
GOLANGCI_VERSION: 'v1.56'
KIND_VERSION: 'v0.23.0'

jobs:

Expand Down Expand Up @@ -54,9 +54,9 @@ jobs:
- name: install Kubebuilder
uses: RyanSiu1995/[email protected]
with:
version: 3.1.0
version: 3.15.1
kubebuilderOnly: false
kubernetesVersion: v1.22.0
kubernetesVersion: v1.29.0
- name: Run Make test
run: make test
- name: Upload coverage report
Expand Down Expand Up @@ -93,6 +93,9 @@ jobs:
restore-keys: ${{ runner.os }}-pkg-
- name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
version: v0.24.0
node_image: kindest/node:v1.29.8
- name: Build Image
run: |
make image
Expand Down Expand Up @@ -135,6 +138,9 @@ jobs:
run: curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash
- name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
version: v0.24.0
node_image: kindest/node:v1.29.8
- name: Prepare OCM testing environment
run: |
clusteradm init --output-join-command-file join.sh --wait
Expand All @@ -152,6 +158,8 @@ jobs:
cluster-gateway ./charts/addon-manager \
--set tag=latest
go run ./e2e/env/prepare | kubectl apply -f -
kubectl rollout status deployment -n vela-system gateway-deployment --timeout 1m
kubectl wait --for=condition=Available apiservice/v1alpha1.cluster.core.oam.dev
- name: Run e2e test
run: |
make test-e2e-ocm
2 changes: 1 addition & 1 deletion .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*'
env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.22'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/oamdev/cluster-gateway/go'
GITHUB_REF: ${{ github.ref }}
Expand Down
42 changes: 36 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
IMG ?= controller:latest
IMG_TAG ?= latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
CRD_OPTIONS ?= "crd"

OS?=linux
ARCH?=amd64
Expand All @@ -20,15 +20,15 @@ VERSION=v0.0.21
all: manager

# Run tests
test: generate fmt vet manifests
test: generate generate-openapi fmt vet manifests
go test ./pkg/... -coverprofile cover.out

# Build manager binary
manager: generate fmt vet
manager: generate generate-openapi fmt vet
go build -o bin/manager ./cmd/apiserver/main.go

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
run: generate generate-openapi fmt vet manifests
go run ./cmd/apiserver/main.go

local-run:
Expand Down Expand Up @@ -76,14 +76,29 @@ ifeq (, $(shell which controller-gen))
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0 ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

openapi-gen:
ifeq (, $(shell which openapi-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go install k8s.io/kube-openapi/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
OPENAPI_GEN=$(GOBIN)/openapi-gen
else
OPENAPI_GEN=$(shell which openapi-gen)
endif

kustomize:
ifeq (, $(shell which kustomize))
@{ \
Expand All @@ -100,7 +115,7 @@ KUSTOMIZE=$(shell which kustomize)
endif

client-gen:
go install k8s.io/code-generator/cmd/client-gen@v0.21.2
go install k8s.io/code-generator/cmd/client-gen@v0.29.2
apiserver-runtime-gen \
--module github.com/oam-dev/cluster-gateway \
-g client-gen \
Expand All @@ -111,6 +126,21 @@ client-gen:
generate: controller-gen
${CONTROLLER_GEN} object:headerFile="hack/boilerplate.go.txt" paths="./pkg/apis/proxy/..."

.PHONY: generate-openapi
generate-openapi: openapi-gen
${OPENAPI_GEN} \
--output-pkg github.com/oam-dev/cluster-gateway/pkg/apis \
--output-file zz_generated.openapi.go \
--output-dir ./pkg/apis/generated \
--output-pkg "generated" \
--go-header-file ./hack/boilerplate.go.txt \
./pkg/apis/proxy/v1alpha1 \
./pkg/apis/cluster/v1alpha1 \
k8s.io/apimachinery/pkg/api/resource \
k8s.io/apimachinery/pkg/apis/meta/v1 \
k8s.io/apimachinery/pkg/runtime \
k8s.io/apimachinery/pkg/version

manifests: controller-gen
${CONTROLLER_GEN} $(CRD_OPTIONS) \
paths="./pkg/apis/proxy/..." \
Expand Down
2 changes: 1 addition & 1 deletion cmd/addon-manager/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG OS=linux
ARG ARCH=amd64
# Build the manager binary
FROM golang:1.20 as builder
FROM golang:1.22 as builder
ARG OS
ARG ARCH

Expand Down
12 changes: 9 additions & 3 deletions cmd/addon-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
ocmauthv1alpha1 "open-cluster-management.io/managed-serviceaccount/api/v1alpha1"
ctrl "sigs.k8s.io/controller-runtime"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

var (
Expand Down Expand Up @@ -57,9 +59,13 @@ func main() {
ctrl.SetLogger(logger)

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
WebhookServer: webhook.NewServer(webhook.Options{
Port: 9443,
}),
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "cluster-gateway-addon-manager",
Expand Down
2 changes: 1 addition & 1 deletion cmd/apiserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.20-alpine as builder
FROM golang:1.22-alpine as builder
ARG OS
ARG ARCH

Expand Down
5 changes: 3 additions & 2 deletions cmd/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/server"
genericfilters "k8s.io/apiserver/pkg/server/filters"
"k8s.io/klog/v2"
"sigs.k8s.io/apiserver-runtime/pkg/builder"

genericfilters "k8s.io/apiserver/pkg/server/filters"

"github.com/oam-dev/cluster-gateway/pkg/config"
"github.com/oam-dev/cluster-gateway/pkg/metrics"
"github.com/oam-dev/cluster-gateway/pkg/options"
"github.com/oam-dev/cluster-gateway/pkg/util/singleton"

// +kubebuilder:scaffold:resource-imports
clusterv1alpha1 "github.com/oam-dev/cluster-gateway/pkg/apis/cluster/v1alpha1"
"github.com/oam-dev/cluster-gateway/pkg/apis/generated"

_ "github.com/oam-dev/cluster-gateway/pkg/featuregates"
)
Expand Down Expand Up @@ -75,6 +75,7 @@ func main() {
return server
}).
WithPostStartHook("init-master-loopback-client", singleton.InitLoopbackClient).
WithOpenAPIDefinitions("Cluster Gateway", "1.0.0", generated.GetOpenAPIDefinitions).
Build()
if err != nil {
klog.Fatal(err)
Expand Down
Loading

0 comments on commit 33c8891

Please sign in to comment.