-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add agent for collecting information
- Loading branch information
1 parent
a73817f
commit d25fd2a
Showing
20 changed files
with
755 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v2 | ||
name: ledger-agent | ||
description: A Helm chart for Kubernetes | ||
type: application | ||
version: 0.3.0 | ||
appVersion: 1.0.0 | ||
maintainers: | ||
- email: [email protected] | ||
name: Stenic | ||
icon: https://raw.githubusercontent.com/stenic/ledger/gh-pages/images/logo.png | ||
home: https://github.com/stenic/ledger/tree/main/charts/ledger | ||
sources: | ||
- https://github.com/stenic/ledger | ||
keywords: | ||
- deployment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "ledger-agent.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "ledger-agent.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "ledger-agent.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "ledger-agent.labels" -}} | ||
helm.sh/chart: {{ include "ledger-agent.chart" . }} | ||
{{ include "ledger-agent.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "ledger-agent.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "ledger-agent.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "ledger-agent.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "ledger-agent.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "ledger-agent.fullname" . }} | ||
labels: | ||
{{- include "ledger-agent.labels" . | nindent 4 }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
{{- include "ledger-agent.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
labels: | ||
{{- include "ledger-agent.selectorLabels" . | nindent 8 }} | ||
spec: | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "ledger-agent.serviceAccountName" . }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 12 }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
args: [ "agent" ] | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
env: | ||
- name: LEDGER_ENDPOINT | ||
valueFrom: | ||
secretKeyRef: | ||
key: endpoint | ||
name: {{ include "ledger-agent.fullname" . }} | ||
- name: TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
key: token | ||
name: {{ include "ledger-agent.fullname" . }} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "ledger-agent.fullname" . }} | ||
labels: | ||
{{- include "ledger-agent.labels" . | nindent 4 }} | ||
rules: | ||
- apiGroups: | ||
- "apps" | ||
resources: | ||
- deployments | ||
- statefulsets | ||
verbs: | ||
- list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ include "ledger-agent.fullname" . }} | ||
labels: | ||
{{- include "ledger-agent.labels" . | nindent 4 }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ include "ledger-agent.fullname" . }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "ledger-agent.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
type: Opaque | ||
metadata: | ||
name: {{ include "ledger-agent.fullname" . }} | ||
labels: | ||
{{- include "ledger-agent.labels" . | nindent 4 }} | ||
data: | ||
endpoint: {{ .Values.ledgerAgent.endpoint | b64enc }} | ||
token: {{ .Values.ledgerAgent.token | b64enc }} | ||
log-level: {{ .Values.ledgerAgent.log.level | b64enc }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- if .Values.serviceAccount.create -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "ledger-agent.serviceAccountName" . }} | ||
labels: | ||
{{- include "ledger-agent.labels" . | nindent 4 }} | ||
{{- with .Values.serviceAccount.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Default values for ledger. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
# replicaCount -- Desired number of pods | ||
replicaCount: 2 | ||
|
||
image: | ||
# image.repository -- ledger image repository | ||
repository: ghcr.io/stenic/ledger | ||
# image.pullPolicy -- ledger image pullPolicy | ||
pullPolicy: Always | ||
# image.tag -- ledger image tag (immutable tags are recommended) | ||
# Overrides the image tag whose default is the chart appVersion. | ||
tag: "" | ||
|
||
# imagePullSecrets -- Docker registry secret names as an array | ||
imagePullSecrets: [] | ||
# nameOverride -- String to partially override fullname | ||
nameOverride: "" | ||
# fullnameOverride -- String to fully override fullname | ||
fullnameOverride: "" | ||
|
||
serviceAccount: | ||
# serviceAccount.create -- Specifies whether a ServiceAccount should be created | ||
create: true | ||
# Annotations to add to the service account | ||
annotations: {} | ||
# serviceAccount.name -- The name of the ServiceAccount to use. | ||
# If not set and create is true, a name is generated using the fullname template | ||
name: "" | ||
|
||
# podAnnotations -- Additional annotations for the pods. | ||
podAnnotations: {} | ||
|
||
# podSecurityContext -- Enable Controller pods' Security Context | ||
podSecurityContext: {} | ||
# fsGroup: 2000 | ||
|
||
# securityContext -- Enable Controller containers' Security Context | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
runAsNonRoot: true | ||
readOnlyRootFilesystem: true | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsUser: 100012 | ||
runAsGroup: 100012 | ||
|
||
# resources -- Resource requests and limits for the controller | ||
resources: | ||
limits: | ||
cpu: 200m | ||
memory: 64Mi | ||
requests: | ||
cpu: 50m | ||
memory: 64Mi | ||
|
||
# nodeSelector -- Node labels for controller pod assignment | ||
nodeSelector: {} | ||
|
||
# affinity -- Affinity and anti-affinity | ||
affinity: {} | ||
|
||
# tolerations -- Node tolerations for server scheduling to nodes with taints | ||
tolerations: [] | ||
|
||
ledgerAgent: | ||
endpoint: ledger | ||
token: test | ||
log: | ||
level: info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/stenic/ledger/internal/agent" | ||
"github.com/stenic/ledger/internal/pkg/utils/env" | ||
) | ||
|
||
func NewAgentCmd() *cobra.Command { | ||
var ( | ||
endpoint string | ||
) | ||
|
||
cmd := &cobra.Command{ | ||
Use: "agent", | ||
Short: "Ledger cluster agent", | ||
Run: func(c *cobra.Command, args []string) { | ||
agent.Run(endpoint) | ||
}, | ||
} | ||
|
||
cmd.Flags().StringVar(&endpoint, "endpoint", env.GetString("LEDGER_ENDPOINT", "http://127.0.0.1:8080"), "Ledger endpoint url") | ||
|
||
return cmd | ||
} | ||
|
||
func init() { | ||
rootCommand.AddCommand(NewAgentCmd()) | ||
} |
Oops, something went wrong.