{"id":6800,"date":"2022-10-26T22:12:12","date_gmt":"2022-10-26T13:12:12","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6800"},"modified":"2022-12-25T19:43:03","modified_gmt":"2022-12-25T10:43:03","slug":"kubernetes-prometheus-grafana-%ec%84%a4%ec%b9%98","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6800","title":{"rendered":"Kubernetes &#8211; Prometheus\/Grafana \uc124\uce58"},"content":{"rendered":"<h1>Kubernetes &#8211; Prometheus\/Grafana \uc124\uce58<\/h1>\n<p>kube-prometheus \ub97c \uc774\uc6a9\ud558\uc5ec Prometheus\/Grafana \ub97c \ub3d9\uc2dc\uc5d0 \uc124\uce58\ud569\ub2c8\ub2e4.<\/p>\n<p>Prometheus\/Grafana \uc124\uc815\uc774 \ubaa8\ub450 \ub05d\ub098 \uc788\uc5b4\uc11c \ud3b8\ub9ac\ud558\uac8c \uc0ac\uc6a9\uac00\ub2a5\ud569\ub2c8\ub2e4.<\/p>\n<h2>\uc124\uce58<\/h2>\n<pre><code class=\"language-bash\">git clone https:\/\/github.com\/coreos\/kube-prometheus.git\ncd kube-prometheus\/<\/code><\/pre>\n<pre><code class=\"language-bash\"># Create the namespace and CRDs, and then wait for them to be available before creating the remaining resources\n# Note that due to some CRD size we are using kubectl server-side apply feature which is generally available since kubernetes 1.22.\n# If you are using previous kubernetes versions this feature may not be available and you would need to use kubectl create instead.\nkubectl apply --server-side -f manifests\/setup\nkubectl wait \\\n    --for condition=Established \\\n    --all CustomResourceDefinition \\\n    --namespace=monitoring\nkubectl apply -f manifests\/<\/code><\/pre>\n<pre><code class=\"language-bash\">kubectl get pod -n monitoring<\/code><\/pre>\n<h2>Ingress \uc0dd\uc131<\/h2>\n<p>ingress-nginx \ub294 \uae30\uc874\uc5d0 \uc124\uce58\ub418\uc5b4 \uc788\ub2e4\uace0 \uac00\uc815\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">cd\nvi ingress-grafana.yaml\n---------------------------\napiVersion: networking.k8s.io\/v1\nkind: Ingress\nmetadata:\n  name: grafana\n  namespace: monitoring\n  annotations:\n    nginx.ingress.kubernetes.io\/rewrite-target: \/\nspec:\n  ingressClassName: nginx\n  rules:\n  - host: k8s-grafana.skyer9.pe.kr\n    http:\n      paths:\n      - path: \/\n        pathType: Prefix\n        backend:\n          service:\n            name: grafana\n            port:\n              number: 3000\n---------------------------<\/code><\/pre>\n<pre><code class=\"language-bash\">kubectl apply -f ingress-grafana.yaml<\/code><\/pre>\n<p>\uc544\ub798 networkpolicy \ub97c \ucd94\uac00\ub85c \uc124\uc815\ud574 \uc8fc\uc9c0 \uc54a\uc73c\uba74,<br \/>\n\ub514\ud3f4\ud2b8\ub85c inbound \uac00 \ub9c9\ud600\uc788\uc5b4\uc11c \uc678\ubd80 \uc811\uc18d\uc774 \ubd88\uac00\ub2a5\ud558\ub2e4.<\/p>\n<pre><code class=\"language-bash\">k get networkpolicy -n monitoring<\/code><\/pre>\n<h2>NetworkPolicy \uc0dd\uc131<\/h2>\n<p>\uc6b0\uc120 \ud074\ub7ec\uc2a4\ud130\uc5d0 \uc124\uce58\ub418\uc5b4 \uc788\ub294 Network add-on \uc774,<br \/>\nNetworkPolicy \ub97c \uc9c0\uc6d0\ud558\ub294\uc9c0 \ud655\uc778\ud574\uc57c \ud569\ub2c8\ub2e4.<br \/>\n(Weave Net works \ub294 ingress \ub9cc \uc9c0\uc6d0\ud569\ub2c8\ub2e4.)<\/p>\n<pre><code class=\"language-bash\">vi np-grafana.yaml\n---------------------------\napiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  labels:\n    app.kubernetes.io\/component: grafana\n    app.kubernetes.io\/name: grafana\n    app.kubernetes.io\/part-of: kube-prometheus\n    app.kubernetes.io\/version: 9.0.1\n  name: grafana\n  namespace: monitoring\nspec:\n  egress:\n  - {}\n  ingress:\n  - ports:\n    - port: 3000\n      protocol: TCP\n    # \uc5ec\ub7ec\uac1c\uc758 \uc544\uc774\ud53c \ub300\uc5ed\uc744 \ud560\ub2f9\ud560 \uc218 \uc788\ub2e4.\n    # from:\n    # - ipBlock:\n    #   cidr: 172.17.0.0\/16\n    #   except:\n    #   - 172.17.1.0\/24\n  podSelector:\n    matchLabels:\n      app.kubernetes.io\/component: grafana\n      app.kubernetes.io\/name: grafana\n      app.kubernetes.io\/part-of: kube-prometheus\n  policyTypes:\n  - Egress\n  - Ingress\n---------------------------<\/code><\/pre>\n<p>PC \ud638\uc2a4\ud2b8 \ud30c\uc77c\uc5d0 \uc544\ub798 \ub0b4\uc6a9\uc744 \ucd94\uac00\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">&lt;worker node \uc544\uc774\ud53c&gt; k8s-grafana.skyer9.pe.kr<\/code><\/pre>\n<pre><code class=\"language-bash\">kubectl get svc -n ingress-nginx\nNAME                                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE\ningress-nginx-controller             NodePort    10.108.205.161   &lt;none&gt;        80:31546\/TCP,443:32034\/TCP   24h\ningress-nginx-controller-admission   ClusterIP   10.103.41.92     &lt;none&gt;        443\/TCP                      24h<\/code><\/pre>\n<p><a href=\"http:\/\/k8s-prometheus.skyer9.pe.kr:31546\">http:\/\/k8s-prometheus.skyer9.pe.kr:31546<\/a><\/p>\n<blockquote>\n<p>grafana \uac00 \uc678\ubd80\uc5d0 \ub178\ucd9c\ub418\uc5c8\uc73c\ubbc0\ub85c,<br \/>\n\ucd94\uac00\uc801\uc778 \ubcf4\uc548\uc124\uc815\uc774 \ud544\uc694\ud569\ub2c8\ub2e4.<\/p>\n<\/blockquote>\n<p>grafana \uc811\uc18d \ud6c4 \uc88c\uce21\uba54\ub274 &gt; Dashboards &gt; browse &gt; Defaults \uc5d0 \uc811\uc18d\ud558\uba74,<br \/>\n\uc774\ubbf8 \uc124\uce58\ub418\uc5b4 \uc788\ub294 \ub9ce\uc740 Dashboards \ub97c \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>\ud37c\uc2dc\uc2a4\ud134\ud2b8\ubcfc\ub968(PV) \uc0dd\uc131<\/h2>\n<p>\ub370\uc774\ud0c0\uac00 Pod \ub0b4\uc5d0 \uc800\uc7a5\ub418\ubbc0\ub85c,<br \/>\nPod \uac00 \uc0ad\uc81c\ub418\uc5c8\uc744 \ub54c \ub370\uc774\ud0c0\ub3c4 \uac19\uc774 \uc0ac\ub77c\uc9d1\ub2c8\ub2e4.<br \/>\n<del>\uc774\ub97c \ubc29\uc9c0\ud558\uae30 \uc704\ud574 PV \uc0dd\uc131\uc774 \ud544\uc694\ud569\ub2c8\ub2e4.<\/del><\/p>\n<p>\uc77c\ub2e8\uc740 Prometheus \uac00 \uc774\uc911\ud654\ub418\uc5b4 \uac00\ub3d9\ub418\uace0,<br \/>\nGrafana \uc5d0\ub294 \ube44\ubc00\ubc88\ud638\ub97c \uc81c\uc678\ud558\uace0 \uadf8\ub2e5 \uc800\uc7a5\ub418\ub294 \uc815\ubcf4\uac00 \uc5c6\uc5b4\uc11c skip \ud569\ub2c8\ub2e4.<\/p>\n<h2>Grafana \ucd94\uac00\uc124\uc815<\/h2>\n<p>\uc88c\uce21\uba54\ub274 &gt; Configuration &gt; Preferences &gt; Timezone \uc744 Browser time \uc73c\ub85c \uc124\uc815\ud558\uba74,<br \/>\n\uc2dc\uac04\ub300\uac00 KST \uac00 \ub429\ub2c8\ub2e4.<br \/>\n\uac01\uac01\uc758 \ub300\uc2dc\ubcf4\ub4dc\uc5d0 \uc2dc\uac04\ub300\ub97c \uc124\uc815\ud558\uac8c \ub418\uc5b4 \uc788\uc73c\uba74,<br \/>\n\uac01\uac01\uc758 \ub300\uc2dc\ubcf4\ub4dc \uc124\uc815\uc744 \uc218\uc815\ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<h2>uninstall<\/h2>\n<pre><code class=\"language-bash\">kubectl delete --ignore-not-found=true -f manifests\/ -f manifests\/setup<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Kubernetes &#8211; Prometheus\/Grafana \uc124\uce58 kube-prometheus \ub97c \uc774\uc6a9\ud558\uc5ec Prometheus\/Grafana \ub97c \ub3d9\uc2dc\uc5d0 \uc124\uce58\ud569\ub2c8\ub2e4. Prometheus\/Grafana \uc124\uc815\uc774 \ubaa8\ub450 \ub05d\ub098 \uc788\uc5b4\uc11c \ud3b8\ub9ac\ud558\uac8c \uc0ac\uc6a9\uac00\ub2a5\ud569\ub2c8\ub2e4. \uc124\uce58 git clone https:\/\/github.com\/coreos\/kube-prometheus.git cd kube-prometheus\/ # Create the namespace and CRDs, and then wait for them to be available before creating the remaining resources # Note that due to some CRD size we are using kubectl\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6800\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-6800","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6800"}],"version-history":[{"count":7,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6800\/revisions"}],"predecessor-version":[{"id":7306,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6800\/revisions\/7306"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}