Skip to content

Commit 25c5fee

Browse files
authored
Merge pull request #90 from andyxning/change_flag_to_pflag
change flag to pflag
2 parents 5982344 + b28c622 commit 25c5fee

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

Dockerfile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC
2020

2121
ADD ./bin/node-problem-detector /node-problem-detector
2222
ADD config /config
23-
ENTRYPOINT ["/node-problem-detector", "-kernel-monitor=/config/kernel-monitor.json"]
23+
ENTRYPOINT ["/node-problem-detector", "--kernel-monitor=/config/kernel-monitor.json"]

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ List of supported problem daemons:
5353

5454
# Usage
5555
## Flags
56-
* `-version`: Print current version of node-problem-detector.
57-
* `-kernel-monitor`: The configuration used by the kernel monitor, e.g.
56+
* `--version`: Print current version of node-problem-detector.
57+
* `--kernel-monitor`: The configuration used by the kernel monitor, e.g.
5858
[config/kernel-monitor.json](https://github.com/kubernetes/node-problem-detector/blob/master/config/kernel-monitor.json).
59-
* `-apiserver-override`: A URI parameter used to customize how node-problem-detector
59+
* `--apiserver-override`: A URI parameter used to customize how node-problem-detector
6060
connects the apiserver. The format is same as the
6161
[`source`](https://github.com/kubernetes/heapster/blob/master/docs/source-configuration.md#kubernetes)
6262
flag of [Heapster](https://github.com/kubernetes/heapster).
@@ -65,7 +65,7 @@ For example, to run without auth, use the following config:
6565
http://APISERVER_IP:APISERVER_PORT?inClusterConfig=false
6666
```
6767
Refer [heapster docs](https://github.com/kubernetes/heapster/blob/1e40b0f4b5eeb3f02e11ee22c2b6fda36b6e6ea1/docs/source-configuration.md#kubernetes) for a complete list of available options.
68-
* `-hostname-override`: A customized node name used for node-problem-detector to update conditions and emit events. node-problem-detector gets node name first from `hostname-override`, then `NODE_NAME` environment variable and finally fall back to `os.Hostname`.
68+
* `--hostname-override`: A customized node name used for node-problem-detector to update conditions and emit events. node-problem-detector gets node name first from `hostname-override`, then `NODE_NAME` environment variable and finally fall back to `os.Hostname`.
6969

7070
## Build Image
7171
Run `make` in the top directory. It will:
@@ -123,7 +123,7 @@ teach node-problem-detector how to access apiserver with `apiserver-override`.
123123

124124
To run node-problem-detector standalone with an insecure apiserver connection:
125125
```
126-
node-problem-detector -apiserver-override=http://APISERVER_IP:APISERVER_INSECURE_PORT?inClusterConfig=false
126+
node-problem-detector --apiserver-override=http://APISERVER_IP:APISERVER_INSECURE_PORT?inClusterConfig=false
127127
```
128128

129129
For more scenarios, see [here](https://github.com/kubernetes/heapster/blob/master/docs/source-configuration.md#kubernetes)

cmd/node_problem_detector.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"strconv"
2727

2828
"github.com/golang/glog"
29+
"github.com/spf13/pflag"
2930

3031
"k8s.io/node-problem-detector/pkg/kernelmonitor"
3132
"k8s.io/node-problem-detector/pkg/problemdetector"
@@ -34,12 +35,12 @@ import (
3435

3536
// TODO: Move flags to options directory.
3637
var (
37-
kernelMonitorConfigPath = flag.String("kernel-monitor", "/config/kernel-monitor.json", "The path to the kernel monitor config file")
38-
apiServerOverride = flag.String("apiserver-override", "", "Custom URI used to connect to Kubernetes ApiServer")
39-
printVersion = flag.Bool("version", false, "Print version information and quit")
40-
hostnameOverride = flag.String("hostname-override", "", "Custom node name used to override hostname")
41-
serverPort = flag.Int("port", 10256, "The port to bind the node problem detector server. Use 0 to disable.")
42-
serverAddress = flag.String("address", "127.0.0.1", "The address to bind the node problem detector server.")
38+
kernelMonitorConfigPath = pflag.String("kernel-monitor", "/config/kernel-monitor.json", "The path to the kernel monitor config file")
39+
apiServerOverride = pflag.String("apiserver-override", "", "Custom URI used to connect to Kubernetes ApiServer")
40+
printVersion = pflag.Bool("version", false, "Print version information and quit")
41+
hostnameOverride = pflag.String("hostname-override", "", "Custom node name used to override hostname")
42+
serverPort = pflag.Int("port", 10256, "The port to bind the node problem detector server. Use 0 to disable.")
43+
serverAddress = pflag.String("address", "127.0.0.1", "The address to bind the node problem detector server.")
4344
)
4445

4546
func validateCmdParams() {
@@ -94,7 +95,9 @@ func startHTTPServer(p problemdetector.ProblemDetector) {
9495
}
9596

9697
func main() {
97-
flag.Parse()
98+
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
99+
pflag.Parse()
100+
98101
validateCmdParams()
99102

100103
if *printVersion {

node-problem-detector.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ spec:
1212
- name: node-problem-detector
1313
command:
1414
- /node-problem-detector
15-
- -logtostderr
16-
- -kernel-monitor=/config/kernel-monitor.json
15+
- --logtostderr
16+
- --kernel-monitor=/config/kernel-monitor.json
1717
image: gcr.io/google_containers/node-problem-detector:v0.2
1818
imagePullPolicy: Always
1919
securityContext:

0 commit comments

Comments
 (0)