From 16a32d06cd2c6ac6e8f2fef1f5a4a83024cf4802 Mon Sep 17 00:00:00 2001 From: Xuelin Yang Date: Mon, 23 Mar 2026 21:42:31 +0800 Subject: [PATCH] examples/kustomize-simple: add k8s manifests --- examples/README.md | 5 ++++ examples/kustomize-simple/README.md | 25 ++++++++++++++++ examples/kustomize-simple/dashboard.json | 1 + examples/kustomize-simple/deployment.yaml | 30 ++++++++++++++++++++ examples/kustomize-simple/kustomization.yaml | 21 ++++++++++++++ examples/kustomize-simple/monitor.yaml | 10 +++++++ examples/kustomize-simple/service.yaml | 14 +++++++++ 7 files changed, 106 insertions(+) create mode 100644 examples/kustomize-simple/README.md create mode 100644 examples/kustomize-simple/dashboard.json create mode 100644 examples/kustomize-simple/deployment.yaml create mode 100644 examples/kustomize-simple/kustomization.yaml create mode 100644 examples/kustomize-simple/monitor.yaml create mode 100644 examples/kustomize-simple/service.yaml diff --git a/examples/README.md b/examples/README.md index a4b3f86..0ba19b6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,11 +6,16 @@ An example how to setup endlessh-go, Prometheus, and Grafana using [docker compose](https://docs.docker.com/compose/). +## [kustomize-simple](./kustomize-simple) + +An example how to setup endlessh-go using [kustomize](https://kustomize.io/). + ## [docker-maxmind](./docker-maxmind) An example how to setup endlessh-go with the Maxmind GeoIP Database. ## FAQ + ### Bind to privileged ports (<1024) in a container You need to add capability `NET_BIND_SERVICE` to the program. diff --git a/examples/kustomize-simple/README.md b/examples/kustomize-simple/README.md new file mode 100644 index 0000000..379bbdc --- /dev/null +++ b/examples/kustomize-simple/README.md @@ -0,0 +1,25 @@ +## kustomize + +This is an example how to setup endlessh-go with existing Prometheus and Grafana using [kustomize](https://kustomize.io/). + +This example assumes the cluster already has a Prometheus Operator based monitoring stack. It deploys: + +- endlessh-go +- a Service exposing SSH and Prometheus metrics +- a `ServiceMonitor` for scraping endlessh-go metrics +- a Grafana dashboard `ConfigMap` + +To deploy the stack, run: + +```bash +kubectl apply -k examples/kustomize-simple +``` + +`dashboard.json` is added to a `ConfigMap` with label `grafana_dashboard=1`, which can be picked up by a Grafana sidecar based dashboard loader. + +The `ServiceMonitor` in `monitor.yaml` scrapes the `metrics` port every `60s`. If your Prometheus stack only selects `ServiceMonitor` objects with specific labels, add the matching label in `kustomization.yaml`. + +The `endlessh` Service exposes the following ports inside the cluster: + +- **22**: SSH for endlessh-go +- **2112**: Prometheus metrics exported by endlessh-go diff --git a/examples/kustomize-simple/dashboard.json b/examples/kustomize-simple/dashboard.json new file mode 100644 index 0000000..4af19ef --- /dev/null +++ b/examples/kustomize-simple/dashboard.json @@ -0,0 +1 @@ +{"annotations":{"list":[{"builtIn":1,"datasource":{"type":"datasource","uid":"grafana"},"enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","target":{"limit":100,"matchAny":false,"tags":[],"type":"dashboard"},"type":"dashboard"}]},"description":"Dashboard for endlessh (Add ports selection)","editable":true,"fiscalYearStartMonth":0,"graphTooltip":0,"id":40,"links":[{"asDropdown":false,"icon":"external link","includeVars":false,"keepTime":false,"tags":[],"targetBlank":true,"title":"GitHub","tooltip":"GitHub","type":"link","url":"https://github.com/shizunge/endlessh-go"},{"asDropdown":false,"icon":"external link","includeVars":false,"keepTime":false,"tags":[],"targetBlank":true,"title":"Grafana","tooltip":"Grafana Dashboard","type":"link","url":"https://grafana.com/grafana/dashboards/15156"}],"panels":[{"datasource":{"type":"prometheus","uid":"prometheus"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0}]}},"overrides":[]},"gridPos":{"h":3,"w":4,"x":0,"y":0},"id":36,"interval":"1m","maxDataPoints":1440,"options":{"colorMode":"value","graphMode":"none","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"/^Total number connections that endlessh trapped$/","values":false},"showPercentChange":false,"text":{},"textMode":"auto","wideLayout":true},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"prometheus","uid":"${DS_PROMETHEUS}"},"editorMode":"code","expr":"(endlessh_client_open_count{instance=~\"$host\", local_port=~\"$port\",job=~\"$job\"} - endlessh_client_open_count{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"} offset $__interval) > 0 or (endlessh_client_open_count{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"}!=0 unless endlessh_client_open_count{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"} offset $__interval)","format":"table","instant":false,"legendFormat":"Seen {{ip}}","range":true,"refId":"Seen"},{"datasource":{"type":"prometheus","uid":"${DS_PROMETHEUS}"},"editorMode":"code","expr":"(endlessh_client_trapped_time_seconds{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"} - endlessh_client_trapped_time_seconds{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"} offset $__interval) > 0 or (endlessh_client_trapped_time_seconds{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"}!=0 unless endlessh_client_trapped_time_seconds{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"} offset $__interval)","format":"table","hide":false,"instant":false,"legendFormat":"Trapped {{ip}}","range":true,"refId":"Trapped"}],"title":"Connections","transformations":[{"id":"filterByRefId","options":{"include":"Seen"}},{"id":"filterByValue","options":{"filters":[{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Value #Seen"}],"match":"any","type":"include"}},{"id":"groupBy","options":{"fields":{"Value #Seen":{"aggregations":["sum"],"operation":"aggregate"},"ip":{"aggregations":[],"operation":"groupby"}}}},{"id":"reduce","options":{"includeTimeField":false,"labelsToFields":false,"mode":"reduceFields","reducers":["sum"]}},{"id":"organize","options":{"excludeByName":{},"indexByName":{},"renameByName":{"Value #Seen (sum)":"Total number connections that endlessh trapped"}}}],"type":"stat"},{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0}]},"unit":"s"},"overrides":[]},"gridPos":{"h":3,"w":4,"x":4,"y":0},"id":42,"options":{"colorMode":"value","graphMode":"none","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"/^Time spent on endlessh$/","values":false},"showPercentChange":false,"text":{},"textMode":"auto","wideLayout":true},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"panelId":36,"refId":"A"}],"title":"Trapped Time","transformations":[{"id":"filterByRefId","options":{"include":"Trapped"}},{"id":"filterByValue","options":{"filters":[{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Value #Trapped"}],"match":"all","type":"include"}},{"id":"groupBy","options":{"fields":{"Value #Trapped":{"aggregations":["sum"],"operation":"aggregate"},"ip":{"aggregations":[],"operation":"groupby"}}}},{"id":"reduce","options":{"includeTimeField":false,"labelsToFields":false,"mode":"reduceFields","reducers":["sum"]}},{"id":"organize","options":{"excludeByName":{},"indexByName":{},"renameByName":{"Total":"Seconds spent on endlessh","Value #Trapped (sum)":"Time spent on endlessh"}}}],"type":"stat"},{"datasource":{"type":"prometheus","uid":"prometheus"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0}]},"unit":"bytes"},"overrides":[]},"gridPos":{"h":3,"w":4,"x":8,"y":0},"id":18,"options":{"colorMode":"value","graphMode":"none","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{},"textMode":"auto","wideLayout":true},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"prometheus","uid":"${DS_PROMETHEUS}"},"editorMode":"code","exemplar":true,"expr":"sum(increase(endlessh_sent_bytes_total{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"}[$__range]))","hide":false,"interval":"","legendFormat":"Bytes sent by endlessh","range":true,"refId":"sent_bytes"}],"title":"Sent Bytes","type":"stat"},{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0}]}},"overrides":[]},"gridPos":{"h":3,"w":4,"x":12,"y":0},"id":38,"options":{"colorMode":"value","graphMode":"none","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"/^Unique IPs connected$/","values":false},"showPercentChange":false,"text":{},"textMode":"auto","wideLayout":true},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"panelId":36,"refId":"A"}],"title":"Unique IPs","transformations":[{"id":"filterByRefId","options":{"include":"Seen"}},{"id":"groupBy","options":{"fields":{"Value #Seen":{"aggregations":["sum"],"operation":"aggregate"},"ip":{"aggregations":[],"operation":"groupby"}}}},{"id":"reduce","options":{"includeTimeField":false,"labelsToFields":false,"mode":"reduceFields","reducers":["count"]}},{"id":"organize","options":{"excludeByName":{},"indexByName":{},"renameByName":{"Value #Seen (sum)":"Unique IPs connected","ip":""}}}],"type":"stat"},{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"links":[{"targetBlank":true,"title":"whois","url":"https://search.arin.net/rdap/?query=${__value.text}"}],"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0}]}},"overrides":[]},"gridPos":{"h":3,"w":4,"x":16,"y":0},"id":45,"options":{"colorMode":"value","graphMode":"none","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"/^Client IP of the latest connection$/","values":false},"showPercentChange":false,"text":{},"textMode":"value","wideLayout":true},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"panelId":36,"refId":"A"}],"title":"Latest Connection","transformations":[{"id":"filterByRefId","options":{"include":"Seen"}},{"id":"filterByValue","options":{"filters":[{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Value #Seen"}],"match":"any","type":"include"}},{"id":"groupBy","options":{"fields":{"Time":{"aggregations":["lastNotNull"],"operation":"aggregate"},"Value #Seen":{"aggregations":["sum"],"operation":"aggregate"},"ip":{"aggregations":[],"operation":"groupby"}}}},{"id":"sortBy","options":{"fields":{},"sort":[{"field":"Time (lastNotNull)"}]}},{"id":"organize","options":{"excludeByName":{"instance":true,"job":true},"indexByName":{},"renameByName":{"Time (lastNotNull)":"Time","Value #Seen (sum)":"Count","ip":"Client IP of the latest connection"}}}],"type":"stat"},{"datasource":{"type":"prometheus","uid":"prometheus"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"min":0,"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0},{"color":"#EAB839","value":10},{"color":"red","value":20}]},"unit":"short"},"overrides":[]},"gridPos":{"h":3,"w":4,"x":20,"y":0},"id":20,"options":{"colorMode":"value","graphMode":"none","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{},"textMode":"auto","wideLayout":true},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"prometheus","uid":"${DS_PROMETHEUS}"},"editorMode":"code","exemplar":true,"expr":"sum((endlessh_client_open_count_total{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"}) - (endlessh_client_closed_count_total{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"} or endlessh_client_open_count_total{instance=~\"$host\",local_port=~\"$port\",job=~\"$job\"} * 0))","instant":false,"interval":"","legendFormat":"Open Connections","refId":"current_open"}],"title":"Current Connections","type":"stat"},{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"barWidthFactor":0.6,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"stepAfter","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","showValues":false,"spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"min":0,"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0}]}},"overrides":[]},"gridPos":{"h":4,"w":12,"x":0,"y":3},"id":30,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":false},"tooltip":{"hideZeros":false,"mode":"single","sort":"none"}},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"panelId":20,"refId":"A"}],"title":"Concurrent Connections","type":"timeseries"},{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false}},"mappings":[]},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":3},"id":32,"options":{"displayLabels":[],"legend":{"displayMode":"table","placement":"right","showLegend":true,"values":["value","percent"]},"pieType":"pie","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"sort":"desc","tooltip":{"hideZeros":false,"mode":"single","sort":"none"}},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"panelId":36,"refId":"A"}],"title":"Connections by Country","transformations":[{"id":"filterByRefId","options":{"include":"Seen"}},{"id":"filterByValue","options":{"filters":[{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Value #Seen"}],"match":"any","type":"include"}},{"id":"groupBy","options":{"fields":{"Value #Seen":{"aggregations":["sum"],"operation":"aggregate"},"country":{"aggregations":["last"],"operation":"aggregate"},"ip":{"aggregations":[],"operation":"groupby"}}}},{"id":"groupBy","options":{"fields":{"Value #Seen (sum)":{"aggregations":["sum"],"operation":"aggregate"},"country (last)":{"aggregations":[],"operation":"groupby"}}}},{"id":"rowsToFields","options":{}}],"type":"piechart"},{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"fieldConfig":{"defaults":{"color":{"mode":"continuous-GrYlRd"},"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#96D98D","value":0}]}},"overrides":[]},"gridPos":{"h":12,"w":12,"x":0,"y":7},"id":48,"options":{"basemap":{"config":{},"name":"Layer 0","type":"default"},"controls":{"mouseWheelZoom":false,"showAttribution":false,"showDebug":false,"showMeasure":false,"showScale":false,"showZoom":true},"layers":[{"config":{"color":{"field":"Connections","fixed":"dark-green"},"fillOpacity":0.4,"shape":"circle","showLegend":false,"size":{"field":"Connections","fixed":5,"max":10,"min":2},"style":{"color":{"field":"Connections","fixed":"dark-green"},"size":{"field":"Connections","fixed":5,"max":9,"min":2},"text":{"field":"location (lastNotNull) (lastNotNull)","fixed":"","mode":"fixed"}}},"location":{"geohash":"Geohash","mode":"geohash"},"name":"Layer 1","type":"markers"}],"tooltip":{"mode":"details"},"view":{"allLayers":true,"id":"zero","lat":0,"lon":0,"noRepeat":false,"zoom":1}},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"panelId":36,"refId":"A"}],"title":"Locations","transformations":[{"id":"filterByRefId","options":{"include":"Seen"}},{"id":"filterByValue","options":{"filters":[{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Value #Seen"}],"match":"any","type":"include"}},{"id":"groupBy","options":{"fields":{"Value #Seen":{"aggregations":["sum"],"operation":"aggregate"},"geohash":{"aggregations":["lastNotNull"],"operation":"groupby"},"location":{"aggregations":["lastNotNull"],"operation":"aggregate"}}}},{"id":"organize","options":{"excludeByName":{},"indexByName":{"Value #geo (lastNotNull) (sum)":2,"geohash (lastNotNull)":0,"location (lastNotNull) (lastNotNull)":1},"renameByName":{"Value #Seen (sum)":"Connections","geohash":"Geohash","location (lastNotNull)":"Location"}}}],"type":"geomap"},{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"custom":{"align":"auto","cellOptions":{"type":"auto"},"filterable":true,"footer":{"reducers":[]},"inspect":false,"minWidth":50},"links":[],"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0}]}},"overrides":[{"matcher":{"id":"byName","options":"Last Connection"},"properties":[{"id":"custom.minWidth","value":150},{"id":"unit","value":"dateTimeAsIso"},{"id":"custom.align","value":"left"}]},{"matcher":{"id":"byName","options":"IP"},"properties":[{"id":"links","value":[{"targetBlank":true,"title":"search ARIN","url":"https://search.arin.net/rdap/?query=${__data.fields.IP}"}]}]},{"matcher":{"id":"byName","options":"Trapped Time"},"properties":[{"id":"unit","value":"s"}]}]},"gridPos":{"h":8,"w":12,"x":12,"y":11},"id":49,"options":{"cellHeight":"sm","frameIndex":0,"showHeader":true,"sortBy":[{"desc":true,"displayName":"Last Connection"}]},"pluginVersion":"12.3.1","targets":[{"datasource":{"type":"datasource","uid":"-- Dashboard --"},"panelId":36,"refId":"A"}],"title":"Clients","transformations":[{"id":"filterByValue","options":{"filters":[{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Value #Seen"},{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Value #Trapped"}],"match":"any","type":"include"}},{"id":"merge","options":{}},{"id":"calculateField","options":{"alias":"Seen","mode":"reduceRow","reduce":{"include":["Value #Seen"],"reducer":"sum"}}},{"id":"calculateField","options":{"alias":"Trapped","mode":"reduceRow","reduce":{"include":["Value #Trapped"],"reducer":"sum"}}},{"id":"filterByValue","options":{"filters":[{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Seen"},{"config":{"id":"greaterOrEqual","options":{"value":0}},"fieldName":"Trapped"}],"match":"all","type":"include"}},{"id":"groupBy","options":{"fields":{"Seen":{"aggregations":["sum"],"operation":"aggregate"},"Time":{"aggregations":["max"],"operation":"aggregate"},"Trapped":{"aggregations":["sum"],"operation":"aggregate"},"country":{"aggregations":["lastNotNull"],"operation":"aggregate"},"ip":{"aggregations":[],"operation":"groupby"}}}},{"id":"filterByValue","options":{"filters":[{"config":{"id":"isNull","options":{}},"fieldName":"ip"}],"match":"any","type":"exclude"}},{"id":"organize","options":{"excludeByName":{},"indexByName":{"Seen (sum)":3,"Time (max)":0,"Trapped (sum)":4,"country (lastNotNull)":2,"ip":1},"renameByName":{"Seen (sum)":"Connections","Time (max)":"Last Connection","Trapped (sum)":"Trapped Time","country (lastNotNull)":"Country","ip":"IP"}}}],"type":"table"}],"preload":false,"refresh":"","schemaVersion":42,"tags":["prometheus"],"templating":{"list":[{"allValue":".*","current":{},"datasource":{"type":"prometheus","uid":"prometheus"},"definition":"label_values(endlessh_client_open_count_total, job)","includeAll":true,"label":"Job","multi":true,"name":"job","options":[],"query":{"query":"label_values(endlessh_client_open_count_total, job)","refId":"StandardVariableQuery"},"refresh":2,"regex":"","sort":1,"type":"query"},{"allValue":".*","current":{},"datasource":{"type":"prometheus","uid":"prometheus"},"definition":"label_values(endlessh_client_open_count_total{job=~\"$job\"}, instance)","includeAll":true,"label":"Host","multi":true,"name":"host","options":[],"query":{"query":"label_values(endlessh_client_open_count_total{job=~\"$job\"}, instance)","refId":"StandardVariableQuery"},"refresh":2,"regex":"","sort":1,"type":"query"},{"allValue":".*","current":{},"definition":"label_values(endlessh_client_open_count_total{job=~\"$job\", instance=~\"$host\"},local_port)","description":"","includeAll":true,"label":"Port","multi":true,"name":"port","options":[],"query":{"qryType":1,"query":"label_values(endlessh_client_open_count_total{job=~\"$job\", instance=~\"$host\"},local_port)","refId":"PrometheusVariableQueryEditor-VariableQuery"},"refresh":2,"regex":"","sort":1,"type":"query"}]},"time":{"from":"now-24h","to":"now"},"timepicker":{},"timezone":"","title":"Endlessh","uid":"ATIxYkO7k","version":1} \ No newline at end of file diff --git a/examples/kustomize-simple/deployment.yaml b/examples/kustomize-simple/deployment.yaml new file mode 100644 index 0000000..9e1cc0f --- /dev/null +++ b/examples/kustomize-simple/deployment.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: endlessh +spec: + replicas: 1 + template: + spec: + automountServiceAccountToken: false + containers: + - name: endlessh + image: shizunge/endlessh-go:latest + args: + - -interval_ms=1000 + - -logtostderr + - -v=1 + - -enable_prometheus + - -geoip_supplier=ip-api + - -host=[::] + - -prometheus_host=[::] + ports: + - name: ssh + containerPort: 2222 + - name: metrics + containerPort: 2112 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL diff --git a/examples/kustomize-simple/kustomization.yaml b/examples/kustomize-simple/kustomization.yaml new file mode 100644 index 0000000..590ab47 --- /dev/null +++ b/examples/kustomize-simple/kustomization.yaml @@ -0,0 +1,21 @@ +resources: + - deployment.yaml + - service.yaml + - monitor.yaml +configMapGenerator: + - name: endlessh-dashboard + files: + - dashboard.json + options: + labels: + grafana_dashboard: "1" +labels: + - pairs: + app.kubernetes.io/name: endlessh + includeSelectors: true + includeTemplates: true + fields: + - group: monitoring.coreos.com + kind: ServiceMonitor + path: spec/selector/matchLabels + create: true diff --git a/examples/kustomize-simple/monitor.yaml b/examples/kustomize-simple/monitor.yaml new file mode 100644 index 0000000..e172c84 --- /dev/null +++ b/examples/kustomize-simple/monitor.yaml @@ -0,0 +1,10 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: endlessh +spec: + endpoints: + - interval: 60s + path: /metrics + port: metrics + jobLabel: app.kubernetes.io/name diff --git a/examples/kustomize-simple/service.yaml b/examples/kustomize-simple/service.yaml new file mode 100644 index 0000000..50d686f --- /dev/null +++ b/examples/kustomize-simple/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: endlessh +spec: + ports: + - name: ssh + port: 22 + targetPort: ssh + protocol: TCP + - name: metrics + port: 2112 + targetPort: metrics + protocol: TCP