Skip to content

Commit a3715d9

Browse files
authored
Merge pull request #3 from mongodb/move_up_one_level
2 parents ee60e7a + e330eac commit a3715d9

31 files changed

+115
-347
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Temporary Build Files
2-
mongodb-kubernetes-operator/build/_output
3-
mongodb-kubernetes-operator/build/_test
2+
build/_output
3+
build/_test
44
# Created by https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
55
### Emacs ###
66
# -*- mode: gitignore; -*-
File renamed without changes.
File renamed without changes.
File renamed without changes.

cmd/manager/main.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"go.uber.org/zap"
6+
"os"
7+
8+
"github.com/mongodb/mongodb-kubernetes-operator/pkg/apis"
9+
"github.com/mongodb/mongodb-kubernetes-operator/pkg/controller"
10+
11+
"sigs.k8s.io/controller-runtime/pkg/client/config"
12+
"sigs.k8s.io/controller-runtime/pkg/manager"
13+
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
14+
)
15+
16+
// Change below variables to serve metrics on different host or port.
17+
var (
18+
metricsHost = "0.0.0.0"
19+
metricsPort int32 = 8383
20+
operatorMetricsPort int32 = 8686
21+
)
22+
23+
func main() {
24+
// TODO: configure non development logger
25+
log, err := zap.NewDevelopment()
26+
if err != nil {
27+
os.Exit(1)
28+
}
29+
// get watch namespace from environment variable
30+
namespace, nsSpecified := os.LookupEnv("WATCH_NAMESPACE")
31+
if !nsSpecified {
32+
os.Exit(1)
33+
}
34+
35+
log.Info(fmt.Sprintf("Watching namespace: %s", namespace))
36+
37+
// Get a config to talk to the apiserver
38+
cfg, err := config.GetConfig()
39+
if err != nil {
40+
os.Exit(1)
41+
}
42+
43+
// Create a new Cmd to provide shared dependencies and start components
44+
mgr, err := manager.New(cfg, manager.Options{
45+
Namespace: "temp",
46+
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
47+
})
48+
if err != nil {
49+
os.Exit(1)
50+
}
51+
52+
log.Info("Registering Components.")
53+
54+
// Setup Scheme for all resources
55+
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
56+
os.Exit(1)
57+
}
58+
59+
// Setup all Controllers
60+
if err := controller.AddToManager(mgr); err != nil {
61+
os.Exit(1)
62+
}
63+
64+
log.Info("Starting the Cmd.")
65+
66+
// Start the Cmd
67+
if err := mgr.Start(signals.SetupSignalHandler()); err != nil {
68+
os.Exit(1)
69+
}
70+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ spec:
1919
apiVersion:
2020
description: 'APIVersion defines the versioned schema of this representation
2121
of an object. Servers should convert recognized schemas to the latest
22-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
22+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
2323
type: string
2424
kind:
2525
description: 'Kind is a string value representing the REST resource this
2626
object represents. Servers may infer this from the endpoint the client
27-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
27+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
2828
type: string
2929
metadata:
3030
type: object
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)