I am getting these metrics by default from prometheus:
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="0.005"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="0.01"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="0.025"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="0.05"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="0.1"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="0.25"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="0.5"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="1"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="2.5"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="5"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="10"} 33
gin_gin_request_duration_bucket{host="localhost:8080",method="GET",path="/dummy1",le="+Inf"} 33
How can I resolve this issue/error?
ERROR: In file './docker-compose.yml', service must be a mapping, not a NoneType.
I am not sure why, but I can't grasp the yml world the yml file is here:
1 version: "3.8"
2 services:
3 mongodb:
4 image: mongo
5 container_name: mongodb
6 environment:
7 - MONGO_INITDB_ROOT_USERNAME=microservice
8 - MONGO_INITDB_ROOT_PASSWORD=A1d2r3i4a5n!
9 volumes:
10 - mongodb-data:/data/db
11 networks:
12 - mongodb_network
13 ports:
14 - 27017:27017
15 healthcheck:
16 test: echo 'db.runCommand("ping").ok' | mongo 192.168.254.135:27017/test --quiet
17 interval: 30s
18 timeout: 10s
19 retries: 3
20 restart: unless-stopped
21 mongo-express:
22 image: mongo-express
23 container_name: mongo-express
24 environment:
25 - ME_CONFIG_MONGODB_SERVER=mongodb
26 - ME_CONFIG_MONGODB_ENABLE_ADMIN=true
27 - ME_CONFIG_MONGODB_ADMINUSERNAME=microservice
28 - ME_CONFIG_MONGODB_ADMINPASSWORD=A1d2r3i4a5n!
29 - ME_CONFIG_BASICAUTH_USERNAME=admin
30 - ME_CONFIG_BASICAUTH_PASSWORD=admin123
31 volumes:
32 - mongodb-data
33 depends_on:
34 - mongodb
35 networks:
36 - mongodb_network
37 ports:
38 - 8081:8081
39 healthcheck:
40 test: wget --quiet --tries=3 --spider http://admin:admin123#192.168.254.135:8081 || exit 1
41 interval: 30s
42 timeout: 10s
43 retries: 3
44 restart: unless-stopped
45 volumes:
46 mongodb-data:
47 name: mongodb-data
48 networks:
49 mongodb_network:
50 name: mongodb_network
The issue comes from you indentation. Check the docker-compose reference and the YAML syntax.
You definition should look something like this:
1 version: "3.8"
2 services:
3 mongodb:
4 image: mongo
5 container_name: mongodb
6 environment:
7 - MONGO_INITDB_ROOT_USERNAME=microservice
8 - MONGO_INITDB_ROOT_PASSWORD=A1d2r3i4a5n!
9 volumes:
10 - mongodb-data:/data/db
11 networks:
12 - mongodb_network
13 ports:
14 - 27017:27017
15 healthcheck:
16 test: echo 'db.runCommand("ping").ok' | mongo 192.168.254.135:27017/test --quiet
17 interval: 30s
18 timeout: 10s
19 retries: 3
20 restart: unless-stopped
21 mongo-express:
22 image: mongo-express
23 container_name: mongo-express
24 environment:
25 - ME_CONFIG_MONGODB_SERVER=mongodb
26 - ME_CONFIG_MONGODB_ENABLE_ADMIN=true
27 - ME_CONFIG_MONGODB_ADMINUSERNAME=microservice
28 - ME_CONFIG_MONGODB_ADMINPASSWORD=A1d2r3i4a5n!
29 - ME_CONFIG_BASICAUTH_USERNAME=admin
30 - ME_CONFIG_BASICAUTH_PASSWORD=admin123
31 volumes:
32 - mongodb-data:/data/db
33 depends_on:
34 - mongodb
35 networks:
36 - mongodb_network
37 ports:
38 - 8081:8081
39 healthcheck:
40 test: wget --quiet --tries=3 --spider http://admin:admin123#192.168.254.135:8081 || exit 1
41 interval: 30s
42 timeout: 10s
43 retries: 3
44 restart: unless-stopped
45
46 volumes:
47 mongodb-data:
48
49 networks:
50 mongodb_network:
While installing Kubernetes with, I'm stuck at CNI plugin installation and configuration part. I have installed Flannel but I see error in kubelet logs due to which coredns pods are in pending state.
OS: Centos7
k8s version: 1.16
Kubeadm is being used to setup the cluster.
I had installed the plugin using: kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
This is error I can see in Kubelet logs:
Sep 21 04:47:29 peteelizalde2c kubelet: W0921 04:47:29.897759 17817 cni.go:202] Error validating CNI config &{cbr0 false [0xc000fb3ee0 0xc000fb3f60] [123 10 32 32 34 110 97 109 101 34 58 32 34 99 98 114 48 34 44 10 32 32 34 112 108 117 103 105 110 115 34 58 32 91 10 32 32 32 32 123 10 32 32 32 32 32 32 34 116 121 112 101 34 58 32 34 102 108 97 110 110 101 108 34 44 10 32 32 32 32 32 32 34 100 101 108 101 103 97 116 101 34 58 32 123 10 32 32 32 32 32 32 32 32 34 104 97 105 114 112 105 110 77 111 100 101 34 58 32 116 114 117 101 44 10 32 32 32 32 32 32 32 32 34 105 115 68 101 102 97 117 108 116 71 97 116 101 119 97 121 34 58 32 116 114 117 101 10 32 32 32 32 32 32 125 10 32 32 32 32 125 44 10 32 32 32 32 123 10 32 32 32 32 32 32 34 116 121 112 101 34 58 32 34 112 111 114 116 109 97 112 34 44 10 32 32 32 32 32 32 34 99 97 112 97 98 105 108 105 116 105 101 115 34 58 32 123 10 32 32 32 32 32 32 32 32 34 112 111 114 116 77 97 112 112 105 110 103 115 34 58 32 116 114 117 101 10 32 32 32 32 32 32 125 10 32 32 32 32 125 10 32 32 93 10 125 10]}: [plugin flannel does not support config version ""]
Sep 21 04:47:29 peteelizalde2c kubelet: W0921 04:47:29.897824 17817 cni.go:237] Unable to update cni config: no valid networks found in /etc/cni/net.d
Sep 21 04:47:32 peteelizalde2c kubelet: E0921 04:47:32.007379 17817 kubelet.go:2187] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Here is the pods:
kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-5644d7b6d9-n4h5x 0/1 Pending 0 114m
kube-system coredns-5644d7b6d9-t2q54 0/1 Pending 0 114m
kube-system etcd-ip-10-29-89-124 1/1 Running 0 113m
kube-system kube-apiserver-ip-10-29-89-124 1/1 Running 0 113m
kube-system kube-controller-manager-ip-10-29-89-124 1/1 Running 0 113m
kube-system kube-flannel-ds-amd64-dqpzj 1/1 Running 0 110m
kube-system kube-proxy-vzlqb 1/1 Running 0 114m
kube-system kube-scheduler-ip-10-29-89-124 1/1 Running 0 113m
There is a file in /etc/cni/net.d named 10-flannel.conflist.
Its contents are:
{
"name": "cbr0",
"plugins": [
{
"type": "flannel",
"delegate": {
"hairpinMode": true,
"isDefaultGateway": true
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
}
]
}
The accepted solution is incomplete and will cause headache down the line.
The proper solution to make this change permanent is to edit the ConfigMap created by flannel in your Kubernetes cluster. Otherwise, the file will be recreated the next time the flannel pod volumes are populated with the ConfigMap (e.g. on node reboot).
Use kubectl edit cm -n kube-system kube-flannel-cfg to edit the ConfigMap provided by flannel, and add the missing line:
5 apiVersion: v1
6 data:
7 cni-conf.json: |
8 {
9 "name": "cbr0",
10 "cniVersion": "0.2.0",
11 "plugins": [
Reboot the node, or alternatively make the change manually in /etc/cni/net.d/10-flannel.conflist and do systemctl restart kubelet afterwards to skip the reboot.
The file /etc/cni/net.d/10-flannel.conflist was missing cniVersion key in its config.
Adding "cniVersion": "0.2.0" solved the issue.
Thanks this helped me as it was a show-stopper
https://github.com/Microsoft/SDN/blob/master/Kubernetes/flannel/l2bridge/cni/config/cni.conf
for the exact location of the "cniVersion": "0.2.0"
My interest is in exploring how K8s resource objects are created from specs submitted by client-API; and how they are communicated across kube master services and pods.
I have started exploring the K8s source code and reached certain depth.
For this exploration I am using kubectl create -f <path to yaml> and tracking how this command is handled in source code.
here is brief summary
https://github.com/kubernetes/kubernetes/blob/v1.14.0/pkg/kubectl/cmd/create/create.go#L96 I started with this function and followed on function trail (thanks to this blog); and gradually reached to
https://github.com/kubernetes/kubernetes/blob/v1.14.0/staging/src/k8s.io/client-go/rest/request.go#L708 - http request is formed here
https://github.com/kubernetes/kubernetes/blob/v1.14.0/staging/src/k8s.io/client-go/rest/request.go#L395 - the body of the request is formed here.
https://github.com/kubernetes/kubernetes/blob/v1.14.0/staging/src/k8s.io/client-go/rest/request.go#L732 - this functions send http request and gets response back for processing, here I have addedklog.Infof("custom log sizeofdata:%T$$$$,%d$$$$,%s$$$$,%#v",*req,unsafe.Sizeof(*req),*req,*req) to find size of the request being sent.
My hypothesis is; this request size in bytes should change as the change in specs submitted by the user (yaml file passed with kubectl create -f)
Now I tried to feed two different resource spec(with kubectl create -f ) and see how the HTTP request and request body changes (its size).
Yaml 1 - nginx sample
https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/application/deployment.yaml
Yaml 2 - centos sample
apiVersion: v1
kind: Pod
metadata:
name: cent-os-test
spec:
containers:
- name: centos-test-container
image: centos
command: ["sleep"]
args: ["100"]
restartPolicy: Never
Surprisingly both times output of the logging line above was same Byte size (248 Bytes)
for log requested by klog.Infof("custom log sizeofdata:%T$$$$,%d$$$$,%s$$$$,%#v",*req,unsafe.Sizeof(*req),*req,*req)
I have used $$$$ as field separator while printing.
Following are log entries in case of both of yamls
for Yaml 2 centos ---
I0405 22:22:37.285666 360723 request.go:745] custom_log size of data : http.Request $$$$, 248 $$$$, {POST https://10.xxx.xxx.xxx:6443/api/v1/namespaces/default/pods HTTP/1.1 %!s(int=1) %!s(int=1) map[Accept:[application/json] Content-Type:[application/json]] {%!s(*bytes.Reader=&{[123 34 97 112 105 86 101 114 115 105 111 110 34 58 34 118 49 34 44 34 107 105 110 100 34 58 34 80 111 100 34 44 34 109 101 116 97 100 97 116 97 34 58 123 34 110 97 109 101 34 58 34 99 101 110 116 45 111 115 45 116 101 115 116 34 44 34 110 97 109 101 115 112 97 99 101 34 58 34 100 101 102 97 117 108 116 34 125 44 34 115 112 101 99 34 58 123 34 99 111 110 116 97 105 110 101 114 115 34 58 91 123 34 97 114 103 115 34 58 91 34 49 48 48 34 93 44 34 99 111 109 109 97 110 100 34 58 91 34 115 108 101 101 112 34 93 44 34 105 109 97 103 101 34 58 34 99 101 110 116 111 115 34 44 34 110 97 109 101 34 58 34 99 101 110 116 111 115 45 116 101 115 116 45 99 111 110 116 97 105 110 101 114 34 125 93 44 34 114 101 115 116 97 114 116 80 111 108 105 99 121 34 58 34 78 101 118 101 114 34 125 125 10] 0 -1})} %!s(func() (io.ReadCloser, error)=0x8087b0) %!s(int64=223) [] %!s(bool=false) 10.xxx.xxx.xxx:6443 map[] map[] %!s(*multipart.Form=<nil>) map[] %!s(*tls.ConnectionState=<nil>) %!s(<-chan struct {}=<nil>) %!s(*http.Response=<nil>) <nil>} $$$$, http.Request{Method:"POST", URL:(*url.URL)(0xc001dc6880), Proto:"HTTP/1.1", ProtoMajor:1, ProtoMinor:1, Header:http.Header{"Accept":[]string{"application/json"}, "Content-Type":[]string{"application/json"}}, Body:ioutil.nopCloser{Reader:(*bytes.Reader)(0xc000886f60)}, GetBody:(func() (io.ReadCloser, error))(0x8087b0), ContentLength:223, TransferEncoding:[]string(nil), Close:false, Host:"10.xxx.xxx.xxx:6443", Form:url.Values(nil), PostForm:url.Values(nil), MultipartForm:(*multipart.Form)(nil), Trailer:http.Header(nil), RemoteAddr:"", RequestURI:"", TLS:(*tls.ConnectionState)(nil), Cancel:(<-chan struct {})(nil), Response:(*http.Response)(nil), ctx:context.Context(nil)}
for Yaml 1 nginx ---
I0406 00:07:19.873854 410863 request.go:745] custom_log size of data : http.Request $$$$, 248 $$$$, {POST https://10.xxx.xxx.xxx:6443/apis/apps/v1/namespaces/default/deployments HTTP/1.1 %!s(int=1) %!s(int=1) map[Accept:[application/json] Content-Type:[application/json]] {%!s(*bytes.Reader=&{[123 34 97 112 105 86 101 114 115 105 111 110 34 58 34 97 112 112 115 47 118 49 34 44 34 107 105 110 100 34 58 34 68 101 112 108 111 121 109 101 110 116 34 44 34 109 101 116 97 100 97 116 97 34 58 123 34 110 97 109 101 34 58 34 110 103 105 110 120 45 100 101 112 108 111 121 109 101 110 116 34 44 34 110 97 109 101 115 112 97 99 101 34 58 34 100 101 102 97 117 108 116 34 125 44 34 115 112 101 99 34 58 123 34 114 101 112 108 105 99 97 115 34 58 50 44 34 115 101 108 101 99 116 111 114 34 58 123 34 109 97 116 99 104 76 97 98 101 108 115 34 58 123 34 97 112 112 34 58 34 110 103 105 110 120 34 125 125 44 34 116 101 109 112 108 97 116 101 34 58 123 34 109 101 116 97 100 97 116 97 34 58 123 34 108 97 98 101 108 115 34 58 123 34 97 112 112 34 58 34 110 103 105 110 120 34 125 125 44 34 115 112 101 99 34 58 123 34 99 111 110 116 97 105 110 101 114 115 34 58 91 123 34 105 109 97 103 101 34 58 34 110 103 105 110 120 58 49 46 55 46 57 34 44 34 110 97 109 101 34 58 34 110 103 105 110 120 34 44 34 112 111 114 116 115 34 58 91 123 34 99 111 110 116 97 105 110 101 114 80 111 114 116 34 58 56 48 125 93 125 93 125 125 125 125 10] 0 -1})} %!s(func() (io.ReadCloser, error)=0x8087b0) %!s(int64=316) [] %!s(bool=false) 10.xxx.xxx.xxx:6443 map[] map[] %!s(*multipart.Form=<nil>) map[] %!s(*tls.ConnectionState=<nil>) %!s(<-chan struct {}=<nil>) %!s(*http.Response=<nil>) <nil>} $$$$, http.Request{Method:"POST", URL:(*url.URL)(0xc000a96380), Proto:"HTTP/1.1", ProtoMajor:1, ProtoMinor:1, Header:http.Header{"Accept":[]string{"application/json"}, "Content-Type":[]string{"application/json"}}, Body:ioutil.nopCloser{Reader:(*bytes.Reader)(0xc0008abb90)}, GetBody:(func() (io.ReadCloser, error))(0x8087b0), ContentLength:316, TransferEncoding:[]string(nil), Close:false, Host:"10.xxx.xxx.xxx:6443", Form:url.Values(nil), PostForm:url.Values(nil), MultipartForm:(*multipart.Form)(nil), Trailer:http.Header(nil), RemoteAddr:"", RequestURI:"", TLS:(*tls.ConnectionState)(nil), Cancel:(<-chan struct {})(nil), Response:(*http.Response)(nil), ctx:context.Context(nil)}
Why both of times the HTTP request size is 248 bytes? Shouldn’t it increase in case of the nginx yaml since it passes more lines of spec information?
Would you refer to the length of the *req variable rather then it's size
klog.Infof("custom log sizeofdata:%T$$$$,%d$$$$,%s$$$$,%#v",*req,len(*req),*req,*req)
Similar to the below snippet illustrating that size of a variable of type string is always 8 but the length of a string that a variable references can vary:
package main
import "fmt"
import "unsafe"
func main() {
s1 := "foo"
s2 := "foobar"
fmt.Printf("s1 size: %T, %d\n", s1, unsafe.Sizeof(s1))
fmt.Printf("s2 size: %T, %d\n", s2, unsafe.Sizeof(s2))
fmt.Printf("s1 len: %T, %d\n", s1, len(s1))
fmt.Printf("s2 len: %T, %d\n", s2, len(s2))
}
Result:
s1 size: string, 8
s2 size: string, 8
s1 len: string, 3
s2 len: string, 6
I have two matrices that contain the points for the top boundaries of two jigsaw puzzles. I am trying to calculate the area contained between these two matrices (of unequal rows). They have multiple points of intersection. The picture below gives a better idea of what I'm trying to accomplish. The output should be a numerical value (of the total area highlighted in blue). If this is too difficult to achieve, is there a better way to compare matrices to see which ones "fit" the best?
Un-Highlighted Picture
Area(in blue) that I am trying to calculate (numerical value)
The matrix values are below if it helps:
Matrix 1:
1 1
2 2
3 2
4 2
5 2
6 3
7 3
8 3
9 3
10 3
11 3
12 2
13 2
14 2
15 2
16 2
17 2
18 2
19 2
20 2
21 2
22 2
23 2
24 2
25 2
26 2
27 2
28 2
29 2
30 2
31 2
32 2
33 2
34 2
35 2
36 2
37 2
38 2
39 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
47 2
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 2
59 2
60 2
61 2
62 2
63 2
64 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
72 3
73 3
74 3
75 4
76 5
77 6
78 7
79 8
79 9
80 10
80 11
80 12
80 13
80 14
80 15
79 16
79 17
79 18
78 19
78 20
78 21
77 22
77 23
77 24
76 25
76 26
76 27
75 28
75 29
75 30
74 31
74 32
74 33
73 34
73 35
73 36
73 37
73 38
72 39
72 40
72 41
72 42
72 43
72 44
73 45
73 46
73 47
74 48
75 49
76 50
77 51
78 52
79 53
80 53
81 54
82 54
83 55
84 55
85 56
86 56
87 57
88 57
89 57
90 58
91 58
92 58
93 58
94 59
95 59
96 59
97 59
98 59
99 59
100 59
101 59
102 59
103 59
104 59
105 59
106 59
107 59
108 59
109 59
110 59
111 59
112 58
113 58
114 58
115 58
116 57
117 57
118 57
119 56
120 56
121 56
122 55
123 55
124 54
125 53
126 53
127 52
128 51
129 51
130 50
131 49
132 48
132 47
133 46
133 45
133 44
133 43
133 42
133 41
133 40
133 39
133 38
132 37
132 36
132 35
131 34
131 33
131 32
131 31
130 30
130 29
130 28
130 27
129 26
129 25
128 24
128 23
127 22
127 21
127 20
127 19
126 18
126 17
126 16
126 15
126 14
126 13
126 12
126 11
126 10
126 9
127 8
128 7
129 6
130 5
131 4
132 3
133 3
134 2
135 2
136 2
137 2
138 2
139 2
140 2
141 2
142 2
143 2
144 2
145 2
146 2
147 2
148 2
149 2
150 2
151 2
152 2
153 2
154 2
155 2
156 2
157 2
158 2
159 2
160 2
161 2
162 2
163 2
164 2
165 2
166 2
167 2
168 1
169 1
170 1
171 1
172 1
Matrix 2:
173 3
172 3
171 3
170 2
169 2
168 2
167 2
166 2
165 2
164 2
163 2
162 2
161 2
160 2
159 2
158 2
157 2
156 2
155 2
154 2
153 2
152 2
151 2
150 2
149 2
148 2
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 3
134 3
133 3
132 3
131 4
130 4
129 4
128 5
127 6
127 7
127 8
126 9
127 10
127 11
127 12
127 13
127 14
126 15
127 16
127 17
127 18
127 19
127 20
127 21
128 22
128 23
128 24
128 25
129 26
129 27
129 28
130 29
130 30
130 31
131 32
131 33
131 34
132 35
132 36
132 37
132 38
133 39
133 40
133 41
133 42
133 43
132 44
132 45
132 46
131 47
130 48
129 49
128 50
127 51
126 52
125 53
124 54
123 54
122 55
121 55
120 55
119 56
118 56
117 57
116 58
115 58
114 59
113 59
112 59
111 59
110 60
109 60
108 60
107 60
106 60
105 60
104 60
103 60
102 60
101 60
100 60
99 60
98 60
97 60
96 60
95 59
94 59
93 59
92 59
91 59
90 58
89 58
88 57
87 57
86 56
85 56
84 55
83 55
82 54
81 54
80 53
79 52
78 51
77 50
76 49
75 48
74 47
73 46
73 45
73 44
73 43
73 42
73 41
73 40
73 39
73 38
73 37
73 36
74 35
74 34
74 33
75 32
75 31
75 30
76 29
76 28
76 27
77 26
77 25
77 24
78 23
78 22
78 21
79 20
79 19
80 18
80 17
80 16
81 15
81 14
81 13
81 12
81 11
81 10
80 10
79 9
79 8
78 7
77 6
76 5
75 4
74 4
73 3
72 3
71 2
70 2
69 2
68 1
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 3
Mark everything above one curve and mark everything below the other curve. Then you can get the area between the curves by finding where there are two marks.
You should take a look at this question Similarity measures between curves?