Skip to content

Commit e8b542c

Browse files
authored
Merge pull request #144 from 00pf00/k8s-1.24
Adapt to higher version of kubernetes (not less than 1.22)
2 parents 8f02940 + acc3688 commit e8b542c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2286
-900
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ push.multiarch:
9191
manifest:
9292
@$(MAKE) image.manifest.push
9393

94+
# Generate manifests e.g. CRD, RBAC etc.
95+
manifests:
96+
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=./pkg/ipam/apis/... rbac:roleName=controller-perms crd:allowDangerousTypes=true output:crd:artifacts:config=./artifacts/crds
97+
9498
## manifest.multiarch: Build docker images for multiple platforms and push manifest lists to registry.
9599
.PHONY: manifest.multiarch
96100
manifest.multiarch:

artifacts/examples/crd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: apiextensions.k8s.io/v1beta1
1+
apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
name: floatingips.galaxy.k8s.io
@@ -12,7 +12,7 @@ spec:
1212
- fip
1313
scope: Cluster
1414
---
15-
apiVersion: apiextensions.k8s.io/v1beta1
15+
apiVersion: apiextensions.k8s.io/v1
1616
kind: CustomResourceDefinition
1717
metadata:
1818
name: pools.galaxy.k8s.io

build/docker/galaxy-ipam/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## global scope TARGETPLATFORM
1818
## ref: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
19-
FROM --platform=${TARGETPLATFORM} golang:1.14.2 AS builder
19+
FROM --platform=${TARGETPLATFORM} golang:1.18.2 AS builder
2020
ARG TARGETPLATFORM
2121
RUN echo "building for ${TARGETPLATFORM}"
2222
ARG WORKDIR="/go/src/tkestack.io/galaxy/"

build/docker/galaxy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## global scope TARGETPLATFORM
1818
## ref: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
19-
FROM --platform=${TARGETPLATFORM} golang:1.14.2 AS builder
19+
FROM --platform=${TARGETPLATFORM} golang:1.18.2 AS builder
2020
ARG TARGETPLATFORM
2121
RUN echo "building for ${TARGETPLATFORM}"
2222
ARG WORKDIR="/go/src/tkestack.io/galaxy/"

build/lib/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ OUTPUT_DIR=${OUTPUT_DIR:-"${ROOT_DIR}/_output"}
3030
BIN_DIR=${OUTPUT_DIR}/bin-${ARCH}
3131
mkdir -p ${BIN_DIR}
3232

33-
CNI_VERSION="v0.6.0"
34-
CNI_BIN=https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-${ARCH}-${CNI_VERSION}.tgz
33+
CNI_VERSION="v0.8.0"
34+
CNI_BIN=https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-amd64-${CNI_VERSION}.tgz
3535

3636
function build::get_basic_cni() {
3737
local BIN_PREFIX="galaxy"

build/lib/golang.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
# Makefile helper functions for golang
1919
#
2020

21-
GO_IMAGE := golang:1.14.2
21+
GO_IMAGE := golang:1.18.2
2222
GO := go
23-
GO_SUPPORTED_VERSIONS ?= 1.11|1.12|1.13|1.14
23+
GO_SUPPORTED_VERSIONS ?= 1.14|1.18
2424
GO_LDFLAGS += -X $(VERSION_PACKAGE).GIT_COMMIT=$(GIT_COMMIT) \
2525
-X $(VERSION_PACKAGE).GO_VERSION=$(shell go version | awk '{print $$3}') \
2626
-X $(VERSION_PACKAGE).BUILD_TIME=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')

cmd/galaxy-ipam/galaxy-ipam.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"github.com/spf13/pflag"
2626
"k8s.io/component-base/cli/flag"
2727
"k8s.io/component-base/logs"
28+
glog "k8s.io/klog"
29+
2830
"tkestack.io/galaxy/pkg/ipam/server"
2931
"tkestack.io/galaxy/pkg/utils/ldflags"
3032
)
@@ -37,6 +39,7 @@ func main() {
3739
// add command line args
3840
s.AddFlags(pflag.CommandLine)
3941

42+
glog.InitFlags(nil)
4043
flag.InitFlags()
4144
logs.InitLogs()
4245
defer logs.FlushLogs()

cmd/galaxy/galaxy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"k8s.io/component-base/cli/flag"
2525
"k8s.io/component-base/logs"
2626
glog "k8s.io/klog"
27+
2728
"tkestack.io/galaxy/pkg/galaxy"
2829
"tkestack.io/galaxy/pkg/signal"
2930
"tkestack.io/galaxy/pkg/utils/ldflags"
@@ -35,6 +36,7 @@ func main() {
3536
galaxy := galaxy.NewGalaxy()
3637
// add command line args
3738
galaxy.AddFlags(pflag.CommandLine)
39+
glog.InitFlags(nil)
3840
flag.InitFlags()
3941
logs.InitLogs()
4042
defer logs.FlushLogs()

cni/tke-route-eni/driver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
/*
24
* Tencent is pleased to support the open source community by making TKEStack available.
35
*
@@ -14,7 +16,6 @@
1416
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
1517
* specific language governing permissions and limitations under the License.
1618
*/
17-
// +build linux
1819

1920
package main
2021

cni/underlay/veth/veth.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"fmt"
6+
"github.com/containernetworking/cni/pkg/types/current"
67
"net"
78
"runtime"
89

@@ -102,5 +103,24 @@ func cmdAdd(args *skel.CmdArgs) error {
102103
}
103104
args.IfName = ifName
104105
result, _ := t020.GetResult(results[0])
105-
return result.Print()
106+
if conf.CNIVersion == result.CNIVersion || conf.CNIVersion == "" {
107+
return result.Print()
108+
}
109+
110+
currentResult := &current.Result{}
111+
currentResult.IPs = []*current.IPConfig{
112+
{
113+
Version: "4",
114+
Gateway: result.IP4.Gateway,
115+
Address: result.IP4.IP,
116+
},
117+
}
118+
currentResult.Routes = []*types.Route{}
119+
120+
for _, r := range result.IP4.Routes {
121+
currentResult.Routes = append(currentResult.Routes, &r)
122+
}
123+
currentResult.CNIVersion = conf.CNIVersion
124+
currentResult.DNS = result.DNS
125+
return currentResult.Print()
106126
}

0 commit comments

Comments
 (0)