Skip to content

Commit

Permalink
Merge pull request #144 from 00pf00/k8s-1.24
Browse files Browse the repository at this point in the history
Adapt to higher version of kubernetes (not less than 1.22)
  • Loading branch information
qyzhaoxun committed Aug 16, 2023
2 parents 8f02940 + acc3688 commit e8b542c
Show file tree
Hide file tree
Showing 69 changed files with 2,286 additions and 900 deletions.
4 changes: 4 additions & 0 deletions Makefile
Expand Up @@ -91,6 +91,10 @@ push.multiarch:
manifest:
@$(MAKE) image.manifest.push

# Generate manifests e.g. CRD, RBAC etc.
manifests:
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

## manifest.multiarch: Build docker images for multiple platforms and push manifest lists to registry.
.PHONY: manifest.multiarch
manifest.multiarch:
Expand Down
4 changes: 2 additions & 2 deletions artifacts/examples/crd.yaml
@@ -1,4 +1,4 @@
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: floatingips.galaxy.k8s.io
Expand All @@ -12,7 +12,7 @@ spec:
- fip
scope: Cluster
---
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: pools.galaxy.k8s.io
Expand Down
2 changes: 1 addition & 1 deletion build/docker/galaxy-ipam/Dockerfile
Expand Up @@ -16,7 +16,7 @@

## global scope TARGETPLATFORM
## ref: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
FROM --platform=${TARGETPLATFORM} golang:1.14.2 AS builder
FROM --platform=${TARGETPLATFORM} golang:1.18.2 AS builder
ARG TARGETPLATFORM
RUN echo "building for ${TARGETPLATFORM}"
ARG WORKDIR="/go/src/tkestack.io/galaxy/"
Expand Down
2 changes: 1 addition & 1 deletion build/docker/galaxy/Dockerfile
Expand Up @@ -16,7 +16,7 @@

## global scope TARGETPLATFORM
## ref: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
FROM --platform=${TARGETPLATFORM} golang:1.14.2 AS builder
FROM --platform=${TARGETPLATFORM} golang:1.18.2 AS builder
ARG TARGETPLATFORM
RUN echo "building for ${TARGETPLATFORM}"
ARG WORKDIR="/go/src/tkestack.io/galaxy/"
Expand Down
4 changes: 2 additions & 2 deletions build/lib/build.sh
Expand Up @@ -30,8 +30,8 @@ OUTPUT_DIR=${OUTPUT_DIR:-"${ROOT_DIR}/_output"}
BIN_DIR=${OUTPUT_DIR}/bin-${ARCH}
mkdir -p ${BIN_DIR}

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

function build::get_basic_cni() {
local BIN_PREFIX="galaxy"
Expand Down
4 changes: 2 additions & 2 deletions build/lib/golang.mk
Expand Up @@ -18,9 +18,9 @@
# Makefile helper functions for golang
#

GO_IMAGE := golang:1.14.2
GO_IMAGE := golang:1.18.2
GO := go
GO_SUPPORTED_VERSIONS ?= 1.11|1.12|1.13|1.14
GO_SUPPORTED_VERSIONS ?= 1.14|1.18
GO_LDFLAGS += -X $(VERSION_PACKAGE).GIT_COMMIT=$(GIT_COMMIT) \
-X $(VERSION_PACKAGE).GO_VERSION=$(shell go version | awk '{print $$3}') \
-X $(VERSION_PACKAGE).BUILD_TIME=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
Expand Down
3 changes: 3 additions & 0 deletions cmd/galaxy-ipam/galaxy-ipam.go
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/spf13/pflag"
"k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
glog "k8s.io/klog"

"tkestack.io/galaxy/pkg/ipam/server"
"tkestack.io/galaxy/pkg/utils/ldflags"
)
Expand All @@ -37,6 +39,7 @@ func main() {
// add command line args
s.AddFlags(pflag.CommandLine)

glog.InitFlags(nil)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
Expand Down
2 changes: 2 additions & 0 deletions cmd/galaxy/galaxy.go
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
glog "k8s.io/klog"

"tkestack.io/galaxy/pkg/galaxy"
"tkestack.io/galaxy/pkg/signal"
"tkestack.io/galaxy/pkg/utils/ldflags"
Expand All @@ -35,6 +36,7 @@ func main() {
galaxy := galaxy.NewGalaxy()
// add command line args
galaxy.AddFlags(pflag.CommandLine)
glog.InitFlags(nil)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
Expand Down
3 changes: 2 additions & 1 deletion cni/tke-route-eni/driver.go
@@ -1,3 +1,5 @@
//go:build linux

/*
* Tencent is pleased to support the open source community by making TKEStack available.
*
Expand All @@ -14,7 +16,6 @@
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
// +build linux

package main

Expand Down
22 changes: 21 additions & 1 deletion cni/underlay/veth/veth.go
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"github.com/containernetworking/cni/pkg/types/current"
"net"
"runtime"

Expand Down Expand Up @@ -102,5 +103,24 @@ func cmdAdd(args *skel.CmdArgs) error {
}
args.IfName = ifName
result, _ := t020.GetResult(results[0])
return result.Print()
if conf.CNIVersion == result.CNIVersion || conf.CNIVersion == "" {
return result.Print()
}

currentResult := &current.Result{}
currentResult.IPs = []*current.IPConfig{
{
Version: "4",
Gateway: result.IP4.Gateway,
Address: result.IP4.IP,
},
}
currentResult.Routes = []*types.Route{}

for _, r := range result.IP4.Routes {
currentResult.Routes = append(currentResult.Routes, &r)
}
currentResult.CNIVersion = conf.CNIVersion
currentResult.DNS = result.DNS
return currentResult.Print()
}
25 changes: 24 additions & 1 deletion cni/veth/veth.go
Expand Up @@ -19,6 +19,7 @@ package main
import (
"encoding/json"
"fmt"
"github.com/containernetworking/cni/pkg/types/current"
"net"
"os"
"runtime"
Expand Down Expand Up @@ -199,7 +200,29 @@ func cmdAdd(args *skel.CmdArgs) error {
return err
}
result.DNS = conf.DNS
return result.Print()

isCurrent := false
for _, v := range current.SupportedVersions {
if v == generalResult.Version() {
isCurrent = true
}
}
if !isCurrent {
return result.Print()
}
currentResult, ok := generalResult.(*current.Result)
if ok {
for _, v := range currentResult.IPs {
if v.Version == "4" {
v.Address = result.IP4.IP
v.Gateway = result.IP4.Gateway
for _, route := range result.IP4.Routes {
currentResult.Routes = append(currentResult.Routes, &route)
}
}
}
}
return currentResult.Print()
}

func cmdDel(args *skel.CmdArgs) error {
Expand Down
102 changes: 83 additions & 19 deletions go.mod
@@ -1,34 +1,98 @@
module tkestack.io/galaxy

go 1.14
go 1.18

require (
github.com/Microsoft/go-winio v0.4.15 // indirect
github.com/containernetworking/cni v0.8.0
github.com/containernetworking/plugins v0.8.7
github.com/dbdd4us/qcloudapi-sdk-go v0.0.0-20190530123522-c8d9381de48c
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/engine-api v0.4.0
github.com/docker/go-connections v0.4.0 // indirect
github.com/emicklei/go-restful v2.10.0+incompatible
github.com/emicklei/go-restful-swagger12 v0.0.0-20170926063155-7524189396c6
github.com/golang/protobuf v1.3.2
github.com/google/uuid v1.1.1
github.com/onsi/ginkgo v1.10.3
github.com/onsi/gomega v1.7.1
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/prometheus/client_golang v0.9.2
github.com/golang/protobuf v1.5.3
github.com/google/uuid v1.1.2
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.24.2
github.com/prometheus/client_golang v1.14.0
github.com/spf13/pflag v1.0.5
github.com/vishvananda/netlink v1.0.0
github.com/vishvananda/netns v0.0.0-20190625233234-7109fa855b0f
golang.org/x/net v0.0.0-20191011234655-491137f69257
golang.org/x/sys v0.0.0-20191010194322-b09406accb47
google.golang.org/grpc v1.24.0
k8s.io/api v0.16.15
k8s.io/apiextensions-apiserver v0.16.15
k8s.io/apimachinery v0.16.15
k8s.io/client-go v0.16.15
k8s.io/component-base v0.16.15
golang.org/x/net v0.8.0
golang.org/x/sys v0.6.0
google.golang.org/grpc v1.51.0
gotest.tools v2.2.0+incompatible
k8s.io/api v0.24.3
k8s.io/apiextensions-apiserver v0.24.3
k8s.io/apimachinery v0.24.3
k8s.io/client-go v0.24.3
k8s.io/code-generator v0.24.3
k8s.io/component-base v0.24.3
k8s.io/cri-api v0.27.4
k8s.io/klog v1.0.0
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
k8s.io/klog/v2 v2.80.1
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
sigs.k8s.io/controller-tools v0.9.2
)

require (
github.com/Microsoft/go-winio v0.4.15 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coreos/go-iptables v0.4.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gobuffalo/flect v0.2.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8 // indirect
github.com/spf13/cobra v1.6.1 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

0 comments on commit e8b542c

Please sign in to comment.