-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add memory storage for supporting ListAndWatch
Co-authored-by: duanmeng <duanmeng_yewu@cmss.chinamobile.com> Co-authored-by: wuyingjun <wuyingjun_yewu@cmss.chinamobile.com> Co-authored-by: hanweisen <hanweisen_yewu@cmss.chinamobile.com> Signed-off-by: zhangyongxi <zhangyongxi_yewu@cmss.chinamobile.com>
- Loading branch information
1 parent
e43ea17
commit 5b11676
Showing
25 changed files
with
1,434 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package app | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
"k8s.io/apimachinery/pkg/util/runtime" | ||
genericfeatures "k8s.io/apiserver/pkg/features" | ||
cliflag "k8s.io/component-base/cli/flag" | ||
"k8s.io/component-base/cli/globalflag" | ||
"k8s.io/component-base/featuregate" | ||
"k8s.io/component-base/logs" | ||
"k8s.io/component-base/term" | ||
|
||
"github.com/clusterpedia-io/clusterpedia/cmd/apiserver/app/options" | ||
clusterpediafeature "github.com/clusterpedia-io/clusterpedia/pkg/utils/feature" | ||
"github.com/clusterpedia-io/clusterpedia/pkg/version/verflag" | ||
) | ||
|
||
func NewClusterPediaServerCommand(ctx context.Context) *cobra.Command { | ||
opts := options.NewServerOptions() | ||
|
||
cmd := &cobra.Command{ | ||
Use: "clusterpedia-apiserver", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
verflag.PrintAndExitIfRequested() | ||
|
||
// Activate logging as soon as possible, after that | ||
// show flags with the final logging configuration. | ||
if err := opts.Logs.ValidateAndApply(clusterpediafeature.FeatureGate); err != nil { | ||
return err | ||
} | ||
cliflag.PrintFlags(cmd.Flags()) | ||
|
||
config, err := opts.Config(true) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
server, err := config.Complete().New() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := server.Run(ctx); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
namedFlagSets := opts.Flags() | ||
verflag.AddFlags(namedFlagSets.FlagSet("global")) | ||
globalflag.AddGlobalFlags(namedFlagSets.FlagSet("global"), cmd.Name(), logs.SkipLoggingConfigurationFlags()) | ||
clusterpediafeature.MutableFeatureGate.AddFlag(namedFlagSets.FlagSet("mutable feature gate")) | ||
|
||
fs := cmd.Flags() | ||
for _, f := range namedFlagSets.FlagSets { | ||
fs.AddFlagSet(f) | ||
} | ||
|
||
cols, _, _ := term.TerminalSize(cmd.OutOrStdout()) | ||
cliflag.SetUsageAndHelpFunc(cmd, namedFlagSets, cols) | ||
return cmd | ||
} | ||
|
||
func init() { | ||
runtime.Must(logs.AddFeatureGates(clusterpediafeature.MutableFeatureGate)) | ||
|
||
// The feature gate `RemainingItemCount` should default to false | ||
// https://github.com/clusterpedia-io/clusterpedia/issues/196 | ||
gates := clusterpediafeature.MutableFeatureGate.GetAll() | ||
gate := gates[genericfeatures.RemainingItemCount] | ||
gate.Default = false | ||
gates[genericfeatures.RemainingItemCount] = gate | ||
|
||
clusterpediafeature.MutableFeatureGate = featuregate.NewFeatureGate() | ||
runtime.Must(clusterpediafeature.MutableFeatureGate.Add(gates)) | ||
clusterpediafeature.FeatureGate = clusterpediafeature.MutableFeatureGate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
apiserver "k8s.io/apiserver/pkg/server" | ||
"k8s.io/component-base/cli" | ||
_ "k8s.io/component-base/logs/json/register" // for JSON log format registration | ||
|
||
"github.com/clusterpedia-io/clusterpedia/cmd/binding-apiserver/app" | ||
) | ||
|
||
func main() { | ||
ctx := apiserver.SetupSignalContext() | ||
command := app.NewClusterPediaServerCommand(ctx) | ||
code := cli.Run(command) | ||
os.Exit(code) | ||
} |
13 changes: 13 additions & 0 deletions
13
deploy/binding-apiserver/clusterpedia_binding_apiserver_apiservice.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: apiregistration.k8s.io/v1 | ||
kind: APIService | ||
metadata: | ||
name: v1beta1.clusterpedia.io | ||
spec: | ||
insecureSkipTLSVerify: true | ||
group: clusterpedia.io | ||
groupPriorityMinimum: 1000 | ||
versionPriority: 100 | ||
service: | ||
name: clusterpedia-binding-apiserver | ||
namespace: clusterpedia-system | ||
version: v1beta1 |
45 changes: 45 additions & 0 deletions
45
deploy/binding-apiserver/clusterpedia_binding_apiserver_deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: clusterpedia-binding-apiserver | ||
namespace: clusterpedia-system | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: clusterpedia-binding-apiserver | ||
namespace: clusterpedia-system | ||
spec: | ||
ports: | ||
- port: 443 | ||
protocol: TCP | ||
targetPort: 443 | ||
selector: | ||
app: clusterpedia-binding-apiserver | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: clusterpedia-binding-apiserver | ||
namespace: clusterpedia-system | ||
labels: | ||
app: clusterpedia-binding-apiserver | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: clusterpedia-binding-apiserver | ||
template: | ||
metadata: | ||
labels: | ||
app: clusterpedia-binding-apiserver | ||
spec: | ||
containers: | ||
- name: binding-apiserver | ||
image: ghcr.io/clusterpedia-io/clusterpedia/binding-apiserver:v0.4.1 | ||
command: | ||
- /usr/local/bin/binding-apiserver | ||
- --secure-port=443 | ||
- --storage-name=memory | ||
- -v=3 | ||
serviceAccountName: clusterpedia-binding-apiserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.