hardcode to yaml file (#7948)

* hardcode to yaml file

* add test instance.

* fix mistake

* fix mistake

* Uniform style
This commit is contained in:
chenhonggc 2018-04-07 22:07:08 +08:00 committed by k8s-ci-robot
parent fd81d48d58
commit 372a37141a
4 changed files with 102 additions and 90 deletions

View File

@ -54,48 +54,10 @@ provides more flexible management, such as overwriting the default
configuration to fit it into your environment or detect configuration to fit it into your environment or detect
customized node problems. customized node problems.
* **Step 1:** Create `node-problem-detector.yaml`: * **Step 1:** `node-problem-detector.yaml`:
{% include code.html language="yaml" file="node-problem-detector.yaml" ghlink="/docs/tasks/debug-application-cluster/node-problem-detector.yaml" %}
```yaml
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: node-problem-detector-v0.1
namespace: kube-system
labels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
spec:
template:
metadata:
labels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
spec:
hostNetwork: true
containers:
- name: node-problem-detector
image: k8s.gcr.io/node-problem-detector:v0.1
securityContext:
privileged: true
resources:
limits:
cpu: "200m"
memory: "100Mi"
requests:
cpu: "20m"
memory: "20Mi"
volumeMounts:
- name: log
mountPath: /log
readOnly: true
volumes:
- name: log
hostPath:
path: /var/log/
```
***Notice that you should make sure the system log directory is right for your ***Notice that you should make sure the system log directory is right for your
OS distro.*** OS distro.***
@ -103,7 +65,7 @@ OS distro.***
* **Step 2:** Start node problem detector with `kubectl`: * **Step 2:** Start node problem detector with `kubectl`:
```shell ```shell
kubectl create -f node-problem-detector.yaml kubectl create -f https://k8s.io/docs/tasks/debug-application-cluster/node-problem-detector.yaml
``` ```
### Addon Pod ### Addon Pod
@ -128,58 +90,14 @@ following the steps:
node-problem-detector-config --from-file=config/`. node-problem-detector-config --from-file=config/`.
* **Step 3:** Change the `node-problem-detector.yaml` to use the ConfigMap: * **Step 3:** Change the `node-problem-detector.yaml` to use the ConfigMap:
```yaml {% include code.html language="yaml" file="node-problem-detector-configmap.yaml" ghlink="/docs/tasks/debug-application-cluster/node-problem-detector-configmap.yaml" %}
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: node-problem-detector-v0.1
namespace: kube-system
labels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
spec:
template:
metadata:
labels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
spec:
hostNetwork: true
containers:
- name: node-problem-detector
image: k8s.gcr.io/node-problem-detector:v0.1
securityContext:
privileged: true
resources:
limits:
cpu: "200m"
memory: "100Mi"
requests:
cpu: "20m"
memory: "20Mi"
volumeMounts:
- name: log
mountPath: /log
readOnly: true
- name: config # Overwrite the config/ directory with ConfigMap volume
mountPath: /config
readOnly: true
volumes:
- name: log
hostPath:
path: /var/log/
- name: config # Define ConfigMap volume
configMap:
name: node-problem-detector-config
```
* **Step 4:** Re-create the node problem detector with the new yaml file: * **Step 4:** Re-create the node problem detector with the new yaml file:
```shell ```shell
kubectl delete -f node-problem-detector.yaml # If you have a node-problem-detector running kubectl delete -f https://k8s.io/docs/tasks/debug-application-cluster/node-problem-detector.yaml # If you have a node-problem-detector running
kubectl create -f node-problem-detector.yaml kubectl create -f https://k8s.io/docs/tasks/debug-application-cluster/node-problem-detector-configmap.yaml
``` ```
***Notice that this approach only applies to node problem detector started with `kubectl`.*** ***Notice that this approach only applies to node problem detector started with `kubectl`.***

View File

@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-problem-detector-v0.1
namespace: kube-system
labels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
spec:
selector:
matchLabels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
template:
metadata:
labels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
spec:
hostNetwork: true
containers:
- name: node-problem-detector
image: k8s.gcr.io/node-problem-detector:v0.1
securityContext:
privileged: true
resources:
limits:
cpu: "200m"
memory: "100Mi"
requests:
cpu: "20m"
memory: "20Mi"
volumeMounts:
- name: log
mountPath: /log
readOnly: true
- name: config # Overwrite the config/ directory with ConfigMap volume
mountPath: /config
readOnly: true
volumes:
- name: log
hostPath:
path: /var/log/
- name: config # Define ConfigMap volume
configMap:
name: node-problem-detector-config

View File

@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-problem-detector-v0.1
namespace: kube-system
labels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
spec:
selector:
matchLabels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
template:
metadata:
labels:
k8s-app: node-problem-detector
version: v0.1
kubernetes.io/cluster-service: "true"
spec:
hostNetwork: true
containers:
- name: node-problem-detector
image: k8s.gcr.io/node-problem-detector:v0.1
securityContext:
privileged: true
resources:
limits:
cpu: "200m"
memory: "100Mi"
requests:
cpu: "20m"
memory: "20Mi"
volumeMounts:
- name: log
mountPath: /log
readOnly: true
volumes:
- name: log
hostPath:
path: /var/log/

View File

@ -427,6 +427,8 @@ func TestExampleObjectSchemas(t *testing.T) {
"fluentd-gcp-ds": {&extensions.DaemonSet{}}, "fluentd-gcp-ds": {&extensions.DaemonSet{}},
"nginx-dep": {&extensions.Deployment{}}, "nginx-dep": {&extensions.Deployment{}},
"shell-demo": {&api.Pod{}}, "shell-demo": {&api.Pod{}},
"node-problem-detector": {&extensions.DaemonSet{}},
"node-problem-detector-configmap": {&extensions.DaemonSet{}},
"termination": {&api.Pod{}}, "termination": {&api.Pod{}},
}, },
// TODO: decide whether federation examples should be added // TODO: decide whether federation examples should be added