Skip to content

Commit

Permalink
Merge pull request #26 from truefoundry/new-tfy-agent
Browse files Browse the repository at this point in the history
New tfy agent
  • Loading branch information
dunefro authored May 24, 2023
2 parents 83960ce + e7b21c4 commit f6718d1
Show file tree
Hide file tree
Showing 15 changed files with 548 additions and 352 deletions.
23 changes: 23 additions & 0 deletions charts/tfy-agent/.helmignore
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/
24 changes: 21 additions & 3 deletions charts/tfy-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
apiVersion: v2
name: tfy-agent
description: Truefoundry workload agent for k8s clusters

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.1
description: "Truefoundry agent for kubernetes clusters"
maintainers:
- name: truefoundry

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
28 changes: 28 additions & 0 deletions charts/tfy-agent/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
______________________________________
( Hello, kubernetes. I will connect to )
( your control plane. Thanks for )
( installing !!! )
--------------------------------------
o , ,
o /( )`
o \ \___ / |
/- _ `-/ '
(/\/ \ \ /\
/ / | ` \
O O ) / |
`-^--'`< '
(_.) _ ) /
`.___/` /
`-----' /
<----. __ / __ \
<----|====O)))==) \) /====
<----' `--' `.__,' \
| |
\ /
______( (_ / \______
,' ,-----' | \
`--{__________) \/
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "tfy-agent.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
125 changes: 47 additions & 78 deletions charts/tfy-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "app.name" -}}
{{- define "tfy-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 "app.fullname" -}}
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 "tfy-agent.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -24,106 +24,75 @@ Expand the name of the chart.
{{- end }}

{{/*
Define full name for tfy-agent-proxy
Create a default fully qualified tfy-agent-proxy name
*/}}
{{- define "app.tfyAgentProxy.fullname" -}}
{{- include "app.fullname" . | trunc 57 | trimSuffix "-" }}-proxy
{{- define "tfy-agent-proxy.fullname" -}}
{{- include "tfy-agent.fullname" . | trunc 57 | trimSuffix "-" }}-proxy
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "app.chart" -}}
Create chart name and version as used by the chart label.
*/}}
{{- define "tfy-agent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "app.labels" -}}
helm.sh/chart: {{ include "app.chart" . }}
{{ include "app.selectorLabels" . }}
{{- if .Values.imageTag }}
app.kubernetes.io/version: {{ .Values.imageTag | quote }}
Common labels
*/}}
{{- define "tfy-agent.labels" -}}
helm.sh/chart: {{ include "tfy-agent.chart" . }}
{{ include "tfy-agent.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "app.selectorLabels" -}}
app.kubernetes.io/name: {{ include "app.name" . }}
Selector labels for tfyAgent
*/}}
{{- define "tfy-agent.selectorLabels" -}}
app.kubernetes.io/name: {{ include "tfy-agent.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "app.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "app.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Common labels
*/}}
{{- define "tfy-agent-proxy.labels" -}}
helm.sh/chart: {{ include "tfy-agent.chart" . }}
{{ include "tfy-agent-proxy.selectorLabels" . }}
app.kubernetes.io/version: {{ .Values.tfyAgentProxy.imageTag | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Parse env from template
*/}}
{{- define "app.parseEnv" -}}
{{ tpl (.Values.env | toYaml) . }}
Selector labels for tfyAgentProxy
*/}}
{{- define "tfy-agent-proxy.selectorLabels" -}}
app.kubernetes.io/name: {{ include "tfy-agent-proxy.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{/*
Create the env file
*/}}
{{- define "app.env" }}
{{- range $key, $val := (include "app.parseEnv" .) | fromYaml }}
{{- if and $val (contains "${k8s-secret" ($val | toString)) }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ $.Values.envSecretName }}
key: {{ $val | trimPrefix "${k8s-secret/" | trimSuffix "}" }}
Create the name of the service account to use
*/}}
{{- define "tfy-agent.serviceAccountName" -}}
{{- if .Values.tfyAgent.serviceAccount.create }}
{{- default (include "tfy-agent.fullname" .) .Values.tfyAgent.serviceAccount.name }}
{{- else }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- default "default" .Values.tfyAgent.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Parse env from template
*/}}
{{- define "app.tfyAgentProxy.parseEnv" -}}
{{ tpl (.Values.tfyAgentProxy.env | toYaml) . }}
{{- end }}

{{/*
Create the env file
*/}}
{{- define "app.tfyAgentProxy.env" }}
{{- range $key, $val := (include "app.tfyAgentProxy.parseEnv" .) | fromYaml }}
{{- if and $val (contains "${k8s-secret" ($val | toString)) }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ $.Values.envSecretName }}
key: {{ $val | trimPrefix "${k8s-secret/" | trimSuffix "}" }}
Create the name of the secret which will contain cluster token
*/}}
{{- define "tfy-agent.secretName" -}}
{{- if .Values.config.clusterTokenSecret }}
{{- .Values.config.clusterTokenSecret }}
{{- else }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- include "tfy-agent.fullname" . | trunc 57 | trimSuffix "-" }}-token
{{- end }}
{{- end }}
{{- end }}

# {{- define "app.imagePullSecrets" }}
# {{- if (tpl .Values.imagePullCredentials .) }}
# - name: {{ include "app.fullname" . }}-image-pull-secret
# {{- end }}
# {{- if (tpl .Values.imagePullSecretName .) }}
# - name: {{ tpl .Values.imagePullSecretName . }}
# {{- end }}
# {{- end }}
6 changes: 3 additions & 3 deletions charts/tfy-agent/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{- if .Values.rbac.enabled -}}
{{- if .Values.global.rbac.enabled -}}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "app.fullname" . }}-admin-rbac
name: {{ include "tfy-agent.fullname" . }}-admin-rbac
subjects:
- kind: ServiceAccount
name: {{ include "app.serviceAccountName" . }}
name: {{ include "tfy-agent.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
Expand Down
34 changes: 0 additions & 34 deletions charts/tfy-agent/templates/deployment-tfy-agent-proxy.yaml

This file was deleted.

63 changes: 0 additions & 63 deletions charts/tfy-agent/templates/deployment.yaml

This file was deleted.

Loading

0 comments on commit f6718d1

Please # to comment.