Skip to content

Commit 73207e4

Browse files
committed
configure ingress for monitoring
1 parent e546772 commit 73207e4

File tree

1 file changed

+66
-65
lines changed

1 file changed

+66
-65
lines changed

cmd/kuberoCli/install.go

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -386,71 +386,6 @@ func installIngress() {
386386
log.Fatal(ingressErr)
387387
}
388388

389-
patch := `{
390-
"spec": {
391-
"template": {
392-
"metadata": {
393-
"annotations": {
394-
"prometheus.io/port": "10254",
395-
"prometheus.io/scrape": "true"
396-
}
397-
},
398-
"spec": {
399-
"containers": [
400-
{
401-
"name": "controller",
402-
"ports": [
403-
{
404-
"containerPort": 10254,
405-
"name": "prometheus",
406-
"protocol": "TCP"
407-
}
408-
],
409-
"args": [
410-
"/nginx-ingress-controller",
411-
"--election-id=ingress-nginx-leader",
412-
"--controller-class=k8s.io/ingress-nginx",
413-
"--ingress-class=nginx",
414-
"--configmap=$(POD_NAMESPACE)/ingress-nginx-controller",
415-
"--validating-webhook=:8443",
416-
"--validating-webhook-certificate=/usr/local/certificates/cert",
417-
"--validating-webhook-key=/usr/local/certificates/key",
418-
"--watch-ingress-without-class=true",
419-
"--enable-metrics=true",
420-
"--publish-status-address=localhost"
421-
]
422-
}
423-
]
424-
}
425-
}
426-
}
427-
}`
428-
_, ingressPatch := exec.Command("kubectl", "patch", "deployments.apps", "ingress-nginx-controller", "-n", "ingress-nginx", "-p", patch).Output()
429-
if ingressPatch != nil {
430-
ingressSpinner.Error("Failed to patch the ingress controller. Here is a detailled information how to do it manually: https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/monitoring.md")
431-
//log.Fatal(ingressPatch)
432-
}
433-
434-
patch = `{
435-
"spec": {
436-
"ports": [
437-
{
438-
"name": "prometheus",
439-
"nodePort": 31280,
440-
"port": 10254,
441-
"protocol": "TCP",
442-
"targetPort": "prometheus"
443-
}
444-
]
445-
}
446-
}`
447-
448-
_, ingressPatch = exec.Command("kubectl", "patch", "svc", "ingress-nginx-controller", "-n", "ingress-nginx", "-p", patch).Output()
449-
if ingressPatch != nil {
450-
ingressSpinner.Error("Failed to patch the ingress controller service. Here is a detailled information how to do it manually: https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/monitoring.md")
451-
//log.Fatal(ingressPatch)
452-
}
453-
454389
ingressSpinner.Success("Ingress installed sucessfully")
455390
}
456391

@@ -838,6 +773,72 @@ func installMonitoring() {
838773
spinner.Success("metrics enabled sucessfully")
839774

840775
}
776+
777+
patch := `{
778+
"spec": {
779+
"template": {
780+
"metadata": {
781+
"annotations": {
782+
"prometheus.io/port": "10254",
783+
"prometheus.io/scrape": "true"
784+
}
785+
},
786+
"spec": {
787+
"containers": [
788+
{
789+
"name": "controller",
790+
"ports": [
791+
{
792+
"containerPort": 10254,
793+
"name": "prometheus",
794+
"protocol": "TCP"
795+
}
796+
],
797+
"args": [
798+
"/nginx-ingress-controller",
799+
"--election-id=ingress-nginx-leader",
800+
"--controller-class=k8s.io/ingress-nginx",
801+
"--ingress-class=nginx",
802+
"--configmap=$(POD_NAMESPACE)/ingress-nginx-controller",
803+
"--validating-webhook=:8443",
804+
"--validating-webhook-certificate=/usr/local/certificates/cert",
805+
"--validating-webhook-key=/usr/local/certificates/key",
806+
"--watch-ingress-without-class=true",
807+
"--enable-metrics=true",
808+
"--publish-status-address=localhost"
809+
]
810+
}
811+
]
812+
}
813+
}
814+
}
815+
}`
816+
_, ingressPatch := exec.Command("kubectl", "patch", "deployments.apps", "ingress-nginx-controller", "-n", "ingress-nginx", "-p", patch).Output()
817+
if ingressPatch != nil {
818+
cfmt.Println("{{✗ Failed to patch the ingress controller. }}::red\nHere is a detailled information how to do it manually: https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/monitoring.md")
819+
//log.Fatal(ingressPatch)
820+
}
821+
822+
patch = `{
823+
"spec": {
824+
"ports": [
825+
{
826+
"name": "prometheus",
827+
"nodePort": 31280,
828+
"port": 10254,
829+
"protocol": "TCP",
830+
"targetPort": "prometheus"
831+
}
832+
]
833+
}
834+
}`
835+
836+
_, ingressPatch = exec.Command("kubectl", "patch", "svc", "ingress-nginx-controller", "-n", "ingress-nginx", "-p", patch).Output()
837+
if ingressPatch != nil {
838+
cfmt.Println("{{✗ Failed to patch the ingress controller service. }}::red\nHere is a detailled information how to do it manually: https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/monitoring.md")
839+
//log.Fatal(ingressPatch)
840+
}
841+
841842
}
842843

843844
func installCertManager() {

0 commit comments

Comments
 (0)