Operator support work with crds v1.7.0
Signed-off-by: Lan Liang <gcslyp@gmail.com>
This commit is contained in:
parent
f1f1a82dc7
commit
3fbd7219d1
|
@ -31,19 +31,19 @@ spec:
|
||||||
serviceSubnet: 10.96.0.0/12
|
serviceSubnet: 10.96.0.0/12
|
||||||
karmadaAggregatedAPIServer:
|
karmadaAggregatedAPIServer:
|
||||||
imageRepository: docker.io/karmada/karmada-aggregated-apiserver
|
imageRepository: docker.io/karmada/karmada-aggregated-apiserver
|
||||||
imageTag: v1.6.0
|
imageTag: v1.7.0
|
||||||
replicas: 1
|
replicas: 1
|
||||||
karmadaControllerManager:
|
karmadaControllerManager:
|
||||||
imageRepository: docker.io/karmada/karmada-controller-manager
|
imageRepository: docker.io/karmada/karmada-controller-manager
|
||||||
imageTag: v1.6.0
|
imageTag: v1.7.0
|
||||||
replicas: 1
|
replicas: 1
|
||||||
karmadaScheduler:
|
karmadaScheduler:
|
||||||
imageRepository: docker.io/karmada/karmada-scheduler
|
imageRepository: docker.io/karmada/karmada-scheduler
|
||||||
imageTag: v1.6.0
|
imageTag: v1.7.0
|
||||||
replicas: 1
|
replicas: 1
|
||||||
karmadaWebhook:
|
karmadaWebhook:
|
||||||
imageRepository: docker.io/karmada/karmada-webhook
|
imageRepository: docker.io/karmada/karmada-webhook
|
||||||
imageTag: v1.6.0
|
imageTag: v1.7.0
|
||||||
replicas: 1
|
replicas: 1
|
||||||
kubeControllerManager:
|
kubeControllerManager:
|
||||||
imageRepository: registry.k8s.io/kube-controller-manager
|
imageRepository: registry.k8s.io/kube-controller-manager
|
||||||
|
|
|
@ -15,7 +15,7 @@ const (
|
||||||
// EtcdDefaultVersion defines the default of the karmada etcd image tag
|
// EtcdDefaultVersion defines the default of the karmada etcd image tag
|
||||||
EtcdDefaultVersion = "3.5.9-0"
|
EtcdDefaultVersion = "3.5.9-0"
|
||||||
// KarmadaDefaultVersion defines the default of the karmada components image tag
|
// KarmadaDefaultVersion defines the default of the karmada components image tag
|
||||||
KarmadaDefaultVersion = "v1.6.0"
|
KarmadaDefaultVersion = "v1.7.0"
|
||||||
// KubeDefaultVersion defines the default of the karmada apiserver and kubeControllerManager image tag
|
// KubeDefaultVersion defines the default of the karmada apiserver and kubeControllerManager image tag
|
||||||
KubeDefaultVersion = "v1.25.4"
|
KubeDefaultVersion = "v1.25.4"
|
||||||
// KarmadaDefaultServiceSubnet defines the default of the subnet used by k8s services.
|
// KarmadaDefaultServiceSubnet defines the default of the subnet used by k8s services.
|
||||||
|
|
|
@ -115,12 +115,8 @@ func runCrds(r workflow.RunData) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createCrds(crdsClient *crdsclient.Clientset, crdsPath string) error {
|
func createCrds(crdsClient *crdsclient.Clientset, crdsPath string) error {
|
||||||
for _, file := range util.ListFiles(crdsPath) {
|
for _, file := range util.ListFileWithSuffix(crdsPath, ".yaml") {
|
||||||
if file.IsDir() || path.Ext(file.Name()) != ".yaml" {
|
crdBytes, err := util.ReadYamlFile(file.AbsPath)
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
crdBytes, err := util.ReadYamlFile(path.Join(crdsPath, file.Name()))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -138,18 +134,13 @@ func createCrds(crdsClient *crdsclient.Clientset, crdsPath string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func patchCrds(crdsClient *crdsclient.Clientset, patchPath string, caBundle string) error {
|
func patchCrds(crdsClient *crdsclient.Clientset, patchPath string, caBundle string) error {
|
||||||
for _, file := range util.ListFiles(patchPath) {
|
for _, file := range util.ListFileWithSuffix(patchPath, ".yaml") {
|
||||||
if file.IsDir() || path.Ext(file.Name()) != ".yaml" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
reg, err := regexp.Compile("{{caBundle}}")
|
reg, err := regexp.Compile("{{caBundle}}")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
crdPath := path.Join(patchPath, file.Name())
|
crdBytes, err := util.ReplaceYamlForReg(file.AbsPath, caBundle, reg)
|
||||||
crdBytes, err := util.ReplaceYamlForReg(crdPath, caBundle, reg)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
@ -145,6 +146,28 @@ func ListFiles(path string) []os.FileInfo {
|
||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FileExtInfo struct {
|
||||||
|
os.FileInfo
|
||||||
|
AbsPath string
|
||||||
|
}
|
||||||
|
|
||||||
|
func ListFileWithSuffix(path, suffix string) []FileExtInfo {
|
||||||
|
files := []FileExtInfo{}
|
||||||
|
if err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
|
||||||
|
if !info.IsDir() && strings.HasSuffix(path, suffix) {
|
||||||
|
files = append(files, FileExtInfo{
|
||||||
|
AbsPath: path,
|
||||||
|
FileInfo: info,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return files
|
||||||
|
}
|
||||||
|
|
||||||
// PathExists check whether the path is exist
|
// PathExists check whether the path is exist
|
||||||
func PathExists(path string) (bool, error) {
|
func PathExists(path string) (bool, error) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestListFileWithSuffix(t *testing.T) {
|
||||||
|
suffix := ".yaml"
|
||||||
|
files := ListFileWithSuffix(".", suffix)
|
||||||
|
want := 2
|
||||||
|
got := len(files)
|
||||||
|
if want != got {
|
||||||
|
t.Errorf("Expected %d ,but got :%d", want, got)
|
||||||
|
}
|
||||||
|
for _, f := range files {
|
||||||
|
if !strings.HasSuffix(f.AbsPath, suffix) {
|
||||||
|
t.Errorf("Want suffix with %s , but not exist, path is:%s", suffix, f.AbsPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue