-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pd-replicas-1' of https://github.com/weekface/tidb-oper…
…ator into pd-replicas-1
- Loading branch information
Showing
44 changed files
with
2,450 additions
and
548 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
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,96 @@ | ||
// Copyright 2019 PingCAP, Inc. | ||
// | ||
// 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, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/golang/glog" | ||
"github.com/pingcap/tidb-operator/pkg/client/clientset/versioned" | ||
"github.com/pingcap/tidb-operator/pkg/webhook" | ||
"github.com/pingcap/tidb-operator/version" | ||
"k8s.io/apiserver/pkg/util/logs" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
) | ||
|
||
var ( | ||
printVersion bool | ||
certFile string | ||
keyFile string | ||
) | ||
|
||
func init() { | ||
flag.BoolVar(&printVersion, "V", false, "Show version and quit") | ||
flag.BoolVar(&printVersion, "version", false, "Show version and quit") | ||
flag.StringVar(&certFile, "tlsCertFile", "/etc/webhook/certs/cert.pem", "File containing the x509 Certificate for HTTPS.") | ||
flag.StringVar(&keyFile, "tlsKeyFile", "/etc/webhook/certs/key.pem", "File containing the x509 private key to --tlsCertFile.") | ||
flag.Parse() | ||
} | ||
|
||
func main() { | ||
|
||
logs.InitLogs() | ||
defer logs.FlushLogs() | ||
|
||
if printVersion { | ||
version.PrintVersionInfo() | ||
os.Exit(0) | ||
} | ||
version.LogVersionInfo() | ||
|
||
cfg, err := rest.InClusterConfig() | ||
if err != nil { | ||
glog.Fatalf("failed to get config: %v", err) | ||
} | ||
|
||
cli, err := versioned.NewForConfig(cfg) | ||
if err != nil { | ||
glog.Fatalf("failed to create Clientset: %v", err) | ||
} | ||
|
||
kubeCli, err := kubernetes.NewForConfig(cfg) | ||
if err != nil { | ||
glog.Fatalf("failed to get kubernetes Clientset: %v", err) | ||
} | ||
|
||
webhookServer := webhook.NewWebHookServer(kubeCli, cli, certFile, keyFile) | ||
|
||
sigs := make(chan os.Signal, 1) | ||
done := make(chan bool, 1) | ||
|
||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) | ||
|
||
go func() { | ||
<-sigs | ||
|
||
// Graceful shutdown the server | ||
if err := webhookServer.Shutdown(); err != nil { | ||
glog.Errorf("fail to shutdown server %v", err) | ||
} | ||
|
||
done <- true | ||
}() | ||
|
||
if err := webhookServer.Run(); err != nil { | ||
glog.Errorf("stop http server %v", err) | ||
} | ||
|
||
<-done | ||
|
||
glog.Infof("webhook server terminate safely.") | ||
} |
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,4 @@ | ||
.terraform | ||
*.tfstate* | ||
credentials | ||
rendered |
Oops, something went wrong.