Add teleport agent update

This commit is contained in:
Jonny Ervine
2024-08-15 22:45:43 +08:00
parent c0d65a0afb
commit b76e232ac2
143 changed files with 15355 additions and 676 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ To do so, you can use the following Teleport Role resource:
kind: role
metadata:
name: gke-kube-access
version: v6
version: v7
spec:
allow:
kubernetes_labels:
+46 -15
View File
@@ -1,5 +1,8 @@
{{- define "teleport-kube-agent.config" -}}
{{- $logLevel := (coalesce .Values.logLevel .Values.log.level "INFO") -}}
{{- $appRolePresent := contains "app" (.Values.roles | toString) -}}
{{- $discoveryEnabled := contains "discovery" (.Values.roles | toString) -}}
{{- $appDiscoveryEnabled := and ($appRolePresent) ($discoveryEnabled) -}}
{{- if (ge (include "teleport-kube-agent.version" . | semver).Major 11) }}
version: v3
{{- end }}
@@ -13,7 +16,7 @@ teleport:
auth_servers: ["{{ required "proxyAddr is required in chart values" .Values.proxyAddr }}"]
{{- end }}
{{- if .Values.caPin }}
ca_pin: {{- toYaml .Values.caPin | nindent 8 }}
ca_pin: {{- toYaml .Values.caPin | nindent 4 }}
{{- end }}
log:
severity: {{ $logLevel }}
@@ -27,18 +30,22 @@ kubernetes_service:
enabled: true
kube_cluster_name: {{ required "kubeClusterName is required in chart values when kube role is enabled, see README" .Values.kubeClusterName }}
{{- if .Values.labels }}
labels: {{- toYaml .Values.labels | nindent 8 }}
labels: {{- toYaml .Values.labels | nindent 4 }}
{{- end }}
{{- else }}
enabled: false
{{- end }}
{{- if and (or (.Values.apps) (.Values.appResources)) (not ($appRolePresent)) }}
{{- fail "app role should be enabled if one of 'apps' or 'appResources' is set, see README" }}
{{- end }}
app_service:
{{- if contains "app" (.Values.roles | toString) }}
{{- if $appRolePresent }}
{{- if not (or (.Values.apps) (.Values.appResources) ($appDiscoveryEnabled)) }}
{{- fail "app service is enabled, but no application source is enabled. You must either statically define apps through `apps`, dynamically through `appResources`, or enable in-cluster discovery." }}
{{- end }}
enabled: true
{{- if not (or (.Values.apps) (.Values.appResources)) }}
{{- fail "at least one of 'apps' and 'appResources' is required in chart values when app role is enabled, see README" }}
{{- end }}
{{- if .Values.apps }}
{{- range $app := .Values.apps }}
{{- if not (hasKey $app "name") }}
@@ -49,12 +56,17 @@ app_service:
{{- end }}
{{- end }}
apps:
{{- toYaml .Values.apps | nindent 8 }}
{{- end }}
{{- if .Values.appResources }}
{{- toYaml .Values.apps | nindent 4 }}
{{- end }}
resources:
{{- toYaml .Values.appResources | nindent 8 }}
{{- end }}
{{- if .Values.appResources }}
{{- toYaml .Values.appResources | nindent 4 }}
{{- end }}
{{- if $appDiscoveryEnabled }}
- labels:
"teleport.dev/kubernetes-cluster": "{{ required "kubeClusterName is required in chart values when kube or discovery role is enabled, see README" .Values.kubeClusterName }}"
"teleport.dev/origin": "discovery-kubernetes"
{{- end }}
{{- else }}
enabled: false
{{- end }}
@@ -78,11 +90,11 @@ db_service:
{{- fail "'tags' is required for all 'awsDatabases' in chart values when key is set and db role is enabled, see README" }}
{{- end }}
{{- end }}
{{- toYaml .Values.awsDatabases | nindent 6 }}
{{- toYaml .Values.awsDatabases | nindent 4 }}
{{- end }}
{{- if .Values.azureDatabases }}
azure:
{{- toYaml .Values.azureDatabases | nindent 6 }}
{{- toYaml .Values.azureDatabases | nindent 4 }}
{{- end}}
{{- if .Values.databases }}
databases:
@@ -97,16 +109,35 @@ db_service:
{{- fail "'protocol' is required for all 'databases' in chart values when db role is enabled, see README" }}
{{- end }}
{{- end }}
{{- toYaml .Values.databases | nindent 6 }}
{{- toYaml .Values.databases | nindent 4 }}
{{- end }}
{{- if .Values.databaseResources }}
resources:
{{- toYaml .Values.databaseResources | nindent 6 }}
{{- toYaml .Values.databaseResources | nindent 4 }}
{{- end }}
{{- else }}
enabled: false
{{- end }}
discovery_service:
{{- if $discoveryEnabled }}
enabled: true
discovery_group: {{ required "kubeClusterName is required in chart values when kube or discovery role is enabled, see README" .Values.kubeClusterName }}
kubernetes: {{- toYaml .Values.kubernetesDiscovery | nindent 4 }}
{{- else }}
enabled: false
{{- end }}
jamf_service:
{{- if contains "jamf" (.Values.roles | toString) }}
enabled: true
api_endpoint: {{ required "jamfApiEndpoint is required in chart values when jamf role is enabled, see README" .Values.jamfApiEndpoint }}
client_id: {{ required "jamfClientId is required in chart values when jamf role is enabled, see README" .Values.jamfClientId }}
client_secret_file: "/etc/teleport-jamf-api-credentials/credential"
{{- else }}
enabled: false
{{- end }}
auth_service:
enabled: false
ssh_service:
+5 -1
View File
@@ -22,7 +22,11 @@ Create the name of the service account to use for the post-delete hook
if serviceAccount is not defined or serviceAccount.name is empty, use .Release.Name-delete-hook
*/}}
{{- define "teleport-kube-agent.deleteHookServiceAccountName" -}}
{{- coalesce .Values.serviceAccount.name .Values.serviceAccountName (printf "%s-delete-hook" .Release.Name) -}}
{{- if .Values.serviceAccount.create -}}
{{- printf "%s-delete-hook" (include "teleport-kube-agent.serviceAccountName" . ) -}}
{{- else -}}
{{- (include "teleport-kube-agent.serviceAccountName" . ) -}}
{{- end -}}
{{- end -}}
{{- define "teleport-kube-agent.version" -}}
@@ -16,6 +16,14 @@ rules:
- serviceaccounts
verbs:
- impersonate
{{- if contains "discovery" (.Values.roles | toString) }}
- apiGroups:
- ""
resources:
- services
verbs:
- list
{{- end}}
- apiGroups:
- ""
resources:
+17 -1
View File
@@ -8,6 +8,10 @@ metadata:
"helm.sh/hook": post-delete
"helm.sh/hook-weight": "-4"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- if .Values.extraLabels.serviceAccount }}
labels:
{{- toYaml .Values.extraLabels.serviceAccount | nindent 4 }}
{{- end }}
---
{{- end }}
{{- if .Values.rbac.create }}
@@ -20,6 +24,10 @@ metadata:
"helm.sh/hook": post-delete
"helm.sh/hook-weight": "-3"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- if .Values.extraLabels.role }}
labels:
{{- toYaml .Values.extraLabels.role | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["secrets",]
@@ -34,13 +42,17 @@ metadata:
"helm.sh/hook": post-delete
"helm.sh/hook-weight": "-2"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- if .Values.extraLabels.roleBinding }}
labels:
{{- toYaml .Values.extraLabels.roleBinding | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ .Release.Name }}-delete-hook
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-delete-hook
name: {{ template "teleport-kube-agent.deleteHookServiceAccountName" . }}
namespace: {{ .Release.Namespace }}
---
{{- end }}
@@ -53,6 +65,10 @@ metadata:
"helm.sh/hook": post-delete
"helm.sh/hook-weight": "-1"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- if .Values.extraLabels.job }}
labels:
{{- toYaml .Values.extraLabels.job | nindent 4 }}
{{- end }}
spec:
template:
metadata:
@@ -43,6 +43,9 @@ spec:
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy | quote }}
{{- end }}
{{- if .Values.podSecurityContext }}
securityContext: {{- toYaml .Values.podSecurityContext | nindent 8}}
{{- end }}
{{- if .Values.hostAliases }}
hostAliases: {{- toYaml .Values.hostAliases | nindent 8 }}
{{- end }}
@@ -108,6 +111,11 @@ spec:
name: "teleport-tls-ca"
readOnly: true
{{- end }}
{{- if contains "jamf" (.Values.roles | toString) }}
- mountPath: /etc/teleport-jamf-api-credentials
name: "jamf-api-credentials"
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
{{- end }}
@@ -130,6 +138,12 @@ spec:
{{- if .Values.updater.enabled }}
- name: TELEPORT_EXT_UPGRADER
value: kube
- name: TELEPORT_EXT_UPGRADER_VERSION
value: {{ include "teleport-kube-agent.version" . }}
{{- end }}
{{- if .Values.clusterDomain }}
- name: TELEPORT_KUBE_CLUSTER_DOMAIN
value: {{ .Values.clusterDomain | quote }}
{{- end }}
{{- if (gt (len .Values.extraEnv) 0) }}
{{- toYaml .Values.extraEnv | nindent 8 }}
@@ -187,8 +201,16 @@ spec:
name: "teleport-tls-ca"
readOnly: true
{{- end }}
{{- if contains "jamf" (.Values.roles | toString) }}
- mountPath: /etc/teleport-jamf-api-credentials
name: "jamf-api-credentials"
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.extraContainers }}
{{- toYaml .Values.extraContainers | nindent 6 }}
{{- end }}
volumes:
- name: "config"
@@ -206,6 +228,11 @@ spec:
secret:
secretName: {{ .Values.tls.existingCASecretName }}
{{- end }}
{{- if contains "jamf" (.Values.roles | toString) }}
- name: "jamf-api-credentials"
secret:
secretName: {{ .Values.jamfCredentialsSecret.name }}
{{- end }}
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 6 }}
{{- end }}
+1 -1
View File
@@ -11,4 +11,4 @@ rules:
- apiGroups: [""]
# objects is "secrets"
resources: ["secrets"]
verbs: ["create", "get", "update","patch"]
verbs: ["create", "get", "update", "patch"]
+20
View File
@@ -17,3 +17,23 @@ stringData:
auth-token: |
{{ coalesce .Values.joinParams.tokenName .Values.authToken }}
{{- end}}
{{- if and (contains "jamf" (.Values.roles | toString)) .Values.jamfCredentialsSecret.create }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.jamfCredentialsSecret.name }}
namespace: {{ .Release.Namespace }}
{{- if .Values.extraLabels.secret }}
labels:
{{- toYaml .Values.extraLabels.secret | nindent 4 }}
{{- end }}
{{- if .Values.annotations.secret }}
annotations:
{{- toYaml .Values.annotations.secret | nindent 4 }}
{{- end }}
type: Opaque
stringData:
credential: {{ required "jamfClientSecret is required in chart values when jamf role is enabled, see README" .Values.jamfClientSecret }}
{{- end}}
+23 -2
View File
@@ -42,8 +42,9 @@ spec:
{{- if .Values.hostAliases }}
hostAliases: {{- toYaml .Values.hostAliases | nindent 8 }}
{{- end }}
securityContext:
fsGroup: 9807
{{- if .Values.podSecurityContext }}
securityContext: {{- toYaml .Values.podSecurityContext | nindent 8}}
{{- end }}
{{- if or .Values.affinity (gt (int $replicaCount) 1) }}
affinity:
{{- if .Values.affinity }}
@@ -106,6 +107,11 @@ spec:
name: "teleport-tls-ca"
readOnly: true
{{- end }}
{{- if contains "jamf" (.Values.roles | toString) }}
- mountPath: /etc/teleport-jamf-api-credentials
name: "jamf-api-credentials"
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
{{- end }}
@@ -142,6 +148,8 @@ spec:
{{- if .Values.updater.enabled }}
- name: TELEPORT_EXT_UPGRADER
value: kube
- name: TELEPORT_EXT_UPGRADER_VERSION
value: {{ include "teleport-kube-agent.version" . }}
{{- end }}
{{- if .Values.tls.existingCASecretName }}
- name: SSL_CERT_FILE
@@ -204,8 +212,16 @@ spec:
name: "teleport-tls-ca"
readOnly: true
{{- end }}
{{- if contains "jamf" (.Values.roles | toString) }}
- mountPath: /etc/teleport-jamf-api-credentials
name: "jamf-api-credentials"
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.extraContainers }}
{{- toYaml .Values.extraContainers | nindent 6 }}
{{- end }}
volumes:
- name: "config"
@@ -223,6 +239,11 @@ spec:
secret:
secretName: {{ .Values.tls.existingCASecretName }}
{{- end }}
{{- if contains "jamf" (.Values.roles | toString) }}
- name: "jamf-api-credentials"
secret:
secretName: {{ .Values.jamfCredentialsSecret.name }}
{{- end }}
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 6 }}
{{- end }}
@@ -56,17 +56,20 @@ spec:
{{- if $updater.tls.existingCASecretName }}
- name: SSL_CERT_FILE
value: /etc/teleport-tls-ca/ca.pem
# Used to track whether a Teleport agent was installed using this method.
- name: TELEPORT_INSTALL_METHOD_HELM_KUBE_AGENT
value: true
{{- end }}
{{- end }}
args:
- "--agent-name={{ .Release.Name }}"
- "--agent-namespace={{ .Release.Namespace }}"
- "--base-image={{ include "teleport-kube-agent.baseImage" . }}"
- "--version-server={{ $updater.versionServer }}"
- "--version-server={{ tpl $updater.versionServer . }}"
- "--version-channel={{ $updater.releaseChannel }}"
{{- if $updater.pullCredentials }}
- "--pull-credentials={{ $updater.pullCredentials }}"
{{- end }}
{{- if .Values.updater.extraArgs }}
{{- toYaml .Values.updater.extraArgs | nindent 10 }}
{{- end }}
{{- if $updater.securityContext }}
securityContext: {{- toYaml $updater.securityContext | nindent 10 }}
{{- end }}
@@ -96,15 +99,27 @@ spec:
{{- if $updater.resources }}
resources: {{- toYaml $updater.resources | nindent 10 }}
{{- end }}
{{- if $updater.tls.existingCASecretName }}
{{- if or $updater.tls.existingCASecretName .Values.updater.extraVolumeMounts }}
volumeMounts:
- mountPath: /etc/teleport-tls-ca
name: "teleport-tls-ca"
readOnly: true
{{- if $updater.tls.existingCASecretName }}
- mountPath: /etc/teleport-tls-ca
name: "teleport-tls-ca"
readOnly: true
{{- end }}
{{- if .Values.updater.extraVolumeMounts }}
{{- toYaml .Values.updater.extraVolumeMounts | nindent 10 }}
{{- end }}
{{- end }}
{{- if or $updater.tls.existingCASecretName .Values.updater.extraVolumes }}
volumes:
- name: "teleport-tls-ca"
secret:
secretName: {{ $updater.tls.existingCASecretName }}
{{- if .Values.updater.extraVolumes }}
{{- toYaml $updater.extraVolumes | nindent 8 }}
{{- end }}
{{- if $updater.tls.existingCASecretName }}
- name: "teleport-tls-ca"
secret:
secretName: {{ $updater.tls.existingCASecretName }}
{{- end }}
{{- end }}
{{- if $updater.priorityClassName }}
priorityClassName: {{ $updater.priorityClassName }}