提交 744bd053 编写于 作者: H hongming

Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	cmd/ks-apiserver/app/server.go
[submodule "vendor/github.com/knative/pkg"]
path = vendor/github.com/knative/pkg
url = https://github.com/knative/pkg.git
...@@ -15,16 +15,15 @@ before_install: ...@@ -15,16 +15,15 @@ before_install:
- go get -u github.com/golang/dep/cmd/dep - go get -u github.com/golang/dep/cmd/dep
before_script: before_script:
- dep ensure -v
- docker --version - docker --version
- bash hack/install_kubebuilder.sh - bash hack/install_kubebuilder.sh
script: script:
- make all && make test && bash hack/docker_build.sh - make all
deploy: deploy:
skip_cleanup: true skip_cleanup: true
provider: script provider: script
script: bash hack/docker_push.sh script: bash hack/docker_build.sh && bash hack/docker_push.sh
on: on:
branch: master branch: master
...@@ -163,6 +163,12 @@ ...@@ -163,6 +163,12 @@
revision = "b7062368c258c9e8f8cbe9dd2e6aebfa1b747be6" revision = "b7062368c258c9e8f8cbe9dd2e6aebfa1b747be6"
version = "v1.0.0" version = "v1.0.0"
[[projects]]
name = "github.com/evanphx/json-patch"
packages = ["."]
revision = "72bf35d0ff611848c1dc9df0f976c81192392fa5"
version = "v4.1.0"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/flynn/go-shlex" name = "github.com/flynn/go-shlex"
...@@ -439,8 +445,22 @@ ...@@ -439,8 +445,22 @@
name = "github.com/knative/pkg" name = "github.com/knative/pkg"
packages = [ packages = [
"apis/istio", "apis/istio",
"apis/istio/authentication",
"apis/istio/authentication/v1alpha1",
"apis/istio/common/v1alpha1", "apis/istio/common/v1alpha1",
"apis/istio/v1alpha3" "apis/istio/v1alpha3",
"client/clientset/versioned",
"client/clientset/versioned/scheme",
"client/clientset/versioned/typed/authentication/v1alpha1",
"client/clientset/versioned/typed/istio/v1alpha3",
"client/informers/externalversions",
"client/informers/externalversions/authentication",
"client/informers/externalversions/authentication/v1alpha1",
"client/informers/externalversions/internalinterfaces",
"client/informers/externalversions/istio",
"client/informers/externalversions/istio/v1alpha3",
"client/listers/authentication/v1alpha1",
"client/listers/istio/v1alpha3"
] ]
revision = "cd278f2d3394c865fda66bca12459e879e0279b8" revision = "cd278f2d3394c865fda66bca12459e879e0279b8"
...@@ -454,13 +474,32 @@ ...@@ -454,13 +474,32 @@
branch = "master" branch = "master"
name = "github.com/kubernetes-sigs/application" name = "github.com/kubernetes-sigs/application"
packages = [ packages = [
"pkg/apis/app/v1beta1",
"pkg/component", "pkg/component",
"pkg/customresource", "pkg/customresource",
"pkg/finalizer", "pkg/finalizer",
"pkg/genericreconciler",
"pkg/kbcontroller",
"pkg/resource" "pkg/resource"
] ]
revision = "4ead7f1b87048b7717b3e474a21fdc07e6bce636" revision = "4ead7f1b87048b7717b3e474a21fdc07e6bce636"
[[projects]]
name = "github.com/kubesphere/s2ioperator"
packages = [
"pkg/apis/devops/v1alpha1",
"pkg/client/clientset/versioned",
"pkg/client/clientset/versioned/scheme",
"pkg/client/clientset/versioned/typed/devops/v1alpha1",
"pkg/client/informers/externalversions",
"pkg/client/informers/externalversions/devops",
"pkg/client/informers/externalversions/devops/v1alpha1",
"pkg/client/informers/externalversions/internalinterfaces",
"pkg/client/listers/devops/v1alpha1"
]
revision = "cb9f6d6145324977e5904ded95de7bfca7a01151"
version = "v0.0.4"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/lucas-clemente/aes12" name = "github.com/lucas-clemente/aes12"
...@@ -1001,7 +1040,8 @@ ...@@ -1001,7 +1040,8 @@
packages = [ packages = [
".", ".",
"cipher", "cipher",
"json" "json",
"jwt"
] ]
revision = "628223f44a71f715d2881ea69afc795a1e9c01be" revision = "628223f44a71f715d2881ea69afc795a1e9c01be"
version = "v2.3.0" version = "v2.3.0"
...@@ -1065,7 +1105,8 @@ ...@@ -1065,7 +1105,8 @@
"pkg/apis/apiextensions/v1beta1", "pkg/apis/apiextensions/v1beta1",
"pkg/client/clientset/clientset", "pkg/client/clientset/clientset",
"pkg/client/clientset/clientset/scheme", "pkg/client/clientset/clientset/scheme",
"pkg/client/clientset/clientset/typed/apiextensions/v1beta1" "pkg/client/clientset/clientset/typed/apiextensions/v1beta1",
"pkg/features"
] ]
revision = "0fe22c71c47604641d9aa352c785b7912c200562" revision = "0fe22c71c47604641d9aa352c785b7912c200562"
version = "kubernetes-1.13.1" version = "kubernetes-1.13.1"
...@@ -1073,13 +1114,16 @@ ...@@ -1073,13 +1114,16 @@
[[projects]] [[projects]]
name = "k8s.io/apimachinery" name = "k8s.io/apimachinery"
packages = [ packages = [
"pkg/api/equality",
"pkg/api/errors", "pkg/api/errors",
"pkg/api/meta", "pkg/api/meta",
"pkg/api/resource", "pkg/api/resource",
"pkg/api/validation",
"pkg/api/validation/path", "pkg/api/validation/path",
"pkg/apis/meta/internalversion", "pkg/apis/meta/internalversion",
"pkg/apis/meta/v1", "pkg/apis/meta/v1",
"pkg/apis/meta/v1/unstructured", "pkg/apis/meta/v1/unstructured",
"pkg/apis/meta/v1/validation",
"pkg/apis/meta/v1beta1", "pkg/apis/meta/v1beta1",
"pkg/conversion", "pkg/conversion",
"pkg/conversion/queryparams", "pkg/conversion/queryparams",
...@@ -1120,23 +1164,28 @@ ...@@ -1120,23 +1164,28 @@
"third_party/forked/golang/reflect" "third_party/forked/golang/reflect"
] ]
revision = "2b1284ed4c93a43499e781493253e2ac5959c4fd" revision = "2b1284ed4c93a43499e781493253e2ac5959c4fd"
version = "kubernetes-1.13.0" version = "kubernetes-1.13.1"
[[projects]] [[projects]]
branch = "master"
name = "k8s.io/apiserver" name = "k8s.io/apiserver"
packages = [ packages = [
"pkg/apis/audit", "pkg/apis/audit",
"pkg/authentication/authenticator",
"pkg/authentication/serviceaccount",
"pkg/authentication/user", "pkg/authentication/user",
"pkg/authorization/authorizer", "pkg/authorization/authorizer",
"pkg/endpoints/request" "pkg/endpoints/request",
"pkg/features",
"pkg/util/feature"
] ]
revision = "39e839dff03462945cc991fb9dac4469c951772d" revision = "3ccfe8365421eb08e334b195786a2973460741d8"
version = "kubernetes-1.13.1"
[[projects]] [[projects]]
name = "k8s.io/client-go" name = "k8s.io/client-go"
packages = [ packages = [
"discovery", "discovery",
"discovery/fake",
"dynamic", "dynamic",
"informers", "informers",
"informers/admissionregistration", "informers/admissionregistration",
...@@ -1255,6 +1304,7 @@ ...@@ -1255,6 +1304,7 @@
"rest", "rest",
"rest/watch", "rest/watch",
"restmapper", "restmapper",
"testing",
"third_party/forked/golang/template", "third_party/forked/golang/template",
"tools/auth", "tools/auth",
"tools/cache", "tools/cache",
...@@ -1268,6 +1318,7 @@ ...@@ -1268,6 +1318,7 @@
"tools/pager", "tools/pager",
"tools/record", "tools/record",
"tools/reference", "tools/reference",
"tools/watch",
"transport", "transport",
"util/buffer", "util/buffer",
"util/cert", "util/cert",
...@@ -1283,7 +1334,6 @@ ...@@ -1283,7 +1334,6 @@
version = "kubernetes-1.13.1" version = "kubernetes-1.13.1"
[[projects]] [[projects]]
branch = "release-1.13"
name = "k8s.io/code-generator" name = "k8s.io/code-generator"
packages = [ packages = [
"cmd/client-gen", "cmd/client-gen",
...@@ -1297,6 +1347,7 @@ ...@@ -1297,6 +1347,7 @@
"pkg/util" "pkg/util"
] ]
revision = "c2090bec4d9b1fb25de3812f868accc2bc9ecbae" revision = "c2090bec4d9b1fb25de3812f868accc2bc9ecbae"
version = "kubernetes-1.13.1"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -1327,14 +1378,50 @@ ...@@ -1327,14 +1378,50 @@
[[projects]] [[projects]]
name = "k8s.io/kubernetes" name = "k8s.io/kubernetes"
packages = ["pkg/util/slice"] packages = [
"pkg/api/legacyscheme",
"pkg/api/service",
"pkg/api/v1/pod",
"pkg/apis/apps",
"pkg/apis/autoscaling",
"pkg/apis/core",
"pkg/apis/core/helper",
"pkg/apis/core/install",
"pkg/apis/core/pods",
"pkg/apis/core/v1",
"pkg/apis/core/v1/helper",
"pkg/apis/core/validation",
"pkg/apis/scheduling",
"pkg/capabilities",
"pkg/controller",
"pkg/features",
"pkg/fieldpath",
"pkg/kubelet/types",
"pkg/master/ports",
"pkg/scheduler/api",
"pkg/security/apparmor",
"pkg/serviceaccount",
"pkg/util/file",
"pkg/util/hash",
"pkg/util/metrics",
"pkg/util/net/sets",
"pkg/util/parsers",
"pkg/util/slice",
"pkg/util/taints"
]
revision = "c27b913fddd1a6c480c229191a087698aa92f0b1" revision = "c27b913fddd1a6c480c229191a087698aa92f0b1"
version = "v1.13.4" version = "v1.13.4"
[[projects]]
branch = "master"
name = "k8s.io/utils"
packages = ["pointer"]
revision = "21c4ce38f2a793ec01e925ddc31216500183b773"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "sigs.k8s.io/application" name = "sigs.k8s.io/application"
packages = ["pkg/apis/app/v1beta1"] packages = ["pkg/controller/application"]
revision = "4ead7f1b87048b7717b3e474a21fdc07e6bce636" revision = "4ead7f1b87048b7717b3e474a21fdc07e6bce636"
[[projects]] [[projects]]
...@@ -1346,7 +1433,6 @@ ...@@ -1346,7 +1433,6 @@
"pkg/client/apiutil", "pkg/client/apiutil",
"pkg/client/config", "pkg/client/config",
"pkg/controller", "pkg/controller",
"pkg/controller/controllerutil",
"pkg/envtest", "pkg/envtest",
"pkg/envtest/printer", "pkg/envtest/printer",
"pkg/event", "pkg/event",
...@@ -1416,6 +1502,6 @@ ...@@ -1416,6 +1502,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "9c1d98a69374a4d7fbddc9df92f3ba83c5d4a0753b887577c161b2802f9c9494" inputs-digest = "662b6da91343ff0a611e4487b8eef803b103b676f5b2a5db7ed8351846218fc5"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1
...@@ -14,7 +14,9 @@ required = [ ...@@ -14,7 +14,9 @@ required = [
"sigs.k8s.io/controller-runtime/pkg/runtime/signals", "sigs.k8s.io/controller-runtime/pkg/runtime/signals",
"sigs.k8s.io/controller-runtime/pkg/source", "sigs.k8s.io/controller-runtime/pkg/source",
"sigs.k8s.io/testing_frameworks/integration", # for integration testing "sigs.k8s.io/testing_frameworks/integration", # for integration testing
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1", "github.com/kubesphere/s2ioperator/pkg/client/clientset/versioned",
"github.com/kubesphere/s2ioperator/pkg/client/informers/externalversions",
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
] ]
[[constraint]] [[constraint]]
...@@ -29,6 +31,10 @@ required = [ ...@@ -29,6 +31,10 @@ required = [
name = "k8s.io/apimachinery" name = "k8s.io/apimachinery"
version = "kubernetes-1.13.1" version = "kubernetes-1.13.1"
[[override]]
name = "k8s.io/apiserver"
version = "kubernetes-1.13.1"
[[constraint]] [[constraint]]
name = "k8s.io/code-generator" name = "k8s.io/code-generator"
version = "kubernetes-1.13.1" version = "kubernetes-1.13.1"
...@@ -49,6 +55,10 @@ required = [ ...@@ -49,6 +55,10 @@ required = [
name="sigs.k8s.io/controller-tools" name="sigs.k8s.io/controller-tools"
version="v0.1.7" version="v0.1.7"
[[constraint]]
name="github.com/kubesphere/s2ioperator"
version="v0.0.7"
[[override]] [[override]]
name="github.com/bifurcation/mint" name="github.com/bifurcation/mint"
revision="824af65410658916142a7600349144e1289f2110" revision="824af65410658916142a7600349144e1289f2110"
...@@ -102,3 +112,7 @@ required = [ ...@@ -102,3 +112,7 @@ required = [
[[constraint]] [[constraint]]
name = "github.com/gorilla/mux" name = "github.com/gorilla/mux"
version = "1.7.0" version = "1.7.0"
[[constraint]]
branch = "master"
name = "github.com/knative/pkg"
...@@ -28,7 +28,7 @@ define ALL_HELP_INFO ...@@ -28,7 +28,7 @@ define ALL_HELP_INFO
# debugging tools like delve. # debugging tools like delve.
endef endef
.PHONY: all .PHONY: all
all: test ks-apiserver ks-apigateway ks-iam all: test ks-apiserver ks-apigateway ks-iam controller-manager
# Build ks-apiserver binary # Build ks-apiserver binary
ks-apiserver: test ks-apiserver: test
...@@ -42,6 +42,10 @@ ks-apigateway: test ...@@ -42,6 +42,10 @@ ks-apigateway: test
ks-iam: test ks-iam: test
hack/gobuild.sh cmd/ks-iam hack/gobuild.sh cmd/ks-iam
# Build controller-manager binary
controller-manager: test
hack/gobuild.sh cmd/controller-manager
# Run go fmt against code # Run go fmt against code
fmt: fmt:
go fmt ./pkg/... ./cmd/... go fmt ./pkg/... ./cmd/...
...@@ -60,7 +64,7 @@ deploy: manifests ...@@ -60,7 +64,7 @@ deploy: manifests
# Generate DeepCopy to implement runtime.Object # Generate DeepCopy to implement runtime.Object
deepcopy: deepcopy:
./vendor/k8s.io/code-generator/generate-groups.sh deepcopy kubesphere.io/kubesphere/pkg/client kubesphere.io/kubesphere/pkg/apis "servicemesh:v1alpha2" ./vendor/k8s.io/code-generator/generate-groups.sh deepcopy,lister,informer,client kubesphere.io/kubesphere/pkg/client kubesphere.io/kubesphere/pkg/apis "servicemesh:v1alpha2"
# Generate code # Generate code
generate: generate:
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Copyright 2018 The KubeSphere Authors. All rights reserved. # Copyright 2018 The KubeSphere Authors. All rights reserved.
# Use of this source code is governed by a Apache license # Use of this source code is governed by a Apache license
# that can be found in the LICENSE file. # that can be found in the LICENSE file.
FROM golang:1.10.3 as controller-manager-builder FROM golang:1.12 as controller-manager-builder
COPY / /go/src/kubesphere.io/kubesphere COPY / /go/src/kubesphere.io/kubesphere
WORKDIR /go/src/kubesphere.io/kubesphere WORKDIR /go/src/kubesphere.io/kubesphere
......
package app
import (
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"kubesphere.io/kubesphere/pkg/controller/destinationrule"
"kubesphere.io/kubesphere/pkg/controller/virtualservice"
"kubesphere.io/kubesphere/pkg/simple/controller/namespace"
"sigs.k8s.io/controller-runtime/pkg/manager"
"time"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
istioclientset "github.com/knative/pkg/client/clientset/versioned"
istioinformers "github.com/knative/pkg/client/informers/externalversions"
servicemeshclientset "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
servicemeshinformers "kubesphere.io/kubesphere/pkg/client/informers/externalversions"
)
const defaultResync = 600 * time.Second
var log = logf.Log.WithName("controller-manager")
func AddControllers(mgr manager.Manager, cfg *rest.Config, stopCh <-chan struct{}) error {
kubeClient, err := kubernetes.NewForConfig(cfg)
if err != nil {
log.Error(err, "building kubernetes client failed")
}
istioclient, err := istioclientset.NewForConfig(cfg)
if err != nil {
log.Error(err, "create istio client failed")
return err
}
informerFactory := informers.NewSharedInformerFactory(kubeClient, defaultResync)
istioInformer := istioinformers.NewSharedInformerFactory(istioclient, defaultResync)
servicemeshclient, err := servicemeshclientset.NewForConfig(cfg)
if err != nil {
log.Error(err, "create servicemesh client failed")
return err
}
servicemeshinformer := servicemeshinformers.NewSharedInformerFactory(servicemeshclient, defaultResync)
vsController := virtualservice.NewVirtualServiceController(informerFactory.Core().V1().Services(),
istioInformer.Networking().V1alpha3().VirtualServices(),
istioInformer.Networking().V1alpha3().DestinationRules(),
servicemeshinformer.Servicemesh().V1alpha2().Strategies(),
kubeClient,
istioclient)
drController := destinationrule.NewDestinationRuleController(informerFactory.Apps().V1().Deployments(),
istioInformer.Networking().V1alpha3().DestinationRules(),
informerFactory.Core().V1().Services(),
servicemeshinformer.Servicemesh().V1alpha2().ServicePolicies(),
kubeClient,
istioclient)
nsController := namespace.NewNamespaceController(kubeClient,
informerFactory.Core().V1().Namespaces(),
informerFactory.Rbac().V1().Roles(),
)
servicemeshinformer.Start(stopCh)
istioInformer.Start(stopCh)
informerFactory.Start(stopCh)
controllers := map[string]manager.Runnable{
"virtualservice-controller": vsController,
"destinationrule-controller": drController,
"namespace-controller": nsController,
}
for name, ctrl := range controllers {
err = mgr.Add(ctrl)
if err != nil {
log.Error(err, "add controller to manager failed", "name", name)
return err
}
}
return nil
}
package app
import (
"fmt"
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog"
"net/http"
"time"
)
// WaitForAPIServer waits for the API Server's /healthz endpoint to report "ok" with timeout.
func WaitForAPIServer(client clientset.Interface, timeout time.Duration) error {
var lastErr error
err := wait.PollImmediate(time.Second, timeout, func() (bool, error) {
healthStatus := 0
result := client.Discovery().RESTClient().Get().AbsPath("/healthz").Do().StatusCode(&healthStatus)
if result.Error() != nil {
lastErr = fmt.Errorf("failed to get apiserver /healthz status: %v", result.Error())
return false, nil
}
if healthStatus != http.StatusOK {
content, _ := result.Raw()
lastErr = fmt.Errorf("APIServer isn't healthy: %v", string(content))
klog.Warningf("APIServer isn't healthy yet: %v. Waiting a little while.", string(content))
return false, nil
}
return true, nil
})
if err != nil {
return fmt.Errorf("%v: %v", err, lastErr)
}
return nil
}
...@@ -20,39 +20,42 @@ package main ...@@ -20,39 +20,42 @@ package main
import ( import (
"flag" "flag"
"k8s.io/client-go/tools/clientcmd"
"kubesphere.io/kubesphere/cmd/controller-manager/app"
"kubesphere.io/kubesphere/pkg/apis"
"kubesphere.io/kubesphere/pkg/controller"
"os" "os"
"sigs.k8s.io/application/pkg/apis/app/v1beta1"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/simple/client/k8s"
"kubesphere.io/kubesphere/pkg/simple/controller/namespace"
"sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/manager"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals" "sigs.k8s.io/controller-runtime/pkg/runtime/signals"
)
"kubesphere.io/kubesphere/pkg/apis" var (
"kubesphere.io/kubesphere/pkg/controller" masterURL string
"kubesphere.io/kubesphere/pkg/webhook" kubeconfig string
metricsAddr string
) )
func main() { func init() {
var metricsAddr string flag.StringVar(&masterURL, "master-url", "", "only need if out of cluster")
flag.StringVar(&kubeconfig, "kubeconfig", "", "only need if out of cluster")
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
}
func main() {
flag.Parse() flag.Parse()
logf.SetLogger(logf.ZapLogger(false)) logf.SetLogger(logf.ZapLogger(false))
log := logf.Log.WithName("entrypoint") log := logf.Log.WithName("controller-manager")
// Get a config to talk to the apiserver cfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
log.Info("setting up client for manager")
cfg, err := k8s.Config()
if err != nil { if err != nil {
log.Error(err, "unable to set up client config") log.Error(err, "failed to build kubeconfig")
os.Exit(1) os.Exit(1)
} }
// Create a new Cmd to provide shared dependencies and start components stopCh := signals.SetupSignalHandler()
log.Info("setting up manager") log.Info("setting up manager")
mgr, err := manager.New(cfg, manager.Options{}) mgr, err := manager.New(cfg, manager.Options{})
if err != nil { if err != nil {
...@@ -60,53 +63,27 @@ func main() { ...@@ -60,53 +63,27 @@ func main() {
os.Exit(1) os.Exit(1)
} }
log.Info("Registering Components.")
// Setup Scheme for all resources
log.Info("setting up scheme") log.Info("setting up scheme")
if err := apis.AddToScheme(mgr.GetScheme()); err != nil { if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
log.Error(err, "unable add APIs to scheme") log.Error(err, "unable add APIs to scheme")
os.Exit(1) os.Exit(1)
} }
log.Info("Print all known types") log.Info("Setting up controllers")
for k, v := range mgr.GetScheme().AllKnownTypes() {
if k.Group == v1beta1.SchemeGroupVersion.Group {
log.Info(k.String() + " / " + v.String())
}
}
// Setup all Controllers
log.Info("Setting up controller")
if err := controller.AddToManager(mgr); err != nil { if err := controller.AddToManager(mgr); err != nil {
log.Error(err, "unable to register controllers to the manager") log.Error(err, "unable to register controllers to the manager")
os.Exit(1) os.Exit(1)
} }
log.Info("setting up webhooks") if err := app.AddControllers(mgr, cfg, stopCh); err != nil {
if err := webhook.AddToManager(mgr); err != nil { log.Error(err, "unable to register controllers to the manager")
log.Error(err, "unable to register webhooks to the manager")
os.Exit(1)
}
err = mgr.Add(manager.RunnableFunc(func(s <-chan struct{}) error {
informerFactory := informers.SharedInformerFactory()
informerFactory.Start(s)
namespace.NewNamespaceController(k8s.Client(),
informerFactory.Core().V1().Namespaces(),
informerFactory.Rbac().V1().Roles()).Start(s)
return nil
}))
if err != nil {
log.Error(err, "error Adding controllers to the Manager")
os.Exit(1) os.Exit(1)
} }
// Start the Cmd
log.Info("Starting the Cmd.") log.Info("Starting the Cmd.")
if err := mgr.Start(signals.SetupSignalHandler()); err != nil { if err := mgr.Start(stopCh); err != nil {
log.Error(err, "unable to run the manager") log.Error(err, "unable to run the manager")
os.Exit(1) os.Exit(1)
} }
} }
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"kubesphere.io/kubesphere/cmd/ks-apiserver/app" "kubesphere.io/kubesphere/cmd/ks-apiserver/app"
"log" "log"
// Install apis // Install apis
_ "kubesphere.io/kubesphere/pkg/apis/logging/install"
_ "kubesphere.io/kubesphere/pkg/apis/metrics/install" _ "kubesphere.io/kubesphere/pkg/apis/metrics/install"
_ "kubesphere.io/kubesphere/pkg/apis/monitoring/install" _ "kubesphere.io/kubesphere/pkg/apis/monitoring/install"
_ "kubesphere.io/kubesphere/pkg/apis/operations/install" _ "kubesphere.io/kubesphere/pkg/apis/operations/install"
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
goflag "flag" goflag "flag"
"fmt" "fmt"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/json-iterator/go"
kconfig "github.com/kiali/kiali/config" kconfig "github.com/kiali/kiali/config"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
...@@ -28,12 +29,14 @@ import ( ...@@ -28,12 +29,14 @@ import (
"kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/filter" "kubesphere.io/kubesphere/pkg/filter"
"kubesphere.io/kubesphere/pkg/informers" "kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/applications" logging "kubesphere.io/kubesphere/pkg/models/log"
"kubesphere.io/kubesphere/pkg/signals" "kubesphere.io/kubesphere/pkg/signals"
"log" "log"
"net/http" "net/http"
) )
var jsonIter = jsoniter.ConfigCompatibleWithStandardLibrary
func NewAPIServerCommand() *cobra.Command { func NewAPIServerCommand() *cobra.Command {
s := options.NewServerRunOptions() s := options.NewServerRunOptions()
...@@ -60,9 +63,6 @@ func Run(s *options.ServerRunOptions) error { ...@@ -60,9 +63,6 @@ func Run(s *options.ServerRunOptions) error {
log.Printf("FLAG: --%s=%q", flag.Name, flag.Value) log.Printf("FLAG: --%s=%q", flag.Name, flag.Value)
}) })
applications.OpenPitrixServer = s.OpenPitrixServer
applications.OpenPitrixProxyToken = s.OpenPitrixProxyToken
var err error var err error
waitForResourceSync() waitForResourceSync()
...@@ -78,6 +78,7 @@ func Run(s *options.ServerRunOptions) error { ...@@ -78,6 +78,7 @@ func Run(s *options.ServerRunOptions) error {
} }
} }
initializeESClientConfig()
initializeKialiConfig(s) initializeKialiConfig(s)
if s.GenericServerRunOptions.InsecurePort != 0 { if s.GenericServerRunOptions.InsecurePort != 0 {
...@@ -110,6 +111,24 @@ func initializeKialiConfig(s *options.ServerRunOptions) { ...@@ -110,6 +111,24 @@ func initializeKialiConfig(s *options.ServerRunOptions) {
kconfig.Set(config) kconfig.Set(config)
} }
func initializeESClientConfig() {
// List all outputs
outputs,err := logging.GetFluentbitOutputFromConfigMap()
if err != nil {
glog.Errorln(err)
return
}
// Iterate the outputs to get elasticsearch configs
for _, output := range outputs {
if configs := logging.ParseEsOutputParams(output.Parameters); configs != nil {
configs.WriteESConfigs()
return
}
}
}
func waitForResourceSync() { func waitForResourceSync() {
stopChan := signals.SetupSignalHandler() stopChan := signals.SetupSignalHandler()
...@@ -134,12 +153,19 @@ func waitForResourceSync() { ...@@ -134,12 +153,19 @@ func waitForResourceSync() {
informerFactory.Apps().V1().StatefulSets().Lister() informerFactory.Apps().V1().StatefulSets().Lister()
informerFactory.Apps().V1().Deployments().Lister() informerFactory.Apps().V1().Deployments().Lister()
informerFactory.Apps().V1().DaemonSets().Lister() informerFactory.Apps().V1().DaemonSets().Lister()
informerFactory.Apps().V1().ReplicaSets().Lister()
informerFactory.Batch().V1().Jobs().Lister() informerFactory.Batch().V1().Jobs().Lister()
informerFactory.Batch().V1beta1().CronJobs().Lister() informerFactory.Batch().V1beta1().CronJobs().Lister()
informerFactory.Start(stopChan) informerFactory.Start(stopChan)
informerFactory.WaitForCacheSync(stopChan) informerFactory.WaitForCacheSync(stopChan)
s2iInformerFactory := informers.S2iSharedInformerFactory()
s2iInformerFactory.Devops().V1alpha1().S2iBuilderTemplates().Lister()
s2iInformerFactory.Devops().V1alpha1().S2iRuns().Lister()
s2iInformerFactory.Devops().V1alpha1().S2iBuilders().Lister()
s2iInformerFactory.Start(stopChan)
s2iInformerFactory.WaitForCacheSync(stopChan)
log.Println("resources sync success") log.Println("resources sync success")
} }
此差异已折叠。
...@@ -6,6 +6,23 @@ metadata: ...@@ -6,6 +6,23 @@ metadata:
controller-tools.k8s.io: "1.0" controller-tools.k8s.io: "1.0"
name: strategies.servicemesh.kubesphere.io name: strategies.servicemesh.kubesphere.io
spec: spec:
additionalPrinterColumns:
- JSONPath: .spec.type
description: type of strategy
name: Type
type: string
- JSONPath: .spec.template.spec.hosts
description: destination hosts
name: Hosts
type: string
- JSONPath: .metadata.creationTimestamp
description: 'CreationTimestamp is a timestamp representing the server time when
this object was created. It is not guaranteed to be set in happens-before order
across separate operations. Clients may not set this value. It is represented
in RFC3339 form and is in UTC. Populated by the system. Read-only. Null for
lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
name: Age
type: date
group: servicemesh.kubesphere.io group: servicemesh.kubesphere.io
names: names:
kind: Strategy kind: Strategy
...@@ -28,10 +45,18 @@ spec: ...@@ -28,10 +45,18 @@ spec:
type: object type: object
spec: spec:
properties: properties:
governor:
description: Governor version, the version takes control of all incoming
traffic label version value
type: string
paused: paused:
description: Indicates that the strategy is paused and will not be processed description: Indicates that the strategy is paused and will not be processed
by the strategy controller by the strategy controller
type: boolean type: boolean
principal:
description: Principal version, the one as reference version label version
value
type: string
selector: selector:
description: Label selector for virtual services. description: Label selector for virtual services.
type: object type: object
......
apiVersion: servicemesh.kubesphere.io/v1alpha2
kind: ServicePolicy
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: servicepolicy-sample
spec:
# Add fields here
foo: bar
...@@ -12,6 +12,8 @@ spec: ...@@ -12,6 +12,8 @@ spec:
"servicemesh.kubesphere.io/type": "canary" "servicemesh.kubesphere.io/type": "canary"
template: template:
spec: spec:
service: "details"
principal: "v1"
hosts: hosts:
- details - details
http: http:
......
...@@ -2,4 +2,6 @@ ...@@ -2,4 +2,6 @@
docker build -f build/ks-apigateway/Dockerfile -t kubespheredev/ks-apigateway:latest . docker build -f build/ks-apigateway/Dockerfile -t kubespheredev/ks-apigateway:latest .
docker build -f build/ks-apiserver/Dockerfile -t kubespheredev/ks-apiserver:latest . docker build -f build/ks-apiserver/Dockerfile -t kubespheredev/ks-apiserver:latest .
docker build -f build/ks-iam/Dockerfile -t kubespheredev/ks-iam:latest . docker build -f build/ks-iam/Dockerfile -t kubespheredev/ks-iam:latest .
\ No newline at end of file
docker build -f build/controller-manager/Dockerfile -t kubespheredev/ks-controller-manager:latest .
...@@ -6,3 +6,4 @@ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ...@@ -6,3 +6,4 @@ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push kubespheredev/ks-apigateway:latest docker push kubespheredev/ks-apigateway:latest
docker push kubespheredev/ks-apiserver:latest docker push kubespheredev/ks-apiserver:latest
docker push kubespheredev/ks-iam:latest docker push kubespheredev/ks-iam:latest
docker push kubespheredev/ks-controller-manager:latest
...@@ -45,15 +45,7 @@ esac ...@@ -45,15 +45,7 @@ esac
command_exists curl command_exists curl
command_exists tar command_exists tar
if [ "x${KUBEBUILDER_VERSION}" = "x" ] ; then KUBEBUILDER_VERSION=v1.0.8
KUBEBUILDER_VERSION=$(curl -L -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | \
grep tag_name | sed "s/ *\"tag_name\": *\"\\(.*\\)\",*/\\1/")
if [ -z "$KUBEBUILDER_VERSION" ]; then
echo "\nUnable to fetch the latest version tag. This may be due to network access problem"
exit 0
fi
fi
KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION#"v"} KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION#"v"}
KUBEBUILDER_VERSION_NAME="kubebuilder_${KUBEBUILDER_VERSION}" KUBEBUILDER_VERSION_NAME="kubebuilder_${KUBEBUILDER_VERSION}"
KUBEBUILDER_DIR=/usr/local/kubebuilder KUBEBUILDER_DIR=/usr/local/kubebuilder
......
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
"github.com/knative/pkg/apis/istio/v1alpha3" "github.com/knative/pkg/apis/istio/v1alpha3"
"kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2" "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
"sigs.k8s.io/application/pkg/apis/app/v1beta1" "github.com/kubernetes-sigs/application/pkg/apis/app/v1beta1"
) )
func init() { func init() {
......
/*
Copyright 2019 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package install
import (
"github.com/emicklei/go-restful"
urlruntime "k8s.io/apimachinery/pkg/util/runtime"
loggingv1alpha2 "kubesphere.io/kubesphere/pkg/apis/logging/v1alpha2"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
)
func init() {
Install(runtime.Container)
}
func Install(container *restful.Container) {
urlruntime.Must(loggingv1alpha2.AddToContainer(container))
}
/*
Copyright 2019 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha2
import (
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/apiserver/logging"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/filter"
)
const GroupName = "logging.kubesphere.io"
var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
var (
WebServiceBuilder = runtime.NewContainerBuilder(addWebService)
AddToContainer = WebServiceBuilder.AddToContainer
)
func addWebService(c *restful.Container) error {
ws := runtime.NewWebService(GroupVersion)
tags := []string{"Logging"}
ws.Route(ws.GET("/cluster").To(logging.LoggingQueryCluster).
Filter(filter.Logging).
Doc("cluster level log query").
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
Param(ws.QueryParameter("workspaces", "workspaces specify").DataType("string").Required(false)).
Param(ws.QueryParameter("workspace_query", "workspace query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("namespaces", "namespaces specify").DataType("string").Required(false)).
Param(ws.QueryParameter("namespace_query", "namespace query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)).
Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)).
Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.GET("/workspaces/{workspace}").To(logging.LoggingQueryWorkspace).
Filter(filter.Logging).
Doc("workspace level log query").
Param(ws.PathParameter("workspace", "workspace specify").DataType("string").Required(true)).
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
Param(ws.QueryParameter("namespaces", "namespaces specify").DataType("string").Required(false)).
Param(ws.QueryParameter("namespace_query", "namespace query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)).
Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)).
Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.GET("/namespaces/{namespace}").To(logging.LoggingQueryNamespace).
Filter(filter.Logging).
Doc("namespace level log query").
Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)).
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)).
Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)).
Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload}").To(logging.LoggingQueryWorkload).
Filter(filter.Logging).
Doc("workload level log query").
Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)).
Param(ws.PathParameter("workload", "workload specify").DataType("string").Required(true)).
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)).
Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}").To(logging.LoggingQueryPod).
Filter(filter.Logging).
Doc("pod level log query").
Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)).
Param(ws.PathParameter("pod", "pod specify").DataType("string").Required(true)).
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers/{container}").To(logging.LoggingQueryContainer).
Filter(filter.Logging).
Doc("container level log query").
Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)).
Param(ws.PathParameter("pod", "pod specify").DataType("string").Required(true)).
Param(ws.PathParameter("container", "container specify").DataType("string").Required(true)).
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.GET("/fluentbit/filters").To(logging.LoggingQueryFluentbitFilters).
Filter(filter.Logging).
Doc("log fluent-bit filters query").
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.POST("/fluentbit/filters").To(logging.LoggingUpdateFluentbitFilters).
Filter(filter.Logging).
Doc("log fluent-bit filters update").
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.GET("/fluentbit/outputs").To(logging.LoggingQueryFluentbitOutputs).
Filter(filter.Logging).
Doc("log fluent-bit outputs query").
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.POST("/fluentbit/outputs").To(logging.LoggingInsertFluentbitOutput).
Filter(filter.Logging).
Doc("log fluent-bit outputs insert").
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.POST("/fluentbit/outputs/{output}").To(logging.LoggingUpdateFluentbitOutput).
Filter(filter.Logging).
Doc("log fluent-bit outputs update").
Param(ws.PathParameter("output", "output id").DataType("int").Required(true)).
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
ws.Route(ws.DELETE("/fluentbit/outputs/{output}").To(logging.LoggingDeleteFluentbitOutput).
Filter(filter.Logging).
Doc("log fluent-bit outputs delete").
Param(ws.PathParameter("output", "output id").DataType("int").Required(true)).
Metadata(restfulspec.KeyOpenAPITags, tags)).
Consumes(restful.MIME_JSON, restful.MIME_XML).
Produces(restful.MIME_JSON)
c.Add(ws)
return nil
}
\ No newline at end of file
...@@ -68,8 +68,8 @@ func addWebService(c *restful.Container) error { ...@@ -68,8 +68,8 @@ func addWebService(c *restful.Container) error {
To(metrics.GetWorkloadMetrics). To(metrics.GetWorkloadMetrics).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get workload metrics from a specific namespace"). Doc("Get workload metrics from a specific namespace").
Param(webservice.PathParameter("namespace", "name of the namespace")). Param(webservice.PathParameter("namespace", "name of the namespace").Required(true)).
Param(webservice.PathParameter("workload", "name of the workload")). Param(webservice.PathParameter("workload", "name of the workload").Required(true)).
Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")). Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")).
Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")). Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")).
Param(webservice.QueryParameter("duration", "metrics duration, in seconds")). Param(webservice.QueryParameter("duration", "metrics duration, in seconds")).
...@@ -87,7 +87,7 @@ func addWebService(c *restful.Container) error { ...@@ -87,7 +87,7 @@ func addWebService(c *restful.Container) error {
To(metrics.GetNamespaceMetrics). To(metrics.GetNamespaceMetrics).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get workload metrics from a specific namespace"). Doc("Get workload metrics from a specific namespace").
Param(webservice.PathParameter("namespace", "name of the namespace")). Param(webservice.PathParameter("namespace", "name of the namespace").Required(true)).
Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")). Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")).
Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")). Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")).
Param(webservice.QueryParameter("duration", "metrics duration, in seconds")). Param(webservice.QueryParameter("duration", "metrics duration, in seconds")).
...@@ -105,7 +105,7 @@ func addWebService(c *restful.Container) error { ...@@ -105,7 +105,7 @@ func addWebService(c *restful.Container) error {
To(metrics.GetNamespaceGraph). To(metrics.GetNamespaceGraph).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get service graph for a specific namespace"). Doc("Get service graph for a specific namespace").
Param(webservice.PathParameter("namespace", "name of a namespace")). Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
Param(webservice.QueryParameter("graphType", "type of the generated service graph, eg. ")). Param(webservice.QueryParameter("graphType", "type of the generated service graph, eg. ")).
Param(webservice.QueryParameter("groupBy", "group nodes by kind")). Param(webservice.QueryParameter("groupBy", "group nodes by kind")).
Param(webservice.QueryParameter("queryTime", "from which time point, default now")). Param(webservice.QueryParameter("queryTime", "from which time point, default now")).
...@@ -118,7 +118,7 @@ func addWebService(c *restful.Container) error { ...@@ -118,7 +118,7 @@ func addWebService(c *restful.Container) error {
To(metrics.GetNamespacesGraph). To(metrics.GetNamespacesGraph).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get service graph for a specific namespace"). Doc("Get service graph for a specific namespace").
Param(webservice.PathParameter("namespace", "name of a namespace")). Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
Param(webservice.QueryParameter("graphType", "type of the generated service graph, eg. ")). Param(webservice.QueryParameter("graphType", "type of the generated service graph, eg. ")).
Param(webservice.QueryParameter("groupBy", "group nodes by kind")). Param(webservice.QueryParameter("groupBy", "group nodes by kind")).
Param(webservice.QueryParameter("queryTime", "from which time point, default now")). Param(webservice.QueryParameter("queryTime", "from which time point, default now")).
...@@ -126,6 +126,50 @@ func addWebService(c *restful.Container) error { ...@@ -126,6 +126,50 @@ func addWebService(c *restful.Container) error {
Param(webservice.QueryParameter("namespaces", "names of namespaces")). Param(webservice.QueryParameter("namespaces", "names of namespaces")).
Writes(errors.Error{})).Produces(restful.MIME_JSON) Writes(errors.Error{})).Produces(restful.MIME_JSON)
// Get namespace health
webservice.Route(webservice.GET("/namespaces/{namespace}/health").
To(metrics.GetNamespaceHealth).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get workload health").
Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
Param(webservice.PathParameter("type", "the type of health, app/service/workload, default app").DefaultValue("app")).
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
Writes(errors.Error{})).Produces(restful.MIME_JSON)
// Get workloads health
webservice.Route(webservice.GET("/namespaces/{namespace}/workloads/{workload}/health").
To(metrics.GetWorkloadHealth).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get workload health").
Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
Param(webservice.PathParameter("workload", "workload name").Required(true)).
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
Writes(errors.Error{})).Produces(restful.MIME_JSON)
// Get app health
webservice.Route(webservice.GET("/namespaces/{namespace}/apps/{app}/health").
To(metrics.GetAppHealth).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get workload health").
Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
Param(webservice.PathParameter("app", "app name").Required(true)).
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
Writes(errors.Error{})).Produces(restful.MIME_JSON)
// Get service health
webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/health").
To(metrics.GetServiceHealth).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get workload health").
Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
Param(webservice.PathParameter("service", "service name").Required(true)).
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
Writes(errors.Error{})).Produces(restful.MIME_JSON)
c.Add(webservice) c.Add(webservice)
return nil return nil
......
/*
Copyright 2019 The KubeSphere authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha2
import (
"github.com/knative/pkg/apis/istio/v1alpha3"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// ServicePolicySpec defines the desired state of ServicePolicy
type ServicePolicySpec struct {
// Label selector for destination rules.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"`
// Template used to create a destination rule
// +optional
Template DestinationRuleSpecTemplate `json:"template,omitempty"`
}
type DestinationRuleSpecTemplate struct {
// Metadata of the virtual services created from this template
// +optional
metav1.ObjectMeta
// Spec indicates the behavior of a destination rule.
// +optional
Spec v1alpha3.DestinationRuleSpec `json:"spec,omitempty"`
}
type ServicePolicyConditionType string
// These are valid conditions of a strategy.
const (
// StrategyComplete means the strategy has been delivered to istio.
ServicePolicyComplete ServicePolicyConditionType = "Complete"
// StrategyFailed means the strategy has failed its delivery to istio.
ServicePolicyFailed ServicePolicyConditionType = "Failed"
)
// StrategyCondition describes current state of a strategy.
type ServicePolicyCondition struct {
// Type of strategy condition, Complete or Failed.
Type ServicePolicyConditionType
// Status of the condition, one of True, False, Unknown
Status apiextensions.ConditionStatus
// Last time the condition was checked.
// +optional
LastProbeTime metav1.Time
// Last time the condition transit from one status to another
// +optional
LastTransitionTime metav1.Time
// reason for the condition's last transition
Reason string
// Human readable message indicating details about last transition.
// +optinal
Message string
}
// ServicePolicyStatus defines the observed state of ServicePolicy
type ServicePolicyStatus struct {
// The latest available observations of an object's current state.
// +optional
Conditions []ServicePolicyCondition
// Represents time when the strategy was acknowledged by the controller.
// It is represented in RFC3339 form and is in UTC.
// +optional
StartTime *metav1.Time
// Represents time when the strategy was completed.
// It is represented in RFC3339 form and is in UTC.
// +optional
CompletionTime *metav1.Time
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ServicePolicy is the Schema for the servicepolicies API
// +k8s:openapi-gen=true
type ServicePolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ServicePolicySpec `json:"spec,omitempty"`
Status ServicePolicyStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ServicePolicyList contains a list of ServicePolicy
type ServicePolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ServicePolicy `json:"items"`
}
func init() {
SchemeBuilder.Register(&ServicePolicy{}, &ServicePolicyList{})
}
/*
Copyright 2019 The KubeSphere authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha2
import (
"testing"
"github.com/onsi/gomega"
"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)
func TestStorageServicePolicy(t *testing.T) {
key := types.NamespacedName{
Name: "foo",
Namespace: "default",
}
created := &ServicePolicy{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
}}
g := gomega.NewGomegaWithT(t)
// Test Create
fetched := &ServicePolicy{}
g.Expect(c.Create(context.TODO(), created)).NotTo(gomega.HaveOccurred())
g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred())
g.Expect(fetched).To(gomega.Equal(created))
// Test Updating the Labels
updated := fetched.DeepCopy()
updated.Labels = map[string]string{"hello": "world"}
g.Expect(c.Update(context.TODO(), updated)).NotTo(gomega.HaveOccurred())
g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred())
g.Expect(fetched).To(gomega.Equal(updated))
// Test Delete
g.Expect(c.Delete(context.TODO(), fetched)).NotTo(gomega.HaveOccurred())
g.Expect(c.Get(context.TODO(), key, fetched)).To(gomega.HaveOccurred())
}
...@@ -45,6 +45,16 @@ type StrategySpec struct { ...@@ -45,6 +45,16 @@ type StrategySpec struct {
// Strategy type // Strategy type
Type StrategyType `json:"type,omitempty"` Type StrategyType `json:"type,omitempty"`
// Principal version, the one as reference version
// label version value
// +optional
PrincipalVersion string `json:"principal,omitempty"`
// Governor version, the version takes control of all incoming traffic
// label version value
// +optional
GovernorVersion string `json:"governor,omitempty"`
// Label selector for virtual services. // Label selector for virtual services.
// +optional // +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"` Selector *metav1.LabelSelector `json:"selector,omitempty"`
...@@ -128,6 +138,9 @@ type StrategyCondition struct { ...@@ -128,6 +138,9 @@ type StrategyCondition struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Strategy is the Schema for the strategies API // Strategy is the Schema for the strategies API
// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type",description="type of strategy"
// +kubebuilder:printcolumn:name="Hosts",type="string",JSONPath=".spec.template.spec.hosts",description="destination hosts"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata"
// +k8s:openapi-gen=true // +k8s:openapi-gen=true
type Strategy struct { type Strategy struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
......
...@@ -25,6 +25,156 @@ import ( ...@@ -25,6 +25,156 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
) )
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DestinationRuleSpecTemplate) DeepCopyInto(out *DestinationRuleSpecTemplate) {
*out = *in
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DestinationRuleSpecTemplate.
func (in *DestinationRuleSpecTemplate) DeepCopy() *DestinationRuleSpecTemplate {
if in == nil {
return nil
}
out := new(DestinationRuleSpecTemplate)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServicePolicy) DeepCopyInto(out *ServicePolicy) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServicePolicy.
func (in *ServicePolicy) DeepCopy() *ServicePolicy {
if in == nil {
return nil
}
out := new(ServicePolicy)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ServicePolicy) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServicePolicyCondition) DeepCopyInto(out *ServicePolicyCondition) {
*out = *in
in.LastProbeTime.DeepCopyInto(&out.LastProbeTime)
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServicePolicyCondition.
func (in *ServicePolicyCondition) DeepCopy() *ServicePolicyCondition {
if in == nil {
return nil
}
out := new(ServicePolicyCondition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServicePolicyList) DeepCopyInto(out *ServicePolicyList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ServicePolicy, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServicePolicyList.
func (in *ServicePolicyList) DeepCopy() *ServicePolicyList {
if in == nil {
return nil
}
out := new(ServicePolicyList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ServicePolicyList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServicePolicySpec) DeepCopyInto(out *ServicePolicySpec) {
*out = *in
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
in.Template.DeepCopyInto(&out.Template)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServicePolicySpec.
func (in *ServicePolicySpec) DeepCopy() *ServicePolicySpec {
if in == nil {
return nil
}
out := new(ServicePolicySpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServicePolicyStatus) DeepCopyInto(out *ServicePolicyStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]ServicePolicyCondition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.StartTime != nil {
in, out := &in.StartTime, &out.StartTime
*out = (*in).DeepCopy()
}
if in.CompletionTime != nil {
in, out := &in.CompletionTime, &out.CompletionTime
*out = (*in).DeepCopy()
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServicePolicyStatus.
func (in *ServicePolicyStatus) DeepCopy() *ServicePolicyStatus {
if in == nil {
return nil
}
out := new(ServicePolicyStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Strategy) DeepCopyInto(out *Strategy) { func (in *Strategy) DeepCopyInto(out *Strategy) {
*out = *in *out = *in
......
/*
Copyright 2019 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package logging
import (
"github.com/emicklei/go-restful"
"github.com/golang/glog"
"kubesphere.io/kubesphere/pkg/models/log"
es "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch"
fb "kubesphere.io/kubesphere/pkg/simple/client/fluentbit"
"net/http"
"strconv"
)
func LoggingQueryCluster(request *restful.Request, response *restful.Response) {
res := logQuery(log.QueryLevelCluster, request)
response.WriteAsJson(res)
}
func LoggingQueryWorkspace(request *restful.Request, response *restful.Response) {
res := logQuery(log.QueryLevelWorkspace, request)
response.WriteAsJson(res)
}
func LoggingQueryNamespace(request *restful.Request, response *restful.Response) {
res := logQuery(log.QueryLevelNamespace, request)
response.WriteAsJson(res)
}
func LoggingQueryWorkload(request *restful.Request, response *restful.Response) {
res := logQuery(log.QueryLevelWorkload, request)
response.WriteAsJson(res)
}
func LoggingQueryPod(request *restful.Request, response *restful.Response) {
res := logQuery(log.QueryLevelPod, request)
response.WriteAsJson(res)
}
func LoggingQueryContainer(request *restful.Request, response *restful.Response) {
res := logQuery(log.QueryLevelContainer, request)
response.WriteAsJson(res)
}
func LoggingQueryFluentbitFilters(request *restful.Request, response *restful.Response) {
res := log.FluentbitFiltersQuery()
response.WriteAsJson(res)
}
func LoggingUpdateFluentbitFilters(request *restful.Request, response *restful.Response) {
var res *log.FluentbitFiltersResult
filters := new([]log.FluentbitFilter)
err := request.ReadEntity(&filters)
if err != nil {
res = &log.FluentbitFiltersResult{Status: http.StatusBadRequest}
} else {
res = log.FluentbitFiltersUpdate(filters)
}
response.WriteAsJson(res)
}
func LoggingQueryFluentbitOutputs(request *restful.Request, response *restful.Response) {
res := log.FluentbitOutputsQuery()
response.WriteAsJson(res)
}
func LoggingInsertFluentbitOutput(request *restful.Request, response *restful.Response) {
var output fb.OutputPlugin
var res *log.FluentbitOutputsResult
err := request.ReadEntity(&output)
if err != nil {
glog.Errorln(err)
res = &log.FluentbitOutputsResult{Status: http.StatusBadRequest}
} else {
res = log.FluentbitOutputInsert(output)
}
response.WriteAsJson(res)
}
func LoggingUpdateFluentbitOutput(request *restful.Request, response *restful.Response) {
var output fb.OutputPlugin
id := request.PathParameter("output")
err := request.ReadEntity(&output)
if err != nil {
glog.Errorln(err)
res := &log.FluentbitOutputsResult{Status: http.StatusBadRequest}
response.WriteAsJson(res)
return
}
res := log.FluentbitOutputUpdate(output, id)
response.WriteAsJson(res)
}
func LoggingDeleteFluentbitOutput(request *restful.Request, response *restful.Response) {
var res *log.FluentbitOutputsResult
id := request.PathParameter("output")
res = log.FluentbitOutputDelete(id)
response.WriteAsJson(res)
}
func logQuery(level log.LogQueryLevel, request *restful.Request) *es.QueryResult {
var param es.QueryParameters
param.Operation = request.QueryParameter("operation")
switch level {
case log.QueryLevelCluster:
{
param.NamespaceFilled, param.Namespaces = log.QueryWorkspace(request.QueryParameter("workspaces"), request.QueryParameter("workspace_query"))
param.NamespaceFilled, param.Namespaces = log.MatchNamespace(request.QueryParameter("namespaces"), param.NamespaceFilled, param.Namespaces)
param.NamespaceQuery = request.QueryParameter("namespace_query")
param.PodFilled, param.Pods = log.QueryWorkload(request.QueryParameter("workloads"), request.QueryParameter("workload_query"), param.Namespaces)
param.PodFilled, param.Pods = log.MatchPod(request.QueryParameter("pods"), param.PodFilled, param.Pods)
param.PodQuery = request.QueryParameter("pod_query")
param.ContainerFilled, param.Containers = log.MatchContainer(request.QueryParameter("containers"))
param.ContainerQuery = request.QueryParameter("container_query")
}
case log.QueryLevelWorkspace:
{
param.NamespaceFilled, param.Namespaces = log.QueryWorkspace(request.PathParameter("workspace"), "")
param.NamespaceFilled, param.Namespaces = log.MatchNamespace(request.QueryParameter("namespaces"), param.NamespaceFilled, param.Namespaces)
param.NamespaceQuery = request.QueryParameter("namespace_query")
param.PodFilled, param.Pods = log.QueryWorkload(request.QueryParameter("workloads"), request.QueryParameter("workload_query"), param.Namespaces)
param.PodFilled, param.Pods = log.MatchPod(request.QueryParameter("pods"), param.PodFilled, param.Pods)
param.PodQuery = request.QueryParameter("pod_query")
param.ContainerFilled, param.Containers = log.MatchContainer(request.QueryParameter("containers"))
param.ContainerQuery = request.QueryParameter("container_query")
}
case log.QueryLevelNamespace:
{
param.NamespaceFilled, param.Namespaces = log.MatchNamespace(request.PathParameter("namespace"), false, nil)
param.PodFilled, param.Pods = log.QueryWorkload(request.QueryParameter("workloads"), request.QueryParameter("workload_query"), param.Namespaces)
param.PodFilled, param.Pods = log.MatchPod(request.QueryParameter("pods"), param.PodFilled, param.Pods)
param.PodQuery = request.QueryParameter("pod_query")
param.ContainerFilled, param.Containers = log.MatchContainer(request.QueryParameter("containers"))
param.ContainerQuery = request.QueryParameter("container_query")
}
case log.QueryLevelWorkload:
{
param.NamespaceFilled, param.Namespaces = log.MatchNamespace(request.PathParameter("namespace"), false, nil)
param.PodFilled, param.Pods = log.QueryWorkload(request.PathParameter("workload"), "", param.Namespaces)
param.PodFilled, param.Pods = log.MatchPod(request.QueryParameter("pods"), param.PodFilled, param.Pods)
param.PodQuery = request.QueryParameter("pod_query")
param.ContainerFilled, param.Containers = log.MatchContainer(request.QueryParameter("containers"))
param.ContainerQuery = request.QueryParameter("container_query")
}
case log.QueryLevelPod:
{
param.NamespaceFilled, param.Namespaces = log.MatchNamespace(request.PathParameter("namespace"), false, nil)
param.PodFilled, param.Pods = log.MatchPod(request.PathParameter("pod"), false, nil)
param.ContainerFilled, param.Containers = log.MatchContainer(request.QueryParameter("containers"))
param.ContainerQuery = request.QueryParameter("container_query")
}
case log.QueryLevelContainer:
{
param.NamespaceFilled, param.Namespaces = log.MatchNamespace(request.PathParameter("namespace"), false, nil)
param.PodFilled, param.Pods = log.MatchPod(request.PathParameter("pod"), false, nil)
param.ContainerFilled, param.Containers = log.MatchContainer(request.PathParameter("container"))
}
}
if len(param.Namespaces) == 1 {
param.Workspace = log.GetWorkspaceOfNamesapce(param.Namespaces[0])
}
param.Interval = request.QueryParameter("interval")
param.LogQuery = request.QueryParameter("log_query")
param.StartTime = request.QueryParameter("start_time")
param.EndTime = request.QueryParameter("end_time")
param.Sort = request.QueryParameter("sort")
var err error
param.From, err = strconv.ParseInt(request.QueryParameter("from"), 10, 64)
if err != nil {
param.From = 0
}
param.Size, err = strconv.ParseInt(request.QueryParameter("size"), 10, 64)
if err != nil {
param.Size = 10
}
glog.Infof("LogQuery with %v", param)
return es.Query(param)
}
...@@ -20,11 +20,11 @@ package monitoring ...@@ -20,11 +20,11 @@ package monitoring
import ( import (
"github.com/emicklei/go-restful" "github.com/emicklei/go-restful"
"kubesphere.io/kubesphere/pkg/models/metrics" "kubesphere.io/kubesphere/pkg/models/metrics"
"kubesphere.io/kubesphere/pkg/simple/client/prometheus" prom "kubesphere.io/kubesphere/pkg/simple/client/prometheus"
) )
func MonitorPod(request *restful.Request, response *restful.Response) { func MonitorPod(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request) requestParams := prom.ParseMonitoringRequestParams(request)
podName := requestParams.PodName podName := requestParams.PodName
metricName := requestParams.MetricsName metricName := requestParams.MetricsName
if podName != "" { if podName != "" {
...@@ -32,7 +32,8 @@ func MonitorPod(request *restful.Request, response *restful.Response) { ...@@ -32,7 +32,8 @@ func MonitorPod(request *restful.Request, response *restful.Response) {
queryType, params, nullRule := metrics.AssemblePodMetricRequestInfo(requestParams, metricName) queryType, params, nullRule := metrics.AssemblePodMetricRequestInfo(requestParams, metricName)
var res *metrics.FormatedMetric var res *metrics.FormatedMetric
if !nullRule { if !nullRule {
res = metrics.GetMetric(queryType, params, metricName) metricsStr := prom.SendMonitoringRequest(queryType, params)
res = metrics.ReformatJson(metricsStr, metricName, map[string]string{"pod_name": ""})
} }
response.WriteAsJson(res) response.WriteAsJson(res)
...@@ -40,21 +41,20 @@ func MonitorPod(request *restful.Request, response *restful.Response) { ...@@ -40,21 +41,20 @@ func MonitorPod(request *restful.Request, response *restful.Response) {
// multiple // multiple
rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelPod) rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelPod)
// sorting // sorting
sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics, metrics.MetricLevelPodName) sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics)
// paging // paging
pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount) pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount)
response.WriteAsJson(pagedMetrics) response.WriteAsJson(pagedMetrics)
} }
} }
func MonitorContainer(request *restful.Request, response *restful.Response) { func MonitorContainer(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request) requestParams := prom.ParseMonitoringRequestParams(request)
metricName := requestParams.MetricsName metricName := requestParams.MetricsName
if requestParams.MetricsFilter != "" { if requestParams.MetricsFilter != "" {
rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelContainer) rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelContainer)
// sorting // sorting
sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics, metrics.MetricLevelContainerName) sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics)
// paging // paging
pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount) pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount)
...@@ -68,7 +68,7 @@ func MonitorContainer(request *restful.Request, response *restful.Response) { ...@@ -68,7 +68,7 @@ func MonitorContainer(request *restful.Request, response *restful.Response) {
} }
func MonitorWorkload(request *restful.Request, response *restful.Response) { func MonitorWorkload(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request) requestParams := prom.ParseMonitoringRequestParams(request)
rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelWorkload) rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelWorkload)
...@@ -80,10 +80,10 @@ func MonitorWorkload(request *restful.Request, response *restful.Response) { ...@@ -80,10 +80,10 @@ func MonitorWorkload(request *restful.Request, response *restful.Response) {
// sorting // sorting
if wlKind == "" { if wlKind == "" {
sortedMetrics, maxMetricCount = metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics, metrics.MetricLevelWorkload) sortedMetrics, maxMetricCount = metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics)
} else { } else {
sortedMetrics, maxMetricCount = metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics, metrics.MetricLevelPodName) sortedMetrics, maxMetricCount = metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics)
} }
// paging // paging
...@@ -95,19 +95,18 @@ func MonitorWorkload(request *restful.Request, response *restful.Response) { ...@@ -95,19 +95,18 @@ func MonitorWorkload(request *restful.Request, response *restful.Response) {
func MonitorAllWorkspaces(request *restful.Request, response *restful.Response) { func MonitorAllWorkspaces(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request) requestParams := prom.ParseMonitoringRequestParams(request)
tp := requestParams.Tp tp := requestParams.Tp
if tp == "_statistics" { if tp == "statistics" {
// merge multiple metric: all-devops, all-roles, all-projects...this api is designed for admin // merge multiple metric: all-devops, all-roles, all-projects...this api is designed for admin
res := metrics.MonitorAllWorkspacesStatistics() res := metrics.MonitorAllWorkspacesStatistics()
response.WriteAsJson(res) response.WriteAsJson(res)
} else if tp == "rank" { } else if tp == "rank" {
rawMetrics := metrics.MonitorAllWorkspaces(requestParams) rawMetrics := metrics.MonitorAllWorkspaces(requestParams)
// sorting // sorting
sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics, metrics.MetricLevelWorkspace) sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics)
// paging // paging
pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount) pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount)
...@@ -119,20 +118,19 @@ func MonitorAllWorkspaces(request *restful.Request, response *restful.Response) ...@@ -119,20 +118,19 @@ func MonitorAllWorkspaces(request *restful.Request, response *restful.Response)
} }
func MonitorOneWorkspace(request *restful.Request, response *restful.Response) { func MonitorOneWorkspace(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request) requestParams := prom.ParseMonitoringRequestParams(request)
tp := requestParams.Tp tp := requestParams.Tp
if tp == "rank" { if tp == "rank" {
// multiple // multiple
rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelWorkspace) rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelWorkspace)
// sorting // sorting
sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics, metrics.MetricLevelNamespace) sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics)
// paging // paging
pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount) pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount)
response.WriteAsJson(pagedMetrics) response.WriteAsJson(pagedMetrics)
} else if tp == "_statistics" { } else if tp == "statistics" {
wsName := requestParams.WsName wsName := requestParams.WsName
// merge multiple metric: devops, roles, projects... // merge multiple metric: devops, roles, projects...
...@@ -145,34 +143,35 @@ func MonitorOneWorkspace(request *restful.Request, response *restful.Response) { ...@@ -145,34 +143,35 @@ func MonitorOneWorkspace(request *restful.Request, response *restful.Response) {
} }
func MonitorNamespace(request *restful.Request, response *restful.Response) { func MonitorNamespace(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request) requestParams := prom.ParseMonitoringRequestParams(request)
metricName := requestParams.MetricsName metricName := requestParams.MetricsName
nsName := requestParams.NsName nsName := requestParams.NsName
if nsName != "" { if nsName != "" {
// single // single
queryType, params := metrics.AssembleNamespaceMetricRequestInfo(requestParams, metricName) queryType, params := metrics.AssembleNamespaceMetricRequestInfo(requestParams, metricName)
res := metrics.GetMetric(queryType, params, metricName) metricsStr := prom.SendMonitoringRequest(queryType, params)
res := metrics.ReformatJson(metricsStr, metricName, map[string]string{"namespace": ""})
response.WriteAsJson(res) response.WriteAsJson(res)
} else { } else {
// multiple // multiple
rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelNamespace) rawMetrics := metrics.MonitorAllMetrics(requestParams, metrics.MetricLevelNamespace)
// sorting // sorting
sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics, metrics.MetricLevelNamespace) sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics)
// paging // paging
pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount) pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount)
response.WriteAsJson(pagedMetrics) response.WriteAsJson(pagedMetrics)
} }
} }
func MonitorCluster(request *restful.Request, response *restful.Response) { func MonitorCluster(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request) requestParams := prom.ParseMonitoringRequestParams(request)
metricName := requestParams.MetricsName metricName := requestParams.MetricsName
if metricName != "" { if metricName != "" {
// single // single
queryType, params := metrics.AssembleClusterMetricRequestInfo(requestParams, metricName) queryType, params := metrics.AssembleClusterMetricRequestInfo(requestParams, metricName)
res := metrics.GetMetric(queryType, params, metricName) metricsStr := prom.SendMonitoringRequest(queryType, params)
res := metrics.ReformatJson(metricsStr, metricName, map[string]string{"cluster": "local"})
response.WriteAsJson(res) response.WriteAsJson(res)
} else { } else {
...@@ -183,15 +182,17 @@ func MonitorCluster(request *restful.Request, response *restful.Response) { ...@@ -183,15 +182,17 @@ func MonitorCluster(request *restful.Request, response *restful.Response) {
} }
func MonitorNode(request *restful.Request, response *restful.Response) { func MonitorNode(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request) requestParams := prom.ParseMonitoringRequestParams(request)
metricName := requestParams.MetricsName metricName := requestParams.MetricsName
if metricName != "" { if metricName != "" {
// single // single
queryType, params := metrics.AssembleNodeMetricRequestInfo(requestParams, metricName) queryType, params := metrics.AssembleNodeMetricRequestInfo(requestParams, metricName)
res := metrics.GetMetric(queryType, params, metricName) metricsStr := prom.SendMonitoringRequest(queryType, params)
res := metrics.ReformatJson(metricsStr, metricName, map[string]string{"node": ""})
nodeAddress := metrics.GetNodeAddressInfo() nodeAddress := metrics.GetNodeAddressInfo()
metrics.AddNodeAddressMetric(res, nodeAddress) metrics.AddNodeAddressMetric(res, nodeAddress)
response.WriteAsJson(res) response.WriteAsJson(res)
} else { } else {
// multiple // multiple
...@@ -203,18 +204,10 @@ func MonitorNode(request *restful.Request, response *restful.Response) { ...@@ -203,18 +204,10 @@ func MonitorNode(request *restful.Request, response *restful.Response) {
} }
// sorting // sorting
sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics, metrics.MetricLevelNode) sortedMetrics, maxMetricCount := metrics.Sort(requestParams.SortMetricName, requestParams.SortType, rawMetrics)
// paging // paging
pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount) pagedMetrics := metrics.Page(requestParams.PageNum, requestParams.LimitNum, sortedMetrics, maxMetricCount)
response.WriteAsJson(pagedMetrics) response.WriteAsJson(pagedMetrics)
} }
} }
// k8s component(controller, scheduler, etcd) status
func MonitorComponentStatus(request *restful.Request, response *restful.Response) {
requestParams := prometheus.ParseMonitoringRequestParams(request)
status := metrics.MonitorComponentStatus(requestParams)
response.WriteAsJson(status)
}
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
) )
const ( const (
ApiRootPath = "/apis" ApiRootPath = "/kapis"
) )
// container holds all webservice of apiserver // container holds all webservice of apiserver
......
...@@ -8,22 +8,29 @@ import ( ...@@ -8,22 +8,29 @@ import (
// Get app metrics // Get app metrics
func GetAppMetrics(request *restful.Request, response *restful.Response) { func GetAppMetrics(request *restful.Request, response *restful.Response) {
handlers.AppMetrics(response.ResponseWriter, request.Request) handlers.AppMetrics(request, response)
} }
// Get workload metrics // Get workload metrics
func GetWorkloadMetrics(request *restful.Request, response *restful.Response) { func GetWorkloadMetrics(request *restful.Request, response *restful.Response) {
handlers.WorkloadMetrics(response.ResponseWriter, request.Request) namespace := request.PathParameter("namespace")
workload := request.PathParameter("workload")
if len(namespace) > 0 && len(workload) > 0 {
request.Request.URL.RawQuery = fmt.Sprintf("%s&namespaces=%s&workload=%s", request.Request.URL.RawQuery, namespace, workload)
}
handlers.WorkloadMetrics(request, response)
} }
// Get service metrics // Get service metrics
func GetServiceMetrics(request *restful.Request, response *restful.Response) { func GetServiceMetrics(request *restful.Request, response *restful.Response) {
handlers.ServiceMetrics(response.ResponseWriter, request.Request) handlers.ServiceMetrics(request, response)
} }
// Get namespace metrics // Get namespace metrics
func GetNamespaceMetrics(request *restful.Request, response *restful.Response) { func GetNamespaceMetrics(request *restful.Request, response *restful.Response) {
handlers.NamespaceMetrics(response.ResponseWriter, request.Request) handlers.NamespaceMetrics(request, response)
} }
// Get service graph for namespace // Get service graph for namespace
...@@ -34,10 +41,30 @@ func GetNamespaceGraph(request *restful.Request, response *restful.Response) { ...@@ -34,10 +41,30 @@ func GetNamespaceGraph(request *restful.Request, response *restful.Response) {
request.Request.URL.RawQuery = fmt.Sprintf("%s&namespaces=%s", request.Request.URL.RawQuery, namespace) request.Request.URL.RawQuery = fmt.Sprintf("%s&namespaces=%s", request.Request.URL.RawQuery, namespace)
} }
handlers.GraphNamespaces(response.ResponseWriter, request.Request) handlers.GetNamespaceGraph(request, response)
} }
// Get service graph for namespaces // Get service graph for namespaces
func GetNamespacesGraph(request *restful.Request, response *restful.Response) { func GetNamespacesGraph(request *restful.Request, response *restful.Response) {
handlers.GraphNamespaces(response.ResponseWriter, request.Request) handlers.GraphNamespaces(request, response)
}
// Get namespace health
func GetNamespaceHealth(request *restful.Request, response *restful.Response) {
handlers.NamespaceHealth(request, response)
}
// Get workload health
func GetWorkloadHealth(request *restful.Request, response *restful.Response) {
handlers.WorkloadHealth(request, response)
}
// Get app health
func GetAppHealth(request *restful.Request, response *restful.Response) {
handlers.AppHealth(request, response)
}
// Get service health
func GetServiceHealth(request *restful.Request, response *restful.Response) {
handlers.ServiceHealth(request, response)
} }
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package versioned
import (
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/servicemesh/v1alpha2"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
ServicemeshV1alpha2() servicemeshv1alpha2.ServicemeshV1alpha2Interface
// Deprecated: please explicitly pick a version if possible.
Servicemesh() servicemeshv1alpha2.ServicemeshV1alpha2Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
servicemeshV1alpha2 *servicemeshv1alpha2.ServicemeshV1alpha2Client
}
// ServicemeshV1alpha2 retrieves the ServicemeshV1alpha2Client
func (c *Clientset) ServicemeshV1alpha2() servicemeshv1alpha2.ServicemeshV1alpha2Interface {
return c.servicemeshV1alpha2
}
// Deprecated: Servicemesh retrieves the default version of ServicemeshClient.
// Please explicitly pick a version.
func (c *Clientset) Servicemesh() servicemeshv1alpha2.ServicemeshV1alpha2Interface {
return c.servicemeshV1alpha2
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
return nil
}
return c.DiscoveryClient
}
// NewForConfig creates a new Clientset for the given config.
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.servicemeshV1alpha2, err = servicemeshv1alpha2.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
return &cs, nil
}
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.servicemeshV1alpha2 = servicemeshv1alpha2.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
}
// New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.servicemeshV1alpha2 = servicemeshv1alpha2.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated clientset.
package versioned
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing"
clientset "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/servicemesh/v1alpha2"
fakeservicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/servicemesh/v1alpha2/fake"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
cs := &Clientset{}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
if err != nil {
return false, nil, err
}
return true, watch, nil
})
return cs
}
// Clientset implements clientset.Interface. Meant to be embedded into a
// struct to get a default implementation. This makes faking out just the method
// you want to test easier.
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
var _ clientset.Interface = &Clientset{}
// ServicemeshV1alpha2 retrieves the ServicemeshV1alpha2Client
func (c *Clientset) ServicemeshV1alpha2() servicemeshv1alpha2.ServicemeshV1alpha2Interface {
return &fakeservicemeshv1alpha2.FakeServicemeshV1alpha2{Fake: &c.Fake}
}
// Servicemesh retrieves the ServicemeshV1alpha2Client
func (c *Clientset) Servicemesh() servicemeshv1alpha2.ServicemeshV1alpha2Interface {
return &fakeservicemeshv1alpha2.FakeServicemeshV1alpha2{Fake: &c.Fake}
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated fake clientset.
package fake
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
)
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
servicemeshv1alpha2.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(scheme))
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package contains the scheme of the automatically generated clientset.
package scheme
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package scheme
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
)
var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
servicemeshv1alpha2.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
var AddToScheme = localSchemeBuilder.AddToScheme
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
utilruntime.Must(AddToScheme(Scheme))
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1alpha2
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/servicemesh/v1alpha2"
)
type FakeServicemeshV1alpha2 struct {
*testing.Fake
}
func (c *FakeServicemeshV1alpha2) ServicePolicies(namespace string) v1alpha2.ServicePolicyInterface {
return &FakeServicePolicies{c, namespace}
}
func (c *FakeServicemeshV1alpha2) Strategies(namespace string) v1alpha2.StrategyInterface {
return &FakeStrategies{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeServicemeshV1alpha2) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
)
// FakeServicePolicies implements ServicePolicyInterface
type FakeServicePolicies struct {
Fake *FakeServicemeshV1alpha2
ns string
}
var servicepoliciesResource = schema.GroupVersionResource{Group: "servicemesh.kubesphere.io", Version: "v1alpha2", Resource: "servicepolicies"}
var servicepoliciesKind = schema.GroupVersionKind{Group: "servicemesh.kubesphere.io", Version: "v1alpha2", Kind: "ServicePolicy"}
// Get takes name of the servicePolicy, and returns the corresponding servicePolicy object, and an error if there is any.
func (c *FakeServicePolicies) Get(name string, options v1.GetOptions) (result *v1alpha2.ServicePolicy, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(servicepoliciesResource, c.ns, name), &v1alpha2.ServicePolicy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ServicePolicy), err
}
// List takes label and field selectors, and returns the list of ServicePolicies that match those selectors.
func (c *FakeServicePolicies) List(opts v1.ListOptions) (result *v1alpha2.ServicePolicyList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(servicepoliciesResource, servicepoliciesKind, c.ns, opts), &v1alpha2.ServicePolicyList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha2.ServicePolicyList{ListMeta: obj.(*v1alpha2.ServicePolicyList).ListMeta}
for _, item := range obj.(*v1alpha2.ServicePolicyList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested servicePolicies.
func (c *FakeServicePolicies) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(servicepoliciesResource, c.ns, opts))
}
// Create takes the representation of a servicePolicy and creates it. Returns the server's representation of the servicePolicy, and an error, if there is any.
func (c *FakeServicePolicies) Create(servicePolicy *v1alpha2.ServicePolicy) (result *v1alpha2.ServicePolicy, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(servicepoliciesResource, c.ns, servicePolicy), &v1alpha2.ServicePolicy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ServicePolicy), err
}
// Update takes the representation of a servicePolicy and updates it. Returns the server's representation of the servicePolicy, and an error, if there is any.
func (c *FakeServicePolicies) Update(servicePolicy *v1alpha2.ServicePolicy) (result *v1alpha2.ServicePolicy, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(servicepoliciesResource, c.ns, servicePolicy), &v1alpha2.ServicePolicy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ServicePolicy), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeServicePolicies) UpdateStatus(servicePolicy *v1alpha2.ServicePolicy) (*v1alpha2.ServicePolicy, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(servicepoliciesResource, "status", c.ns, servicePolicy), &v1alpha2.ServicePolicy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ServicePolicy), err
}
// Delete takes name of the servicePolicy and deletes it. Returns an error if one occurs.
func (c *FakeServicePolicies) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(servicepoliciesResource, c.ns, name), &v1alpha2.ServicePolicy{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeServicePolicies) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(servicepoliciesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha2.ServicePolicyList{})
return err
}
// Patch applies the patch and returns the patched servicePolicy.
func (c *FakeServicePolicies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ServicePolicy, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(servicepoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha2.ServicePolicy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ServicePolicy), err
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
)
// FakeStrategies implements StrategyInterface
type FakeStrategies struct {
Fake *FakeServicemeshV1alpha2
ns string
}
var strategiesResource = schema.GroupVersionResource{Group: "servicemesh.kubesphere.io", Version: "v1alpha2", Resource: "strategies"}
var strategiesKind = schema.GroupVersionKind{Group: "servicemesh.kubesphere.io", Version: "v1alpha2", Kind: "Strategy"}
// Get takes name of the strategy, and returns the corresponding strategy object, and an error if there is any.
func (c *FakeStrategies) Get(name string, options v1.GetOptions) (result *v1alpha2.Strategy, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(strategiesResource, c.ns, name), &v1alpha2.Strategy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Strategy), err
}
// List takes label and field selectors, and returns the list of Strategies that match those selectors.
func (c *FakeStrategies) List(opts v1.ListOptions) (result *v1alpha2.StrategyList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(strategiesResource, strategiesKind, c.ns, opts), &v1alpha2.StrategyList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha2.StrategyList{ListMeta: obj.(*v1alpha2.StrategyList).ListMeta}
for _, item := range obj.(*v1alpha2.StrategyList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested strategies.
func (c *FakeStrategies) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(strategiesResource, c.ns, opts))
}
// Create takes the representation of a strategy and creates it. Returns the server's representation of the strategy, and an error, if there is any.
func (c *FakeStrategies) Create(strategy *v1alpha2.Strategy) (result *v1alpha2.Strategy, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(strategiesResource, c.ns, strategy), &v1alpha2.Strategy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Strategy), err
}
// Update takes the representation of a strategy and updates it. Returns the server's representation of the strategy, and an error, if there is any.
func (c *FakeStrategies) Update(strategy *v1alpha2.Strategy) (result *v1alpha2.Strategy, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(strategiesResource, c.ns, strategy), &v1alpha2.Strategy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Strategy), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeStrategies) UpdateStatus(strategy *v1alpha2.Strategy) (*v1alpha2.Strategy, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(strategiesResource, "status", c.ns, strategy), &v1alpha2.Strategy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Strategy), err
}
// Delete takes name of the strategy and deletes it. Returns an error if one occurs.
func (c *FakeStrategies) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(strategiesResource, c.ns, name), &v1alpha2.Strategy{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeStrategies) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(strategiesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha2.StrategyList{})
return err
}
// Patch applies the patch and returns the patched strategy.
func (c *FakeStrategies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.Strategy, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(strategiesResource, c.ns, name, pt, data, subresources...), &v1alpha2.Strategy{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Strategy), err
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1alpha2
type ServicePolicyExpansion interface{}
type StrategyExpansion interface{}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1alpha2
import (
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
rest "k8s.io/client-go/rest"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
"kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
type ServicemeshV1alpha2Interface interface {
RESTClient() rest.Interface
ServicePoliciesGetter
StrategiesGetter
}
// ServicemeshV1alpha2Client is used to interact with features provided by the servicemesh.kubesphere.io group.
type ServicemeshV1alpha2Client struct {
restClient rest.Interface
}
func (c *ServicemeshV1alpha2Client) ServicePolicies(namespace string) ServicePolicyInterface {
return newServicePolicies(c, namespace)
}
func (c *ServicemeshV1alpha2Client) Strategies(namespace string) StrategyInterface {
return newStrategies(c, namespace)
}
// NewForConfig creates a new ServicemeshV1alpha2Client for the given config.
func NewForConfig(c *rest.Config) (*ServicemeshV1alpha2Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &ServicemeshV1alpha2Client{client}, nil
}
// NewForConfigOrDie creates a new ServicemeshV1alpha2Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *ServicemeshV1alpha2Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new ServicemeshV1alpha2Client for the given RESTClient.
func New(c rest.Interface) *ServicemeshV1alpha2Client {
return &ServicemeshV1alpha2Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1alpha2.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *ServicemeshV1alpha2Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1alpha2
import (
"time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
// ServicePoliciesGetter has a method to return a ServicePolicyInterface.
// A group's client should implement this interface.
type ServicePoliciesGetter interface {
ServicePolicies(namespace string) ServicePolicyInterface
}
// ServicePolicyInterface has methods to work with ServicePolicy resources.
type ServicePolicyInterface interface {
Create(*v1alpha2.ServicePolicy) (*v1alpha2.ServicePolicy, error)
Update(*v1alpha2.ServicePolicy) (*v1alpha2.ServicePolicy, error)
UpdateStatus(*v1alpha2.ServicePolicy) (*v1alpha2.ServicePolicy, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1alpha2.ServicePolicy, error)
List(opts v1.ListOptions) (*v1alpha2.ServicePolicyList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ServicePolicy, err error)
ServicePolicyExpansion
}
// servicePolicies implements ServicePolicyInterface
type servicePolicies struct {
client rest.Interface
ns string
}
// newServicePolicies returns a ServicePolicies
func newServicePolicies(c *ServicemeshV1alpha2Client, namespace string) *servicePolicies {
return &servicePolicies{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the servicePolicy, and returns the corresponding servicePolicy object, and an error if there is any.
func (c *servicePolicies) Get(name string, options v1.GetOptions) (result *v1alpha2.ServicePolicy, err error) {
result = &v1alpha2.ServicePolicy{}
err = c.client.Get().
Namespace(c.ns).
Resource("servicepolicies").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of ServicePolicies that match those selectors.
func (c *servicePolicies) List(opts v1.ListOptions) (result *v1alpha2.ServicePolicyList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha2.ServicePolicyList{}
err = c.client.Get().
Namespace(c.ns).
Resource("servicepolicies").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested servicePolicies.
func (c *servicePolicies) Watch(opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("servicepolicies").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a servicePolicy and creates it. Returns the server's representation of the servicePolicy, and an error, if there is any.
func (c *servicePolicies) Create(servicePolicy *v1alpha2.ServicePolicy) (result *v1alpha2.ServicePolicy, err error) {
result = &v1alpha2.ServicePolicy{}
err = c.client.Post().
Namespace(c.ns).
Resource("servicepolicies").
Body(servicePolicy).
Do().
Into(result)
return
}
// Update takes the representation of a servicePolicy and updates it. Returns the server's representation of the servicePolicy, and an error, if there is any.
func (c *servicePolicies) Update(servicePolicy *v1alpha2.ServicePolicy) (result *v1alpha2.ServicePolicy, err error) {
result = &v1alpha2.ServicePolicy{}
err = c.client.Put().
Namespace(c.ns).
Resource("servicepolicies").
Name(servicePolicy.Name).
Body(servicePolicy).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *servicePolicies) UpdateStatus(servicePolicy *v1alpha2.ServicePolicy) (result *v1alpha2.ServicePolicy, err error) {
result = &v1alpha2.ServicePolicy{}
err = c.client.Put().
Namespace(c.ns).
Resource("servicepolicies").
Name(servicePolicy.Name).
SubResource("status").
Body(servicePolicy).
Do().
Into(result)
return
}
// Delete takes name of the servicePolicy and deletes it. Returns an error if one occurs.
func (c *servicePolicies) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("servicepolicies").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *servicePolicies) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("servicepolicies").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched servicePolicy.
func (c *servicePolicies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ServicePolicy, err error) {
result = &v1alpha2.ServicePolicy{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("servicepolicies").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1alpha2
import (
"time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
// StrategiesGetter has a method to return a StrategyInterface.
// A group's client should implement this interface.
type StrategiesGetter interface {
Strategies(namespace string) StrategyInterface
}
// StrategyInterface has methods to work with Strategy resources.
type StrategyInterface interface {
Create(*v1alpha2.Strategy) (*v1alpha2.Strategy, error)
Update(*v1alpha2.Strategy) (*v1alpha2.Strategy, error)
UpdateStatus(*v1alpha2.Strategy) (*v1alpha2.Strategy, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1alpha2.Strategy, error)
List(opts v1.ListOptions) (*v1alpha2.StrategyList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.Strategy, err error)
StrategyExpansion
}
// strategies implements StrategyInterface
type strategies struct {
client rest.Interface
ns string
}
// newStrategies returns a Strategies
func newStrategies(c *ServicemeshV1alpha2Client, namespace string) *strategies {
return &strategies{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the strategy, and returns the corresponding strategy object, and an error if there is any.
func (c *strategies) Get(name string, options v1.GetOptions) (result *v1alpha2.Strategy, err error) {
result = &v1alpha2.Strategy{}
err = c.client.Get().
Namespace(c.ns).
Resource("strategies").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of Strategies that match those selectors.
func (c *strategies) List(opts v1.ListOptions) (result *v1alpha2.StrategyList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha2.StrategyList{}
err = c.client.Get().
Namespace(c.ns).
Resource("strategies").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested strategies.
func (c *strategies) Watch(opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("strategies").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a strategy and creates it. Returns the server's representation of the strategy, and an error, if there is any.
func (c *strategies) Create(strategy *v1alpha2.Strategy) (result *v1alpha2.Strategy, err error) {
result = &v1alpha2.Strategy{}
err = c.client.Post().
Namespace(c.ns).
Resource("strategies").
Body(strategy).
Do().
Into(result)
return
}
// Update takes the representation of a strategy and updates it. Returns the server's representation of the strategy, and an error, if there is any.
func (c *strategies) Update(strategy *v1alpha2.Strategy) (result *v1alpha2.Strategy, err error) {
result = &v1alpha2.Strategy{}
err = c.client.Put().
Namespace(c.ns).
Resource("strategies").
Name(strategy.Name).
Body(strategy).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *strategies) UpdateStatus(strategy *v1alpha2.Strategy) (result *v1alpha2.Strategy, err error) {
result = &v1alpha2.Strategy{}
err = c.client.Put().
Namespace(c.ns).
Resource("strategies").
Name(strategy.Name).
SubResource("status").
Body(strategy).
Do().
Into(result)
return
}
// Delete takes name of the strategy and deletes it. Returns an error if one occurs.
func (c *strategies) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("strategies").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *strategies) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("strategies").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched strategy.
func (c *strategies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.Strategy, err error) {
result = &v1alpha2.Strategy{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("strategies").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package externalversions
import (
reflect "reflect"
sync "sync"
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
servicemesh "kubesphere.io/kubesphere/pkg/client/informers/externalversions/servicemesh"
)
// SharedInformerOption defines the functional option type for SharedInformerFactory.
type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory
type sharedInformerFactory struct {
client versioned.Interface
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]time.Duration
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
}
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
for k, v := range resyncConfig {
factory.customResync[reflect.TypeOf(k)] = v
}
return factory
}
}
// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory.
func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.tweakListOptions = tweakListOptions
return factory
}
}
// WithNamespace limits the SharedInformerFactory to the specified namespace.
func WithNamespace(namespace string) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.namespace = namespace
return factory
}
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync)
}
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
// Listers obtained via this SharedInformerFactory will be subject to the same filters
// as specified here.
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
}
// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options.
func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory {
factory := &sharedInformerFactory{
client: client,
namespace: v1.NamespaceAll,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
customResync: make(map[reflect.Type]time.Duration),
}
// Apply all options
for _, opt := range options {
factory = opt(factory)
}
return factory
}
// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
go informer.Run(stopCh)
f.startedInformers[informerType] = true
}
}
}
// WaitForCacheSync waits for all started informers' cache were synced.
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
informers := func() map[reflect.Type]cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informers := map[reflect.Type]cache.SharedIndexInformer{}
for informerType, informer := range f.informers {
if f.startedInformers[informerType] {
informers[informerType] = informer
}
}
return informers
}()
res := map[reflect.Type]bool{}
for informType, informer := range informers {
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
}
return res
}
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(obj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
resyncPeriod, exists := f.customResync[informerType]
if !exists {
resyncPeriod = f.defaultResync
}
informer = newFunc(f.client, resyncPeriod)
f.informers[informerType] = informer
return informer
}
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
Servicemesh() servicemesh.Interface
}
func (f *sharedInformerFactory) Servicemesh() servicemesh.Interface {
return servicemesh.New(f, f.namespace, f.tweakListOptions)
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package externalversions
import (
"fmt"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
)
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
// sharedInformers based on type
type GenericInformer interface {
Informer() cache.SharedIndexInformer
Lister() cache.GenericLister
}
type genericInformer struct {
informer cache.SharedIndexInformer
resource schema.GroupResource
}
// Informer returns the SharedIndexInformer.
func (f *genericInformer) Informer() cache.SharedIndexInformer {
return f.informer
}
// Lister returns the GenericLister.
func (f *genericInformer) Lister() cache.GenericLister {
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
}
// ForResource gives generic access to a shared informer of the matching type
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=servicemesh.kubesphere.io, Version=v1alpha2
case v1alpha2.SchemeGroupVersion.WithResource("servicepolicies"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Servicemesh().V1alpha2().ServicePolicies().Informer()}, nil
case v1alpha2.SchemeGroupVersion.WithResource("strategies"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Servicemesh().V1alpha2().Strategies().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package internalinterfaces
import (
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
)
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package servicemesh
import (
internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
v1alpha2 "kubesphere.io/kubesphere/pkg/client/informers/externalversions/servicemesh/v1alpha2"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V1alpha2 provides access to shared informers for resources in V1alpha2.
V1alpha2() v1alpha2.Interface
}
type group struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// V1alpha2 returns a new v1alpha2.Interface.
func (g *group) V1alpha2() v1alpha2.Interface {
return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions)
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha2
import (
internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// ServicePolicies returns a ServicePolicyInformer.
ServicePolicies() ServicePolicyInformer
// Strategies returns a StrategyInformer.
Strategies() StrategyInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// ServicePolicies returns a ServicePolicyInformer.
func (v *version) ServicePolicies() ServicePolicyInformer {
return &servicePolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// Strategies returns a StrategyInformer.
func (v *version) Strategies() StrategyInformer {
return &strategyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha2
import (
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
v1alpha2 "kubesphere.io/kubesphere/pkg/client/listers/servicemesh/v1alpha2"
)
// ServicePolicyInformer provides access to a shared informer and lister for
// ServicePolicies.
type ServicePolicyInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha2.ServicePolicyLister
}
type servicePolicyInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewServicePolicyInformer constructs a new informer for ServicePolicy type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewServicePolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredServicePolicyInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredServicePolicyInformer constructs a new informer for ServicePolicy type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredServicePolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ServicemeshV1alpha2().ServicePolicies(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ServicemeshV1alpha2().ServicePolicies(namespace).Watch(options)
},
},
&servicemeshv1alpha2.ServicePolicy{},
resyncPeriod,
indexers,
)
}
func (f *servicePolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredServicePolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *servicePolicyInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&servicemeshv1alpha2.ServicePolicy{}, f.defaultInformer)
}
func (f *servicePolicyInformer) Lister() v1alpha2.ServicePolicyLister {
return v1alpha2.NewServicePolicyLister(f.Informer().GetIndexer())
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha2
import (
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
v1alpha2 "kubesphere.io/kubesphere/pkg/client/listers/servicemesh/v1alpha2"
)
// StrategyInformer provides access to a shared informer and lister for
// Strategies.
type StrategyInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha2.StrategyLister
}
type strategyInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewStrategyInformer constructs a new informer for Strategy type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewStrategyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredStrategyInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredStrategyInformer constructs a new informer for Strategy type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredStrategyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ServicemeshV1alpha2().Strategies(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ServicemeshV1alpha2().Strategies(namespace).Watch(options)
},
},
&servicemeshv1alpha2.Strategy{},
resyncPeriod,
indexers,
)
}
func (f *strategyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredStrategyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *strategyInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&servicemeshv1alpha2.Strategy{}, f.defaultInformer)
}
func (f *strategyInformer) Lister() v1alpha2.StrategyLister {
return v1alpha2.NewStrategyLister(f.Informer().GetIndexer())
}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha2
// ServicePolicyListerExpansion allows custom methods to be added to
// ServicePolicyLister.
type ServicePolicyListerExpansion interface{}
// ServicePolicyNamespaceListerExpansion allows custom methods to be added to
// ServicePolicyNamespaceLister.
type ServicePolicyNamespaceListerExpansion interface{}
// StrategyListerExpansion allows custom methods to be added to
// StrategyLister.
type StrategyListerExpansion interface{}
// StrategyNamespaceListerExpansion allows custom methods to be added to
// StrategyNamespaceLister.
type StrategyNamespaceListerExpansion interface{}
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha2
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/servicemesh/v1alpha2"
)
// ServicePolicyLister helps list ServicePolicies.
type ServicePolicyLister interface {
// List lists all ServicePolicies in the indexer.
List(selector labels.Selector) (ret []*v1alpha2.ServicePolicy, err error)
// ServicePolicies returns an object that can list and get ServicePolicies.
ServicePolicies(namespace string) ServicePolicyNamespaceLister
ServicePolicyListerExpansion
}
// servicePolicyLister implements the ServicePolicyLister interface.
type servicePolicyLister struct {
indexer cache.Indexer
}
// NewServicePolicyLister returns a new ServicePolicyLister.
func NewServicePolicyLister(indexer cache.Indexer) ServicePolicyLister {
return &servicePolicyLister{indexer: indexer}
}
// List lists all ServicePolicies in the indexer.
func (s *servicePolicyLister) List(selector labels.Selector) (ret []*v1alpha2.ServicePolicy, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha2.ServicePolicy))
})
return ret, err
}
// ServicePolicies returns an object that can list and get ServicePolicies.
func (s *servicePolicyLister) ServicePolicies(namespace string) ServicePolicyNamespaceLister {
return servicePolicyNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ServicePolicyNamespaceLister helps list and get ServicePolicies.
type ServicePolicyNamespaceLister interface {
// List lists all ServicePolicies in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1alpha2.ServicePolicy, err error)
// Get retrieves the ServicePolicy from the indexer for a given namespace and name.
Get(name string) (*v1alpha2.ServicePolicy, error)
ServicePolicyNamespaceListerExpansion
}
// servicePolicyNamespaceLister implements the ServicePolicyNamespaceLister
// interface.
type servicePolicyNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ServicePolicies in the indexer for a given namespace.
func (s servicePolicyNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.ServicePolicy, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha2.ServicePolicy))
})
return ret, err
}
// Get retrieves the ServicePolicy from the indexer for a given namespace and name.
func (s servicePolicyNamespaceLister) Get(name string) (*v1alpha2.ServicePolicy, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha2.Resource("servicepolicy"), name)
}
return obj.(*v1alpha2.ServicePolicy), nil
}
此差异已折叠。
...@@ -17,14 +17,14 @@ limitations under the License. ...@@ -17,14 +17,14 @@ limitations under the License.
package controller package controller
import ( import (
"kubesphere.io/kubesphere/pkg/controller/strategy" "sigs.k8s.io/application/pkg/controller/application"
) )
func init() { func init() {
// AddToManagerFuncs is a list of functions to create controllers and add them to a manager. // AddToManagerFuncs is a list of functions to create controllers and add them to a manager.
AddToManagerFuncs = append(AddToManagerFuncs, strategy.Add) //AddToManagerFuncs = append(AddToManagerFuncs, strategy.Add)
// Add application to manager functions // Add application to manager functions
//AddToManagerFuncs = append(AddToManagerFuncs, application.Add) AddToManagerFuncs = append(AddToManagerFuncs, application.Add)
} }
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Subproject commit f8007289b228598dfdf7e6de67ee5f5c391c9d34
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册