Add teleport agent update
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
{{- if and .Values.podSecurityPolicy.enabled (semverCompare "<1.23.0-0" .Capabilities.KubeVersion.Version) }}
|
||||
SECURITY WARNING: Kubernetes 1.25 removes PodSecurityPolicy support and Helm
|
||||
doesn't support upgrading from 1.24 to 1.25 with PSPs enabled. Since version 12
|
||||
the `teleport-cluster` chart doesn't deploy PSPs on Kubernetes 1.23 or older.
|
||||
Instead, we recommend you to configure Pod Security AdmissionControllers for
|
||||
the namespace "{{.Release.Namespace}}" by adding the label
|
||||
`pod-security.kubernetes.io/enforce: baseline` on the namespace resource.
|
||||
|
||||
See https://goteleport.com/docs/deploy-a-cluster/helm-deployments/migration-kubernetes-1-25-psp/
|
||||
|
||||
To remove this warning, explicitly set "podSecurityPolicy.enabled=false".
|
||||
{{- end }}
|
||||
|
||||
{{- if .Values.teleportVersionOverride }}
|
||||
|
||||
DANGER: `teleportVersionOverride` MUST NOT be used to control the Teleport version.
|
||||
This chart is designed to run Teleport version {{ .Chart.AppVersion }}.
|
||||
You will face compatibility issues trying to run a different Teleport version with it.
|
||||
|
||||
If you want to run Teleport version {{.Values.teleportVersionOverride}},
|
||||
you should use `helm --version {{.Values.teleportVersionOverride}}` instead.
|
||||
{{- end }}
|
||||
{{- if contains "-gke." .Capabilities.KubeVersion.Version -}}
|
||||
{{- $groupName := (coalesce .Values.adminClusterRoleBinding.name "cluster-admin") }}
|
||||
|
||||
WARNING: GKE Autopilot clusters forbid users from impersonating system-wide identities.
|
||||
This means you won't be able to use the `system:masters` Kubernetes Group in
|
||||
the Teleport Roles for GKE Autopilot clusters.
|
||||
|
||||
Given that you installed Teleport on a GKE cluster, we recommend you use the
|
||||
Kubernetes Group `{{ $groupName }}` instead of `system:masters` in the Teleport Roles
|
||||
for GKE Autopilot clusters.
|
||||
|
||||
To do so, you can use the following Teleport Role resource:
|
||||
|
||||
kind: role
|
||||
metadata:
|
||||
name: gke-kube-access
|
||||
version: v6
|
||||
spec:
|
||||
allow:
|
||||
kubernetes_labels:
|
||||
'*': '*'
|
||||
kubernetes_groups:
|
||||
- "{{ $groupName }}"
|
||||
|
||||
This chart automatically created the `{{ $groupName }}` Kubernetes Group for you and
|
||||
assigned it admin privileges on the Kubernetes cluster.
|
||||
|
||||
Consult the built-in security features that GKE Autopilot enforces:
|
||||
https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-security#built-in-security
|
||||
|
||||
{{- end }}
|
||||
@@ -0,0 +1,116 @@
|
||||
{{- define "teleport-kube-agent.config" -}}
|
||||
{{- $logLevel := (coalesce .Values.logLevel .Values.log.level "INFO") -}}
|
||||
{{- if (ge (include "teleport-kube-agent.version" . | semver).Major 11) }}
|
||||
version: v3
|
||||
{{- end }}
|
||||
teleport:
|
||||
join_params:
|
||||
method: "{{ .Values.joinParams.method }}"
|
||||
token_name: "/etc/teleport-secrets/auth-token"
|
||||
{{- if (ge (include "teleport-kube-agent.version" . | semver).Major 11) }}
|
||||
proxy_server: {{ required "proxyAddr is required in chart values" .Values.proxyAddr }}
|
||||
{{- else }}
|
||||
auth_servers: ["{{ required "proxyAddr is required in chart values" .Values.proxyAddr }}"]
|
||||
{{- end }}
|
||||
{{- if .Values.caPin }}
|
||||
ca_pin: {{- toYaml .Values.caPin | nindent 8 }}
|
||||
{{- end }}
|
||||
log:
|
||||
severity: {{ $logLevel }}
|
||||
output: {{ .Values.log.output }}
|
||||
format:
|
||||
output: {{ .Values.log.format }}
|
||||
extra_fields: {{ .Values.log.extraFields | toJson }}
|
||||
|
||||
kubernetes_service:
|
||||
{{- if or (contains "kube" (.Values.roles | toString)) (empty .Values.roles) }}
|
||||
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 }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
enabled: false
|
||||
{{- end }}
|
||||
|
||||
app_service:
|
||||
{{- if contains "app" (.Values.roles | toString) }}
|
||||
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") }}
|
||||
{{- fail "'name' is required for all 'apps' in chart values when app role is enabled, see README" }}
|
||||
{{- end }}
|
||||
{{- if not (hasKey $app "uri") }}
|
||||
{{- fail "'uri' is required for all 'apps' in chart values when app role is enabled, see README" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
apps:
|
||||
{{- toYaml .Values.apps | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.appResources }}
|
||||
resources:
|
||||
{{- toYaml .Values.appResources | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
enabled: false
|
||||
{{- end }}
|
||||
|
||||
db_service:
|
||||
{{- if contains "db" (.Values.roles | toString) }}
|
||||
enabled: true
|
||||
{{- if not (or (.Values.awsDatabases) (.Values.azureDatabases) (.Values.databases) (.Values.databaseResources)) }}
|
||||
{{- fail "at least one of 'awsDatabases', 'azureDatabases', 'databases' or 'databaseResources' is required in chart values when db role is enabled, see README" }}
|
||||
{{- end }}
|
||||
{{- if .Values.awsDatabases }}
|
||||
aws:
|
||||
{{- range $awsDb := .Values.awsDatabases }}
|
||||
{{- if not (hasKey $awsDb "types") }}
|
||||
{{- fail "'types' is required for all 'awsDatabases' in chart values when key is set and db role is enabled, see README" }}
|
||||
{{- end }}
|
||||
{{- if not (hasKey $awsDb "regions") }}
|
||||
{{- fail "'regions' is required for all 'awsDatabases' in chart values when key is set and db role is enabled, see README" }}
|
||||
{{- end }}
|
||||
{{- if not (hasKey $awsDb "tags") }}
|
||||
{{- 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 }}
|
||||
{{- end }}
|
||||
{{- if .Values.azureDatabases }}
|
||||
azure:
|
||||
{{- toYaml .Values.azureDatabases | nindent 6 }}
|
||||
{{- end}}
|
||||
{{- if .Values.databases }}
|
||||
databases:
|
||||
{{- range $db := .Values.databases }}
|
||||
{{- if not (hasKey $db "name") }}
|
||||
{{- fail "'name' is required for all 'databases' in chart values when db role is enabled, see README" }}
|
||||
{{- end }}
|
||||
{{- if not (hasKey $db "uri") }}
|
||||
{{- fail "'uri' is required for all 'databases' is required in chart values when db role is enabled, see README" }}
|
||||
{{- end }}
|
||||
{{- if not (hasKey $db "protocol") }}
|
||||
{{- fail "'protocol' is required for all 'databases' in chart values when db role is enabled, see README" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- toYaml .Values.databases | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.databaseResources }}
|
||||
resources:
|
||||
{{- toYaml .Values.databaseResources | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
enabled: false
|
||||
{{- end }}
|
||||
|
||||
auth_service:
|
||||
enabled: false
|
||||
ssh_service:
|
||||
enabled: false
|
||||
proxy_service:
|
||||
enabled: false
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,46 @@
|
||||
{{- define "teleport.kube.agent.isUpgrade" -}}
|
||||
{{- /* Checks if action is an upgrade from an old release that didn't support Secret storage */}}
|
||||
{{- if .Release.IsUpgrade }}
|
||||
{{- $deployment := (lookup "apps/v1" "Deployment" .Release.Namespace .Release.Name ) -}}
|
||||
{{- if ($deployment) }}
|
||||
true
|
||||
{{- else if .Values.unitTestUpgrade }}
|
||||
true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
if serviceAccount is not defined or serviceAccount.name is empty, use .Release.Name
|
||||
*/}}
|
||||
{{- define "teleport-kube-agent.serviceAccountName" -}}
|
||||
{{- coalesce .Values.serviceAccount.name .Values.serviceAccountName .Release.Name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
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) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "teleport-kube-agent.version" -}}
|
||||
{{- if .Values.teleportVersionOverride -}}
|
||||
{{- .Values.teleportVersionOverride -}}
|
||||
{{- else -}}
|
||||
{{- .Chart.Version -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "teleport-kube-agent.baseImage" -}}
|
||||
{{- if .Values.enterprise -}}
|
||||
{{- .Values.enterpriseImage -}}
|
||||
{{- else -}}
|
||||
{{- .Values.image -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "teleport-kube-agent.image" -}}
|
||||
{{ include "teleport-kube-agent.baseImage" . }}:{{ include "teleport-kube-agent.version" . }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,24 @@
|
||||
{{/* GKE Autopilot clusters forbid users from impersonating system:masters
|
||||
Groups. This is a security measure released under the GKE Warden authz module
|
||||
https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-security#built-in-security
|
||||
Because of this limitation, users are unable to specify kubernetes_groups=["system:masters"]
|
||||
in Teleport, so we create a Kubernetes Group called cluster-admin when we detect
|
||||
that the underlying cluster is a GKE cluster. */}}
|
||||
{{- if or (contains "-gke." .Capabilities.KubeVersion.Version) (.Values.adminClusterRoleBinding.create) -}}
|
||||
{{- $groupName := (coalesce .Values.adminClusterRoleBinding.name "cluster-admin") }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: admin-k8s-cluster-group
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
# This is the built-in cluster-admin role that exists in all K8S clusters.
|
||||
# We are binding the cluster-admin role to the cluster-admin group.
|
||||
# See https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles
|
||||
name: cluster-admin
|
||||
subjects:
|
||||
- apiGroup: rbac.authorization.k8s.io
|
||||
kind: Group
|
||||
name: {{ $groupName }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,31 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: {{ .Values.clusterRoleName | default .Release.Name }}
|
||||
{{- if .Values.extraLabels.clusterRole }}
|
||||
labels:
|
||||
{{- toYaml .Values.extraLabels.clusterRole | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- users
|
||||
- groups
|
||||
- serviceaccounts
|
||||
verbs:
|
||||
- impersonate
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
verbs:
|
||||
- get
|
||||
- apiGroups:
|
||||
- "authorization.k8s.io"
|
||||
resources:
|
||||
- selfsubjectaccessreviews
|
||||
verbs:
|
||||
- create
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,18 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: {{ .Values.clusterRoleBindingName | default .Release.Name }}
|
||||
{{- if .Values.extraLabels.clusterRoleBinding }}
|
||||
labels:
|
||||
{{- toYaml .Values.extraLabels.clusterRoleBinding | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: {{ .Values.clusterRoleName | default .Release.Name }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "teleport-kube-agent.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- if .Values.extraLabels.config }}
|
||||
labels:
|
||||
{{- toYaml .Values.extraLabels.config | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.annotations.config }}
|
||||
annotations:
|
||||
{{- toYaml .Values.annotations.config | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
teleport.yaml: |
|
||||
{{- mustMergeOverwrite (include "teleport-kube-agent.config" . | fromYaml) .Values.teleportConfig | toYaml | nindent 4 -}}
|
||||
@@ -0,0 +1,95 @@
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ template "teleport-kube-agent.deleteHookServiceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
"helm.sh/hook": post-delete
|
||||
"helm.sh/hook-weight": "-4"
|
||||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
|
||||
---
|
||||
{{- end }}
|
||||
{{- if .Values.rbac.create }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-delete-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
"helm.sh/hook": post-delete
|
||||
"helm.sh/hook-weight": "-3"
|
||||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets",]
|
||||
verbs: ["get", "delete", "list"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-delete-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
"helm.sh/hook": post-delete
|
||||
"helm.sh/hook-weight": "-2"
|
||||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ .Release.Name }}-delete-hook
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ .Release.Name }}-delete-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
---
|
||||
{{- end }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-delete-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
"helm.sh/hook": post-delete
|
||||
"helm.sh/hook-weight": "-1"
|
||||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-delete-hook
|
||||
spec:
|
||||
{{- if .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml .Values.imagePullSecrets | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{ .Values.priorityClassName }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "teleport-kube-agent.deleteHookServiceAccountName" . }}
|
||||
restartPolicy: OnFailure
|
||||
{{- if .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml .Values.tolerations | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml .Values.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: post-delete-job
|
||||
env:
|
||||
- name: KUBE_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: RELEASE_NAME
|
||||
value: {{ .Release.Name }}
|
||||
image: {{ include "teleport-kube-agent.image" . | quote }}
|
||||
{{- if .Values.imagePullPolicy }}
|
||||
imagePullPolicy: {{ toYaml .Values.imagePullPolicy }}
|
||||
{{- end }}
|
||||
command: ["teleport"]
|
||||
args: ["kube-state", "delete"]
|
||||
{{- if .Values.securityContext }}
|
||||
securityContext: {{- toYaml .Values.securityContext | nindent 10 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,216 @@
|
||||
#
|
||||
# Warning to maintainers, any changes to this file that are not specific to the Deployment need to also be duplicated
|
||||
# in the statefulset.yaml file.
|
||||
#
|
||||
{{- if and (not .Values.storage.enabled) (include "teleport.kube.agent.isUpgrade" . ) }}
|
||||
{{- $replicaCount := (coalesce .Values.replicaCount .Values.highAvailability.replicaCount "1") }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: {{ .Release.Name }}
|
||||
{{- if .Values.extraLabels.deployment }}
|
||||
{{- toYaml .Values.extraLabels.deployment | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.annotations.deployment }}
|
||||
annotations:
|
||||
{{- toYaml .Values.annotations.deployment | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
replicas: {{ $replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Release.Name }}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
# ConfigMap checksum, to recreate the pod on config changes.
|
||||
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
|
||||
{{- if .Values.annotations.pod }}
|
||||
{{- toYaml .Values.annotations.pod | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
app: {{ .Release.Name }}
|
||||
{{- if .Values.extraLabels.pod }}
|
||||
{{- toYaml .Values.extraLabels.pod | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.dnsConfig }}
|
||||
dnsConfig: {{- toYaml .Values.dnsConfig | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.dnsPolicy }}
|
||||
dnsPolicy: {{ .Values.dnsPolicy | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.hostAliases }}
|
||||
hostAliases: {{- toYaml .Values.hostAliases | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.affinity (gt (int $replicaCount) 1) }}
|
||||
affinity:
|
||||
{{- if .Values.affinity }}
|
||||
{{- if .Values.highAvailability.requireAntiAffinity }}
|
||||
{{- fail "Cannot use highAvailability.requireAntiAffinity when affinity is also set in chart values - unset one or the other" }}
|
||||
{{- end }}
|
||||
{{- toYaml .Values.affinity | nindent 8 }}
|
||||
{{- else }}
|
||||
podAntiAffinity:
|
||||
{{- if .Values.highAvailability.requireAntiAffinity }}
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
- labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- {{ .Release.Name }}
|
||||
topologyKey: "kubernetes.io/hostname"
|
||||
{{- else if gt (int $replicaCount) 1 }}
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 50
|
||||
podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- {{ .Release.Name }}
|
||||
topologyKey: "kubernetes.io/hostname"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml .Values.tolerations | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml .Values.imagePullSecrets | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.initContainers }}
|
||||
initContainers: {{- toYaml .Values.initContainers | nindent 6 }}
|
||||
{{- if .Values.resources }}
|
||||
resources: {{- toYaml .Values.resources | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.initSecurityContext }}
|
||||
securityContext: {{- toYaml .Values.initSecurityContext | nindent 10 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- mountPath: /etc/teleport
|
||||
name: "config"
|
||||
readOnly: true
|
||||
- mountPath: /etc/teleport-secrets
|
||||
name: "auth-token"
|
||||
readOnly: true
|
||||
- mountPath: /var/lib/teleport
|
||||
name: "data"
|
||||
{{- if .Values.tls.existingCASecretName }}
|
||||
- mountPath: /etc/teleport-tls-ca
|
||||
name: "teleport-tls-ca"
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.extraVolumeMounts }}
|
||||
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml .Values.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: "teleport"
|
||||
image: {{ include "teleport-kube-agent.image" . | quote }}
|
||||
{{- if .Values.imagePullPolicy }}
|
||||
imagePullPolicy: {{ toYaml .Values.imagePullPolicy }}
|
||||
{{- end }}
|
||||
env:
|
||||
# This variable is set for telemetry purposes.
|
||||
# Telemetry is opt-in for oss users and controlled at the auth level.
|
||||
- name: TELEPORT_INSTALL_METHOD_HELM_KUBE_AGENT
|
||||
value: "true"
|
||||
{{- if .Values.updater.enabled }}
|
||||
- name: TELEPORT_EXT_UPGRADER
|
||||
value: kube
|
||||
{{- end }}
|
||||
{{- if (gt (len .Values.extraEnv) 0) }}
|
||||
{{- toYaml .Values.extraEnv | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.existingCASecretName }}
|
||||
- name: SSL_CERT_FILE
|
||||
value: /etc/teleport-tls-ca/ca.pem
|
||||
{{- end }}
|
||||
args:
|
||||
- "--diag-addr=0.0.0.0:3000"
|
||||
{{- if .Values.insecureSkipProxyTLSVerify }}
|
||||
- "--insecure"
|
||||
{{- end }}
|
||||
{{- if .Values.extraArgs }}
|
||||
{{- toYaml .Values.extraArgs | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.securityContext }}
|
||||
securityContext: {{- toYaml .Values.securityContext | nindent 10 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: diag
|
||||
containerPort: 3000
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: diag
|
||||
initialDelaySeconds: 5 # wait 5s for agent to start
|
||||
periodSeconds: 5 # poll health every 5s
|
||||
failureThreshold: 6 # consider agent unhealthy after 30s (6 * 5s)
|
||||
timeoutSeconds: {{ .Values.probeTimeoutSeconds }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /readyz
|
||||
port: diag
|
||||
initialDelaySeconds: 5 # wait 5s for agent to register
|
||||
periodSeconds: 5 # poll health every 5s
|
||||
failureThreshold: 12 # consider agent unhealthy after 60s (12 * 5s)
|
||||
timeoutSeconds: {{ .Values.probeTimeoutSeconds }}
|
||||
{{- if .Values.resources }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 10 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- mountPath: /etc/teleport
|
||||
name: "config"
|
||||
readOnly: true
|
||||
- mountPath: /etc/teleport-secrets
|
||||
name: "auth-token"
|
||||
readOnly: true
|
||||
- mountPath: /var/lib/teleport
|
||||
name: {{ default "data" .Values.existingDataVolume }}
|
||||
{{- if .Values.tls.existingCASecretName }}
|
||||
- mountPath: /etc/teleport-tls-ca
|
||||
name: "teleport-tls-ca"
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.extraVolumeMounts }}
|
||||
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: "config"
|
||||
configMap:
|
||||
name: {{ .Release.Name }}
|
||||
- name: "auth-token"
|
||||
secret:
|
||||
secretName: {{ coalesce .Values.secretName .Values.joinTokenSecret.name }}
|
||||
{{- if not .Values.existingDataVolume }}
|
||||
- name: "data"
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.existingCASecretName }}
|
||||
- name: "teleport-tls-ca"
|
||||
secret:
|
||||
secretName: {{ .Values.tls.existingCASecretName }}
|
||||
{{- end }}
|
||||
{{- if .Values.extraVolumes }}
|
||||
{{- toYaml .Values.extraVolumes | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{ .Values.priorityClassName }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "teleport-kube-agent.serviceAccountName" . }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,97 @@
|
||||
{{- $deployment := (lookup "apps/v1" "Deployment" .Release.Namespace .Release.Name ) -}}
|
||||
{{- if $deployment }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
"helm.sh/hook": post-upgrade
|
||||
"helm.sh/hook-weight": "-4"
|
||||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
"helm.sh/hook": post-upgrade
|
||||
"helm.sh/hook-weight": "-3"
|
||||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
|
||||
rules:
|
||||
- apiGroups: ["apps"]
|
||||
resources: ["statefulsets"]
|
||||
resourceNames: ["{{ .Release.Name }}"]
|
||||
verbs: ["get", "watch", "list"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods",]
|
||||
verbs: ["get", "watch"]
|
||||
- apiGroups: ["apps"]
|
||||
resources: ["deployments",]
|
||||
resourceNames: ["{{ .Release.Name }}"]
|
||||
verbs: ["get", "delete", "list"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
"helm.sh/hook": post-upgrade
|
||||
"helm.sh/hook-weight": "-2"
|
||||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ .Release.Name }}-hook
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ .Release.Name }}-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-hook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
"helm.sh/hook": post-upgrade
|
||||
"helm.sh/hook-weight": "-1"
|
||||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-hook
|
||||
spec:
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{ .Values.priorityClassName }}
|
||||
{{- end }}
|
||||
{{- if .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml .Values.tolerations | nindent 6 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ .Release.Name }}-hook
|
||||
restartPolicy: OnFailure
|
||||
{{- if .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml .Values.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: post-install-job
|
||||
image: alpine/k8s:1.26.0
|
||||
command:
|
||||
- sh
|
||||
- "-c"
|
||||
- |
|
||||
/bin/sh <<'EOF'
|
||||
set -eu -o pipefail
|
||||
# wait until statefulset is ready
|
||||
kubectl rollout status --watch --timeout=600s statefulset/{{ .Release.Name }}
|
||||
# delete deployment
|
||||
kubectl delete deployment/{{ .Release.Name }}
|
||||
EOF
|
||||
{{- if .Values.securityContext }}
|
||||
securityContext: {{- toYaml .Values.securityContext | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
@@ -0,0 +1,21 @@
|
||||
{{- if .Values.highAvailability.podDisruptionBudget.enabled }}
|
||||
{{- if .Capabilities.APIVersions.Has "policy/v1" }}
|
||||
apiVersion: policy/v1
|
||||
{{- else }}
|
||||
apiVersion: policy/v1beta1
|
||||
{{- end }}
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: {{ .Release.Name }}
|
||||
{{- if .Values.extraLabels.podDisruptionBudget }}
|
||||
{{- toYaml .Values.extraLabels.podDisruptionBudget | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
minAvailable: {{ .Values.highAvailability.podDisruptionBudget.minAvailable }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,31 @@
|
||||
{{- if.Values.podMonitor.enabled -}}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PodMonitor
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- with .Values.podMonitor.additionalLabels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
jobLabel: {{ .Release.Name }}
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- {{ .Release.Namespace }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Release.Name }}
|
||||
podMetricsEndpoints:
|
||||
- port: diag
|
||||
path: /metrics
|
||||
{{- with .Values.podMonitor.interval }}
|
||||
interval: {{ . | quote }}
|
||||
{{- end }}
|
||||
podTargetLabels:
|
||||
- "app.kubernetes.io/name"
|
||||
- "app.kubernetes.io/instance"
|
||||
- "app.kubernetes.io/component"
|
||||
- "app.kubernetes.io/version"
|
||||
- "teleport.dev/majorVersion"
|
||||
{{- end }}
|
||||
@@ -0,0 +1,70 @@
|
||||
{{/* PSPs are deprecated in 1.22 and removed in 1.25. However Helm doesn't handle their removal properly in 1.25
|
||||
We must remove them before 1.25 to ensure the Helm state doesn't corrupt. As this is a breaking change, this
|
||||
only applies to v12+ charts. v11 and below will only show a warning from the NOTES.txt.
|
||||
Users must use PSAs instead (beta in 1.23, GA in 1.25). The "teleport-cluster" chart runs in "baseline" mode */}}
|
||||
{{- if and .Values.podSecurityPolicy.enabled (semverCompare "<1.23.0-0" .Capabilities.KubeVersion.Version) -}}
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodSecurityPolicy
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
{{- if .Values.extraLabels.podSecurityPolicy }}
|
||||
labels:
|
||||
{{- toYaml .Values.extraLabels.podSecurityPolicy | nindent 4 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'docker/default,runtime/default'
|
||||
seccomp.security.alpha.kubernetes.io/defaultProfileName: 'runtime/default'
|
||||
spec:
|
||||
privileged: false
|
||||
allowPrivilegeEscalation: false
|
||||
requiredDropCapabilities:
|
||||
- ALL
|
||||
seLinux:
|
||||
rule: RunAsAny
|
||||
supplementalGroups:
|
||||
rule: MustRunAs
|
||||
ranges:
|
||||
# Forbid adding the root group.
|
||||
- min: 1
|
||||
max: 65535
|
||||
runAsUser:
|
||||
rule: MustRunAsNonRoot
|
||||
fsGroup:
|
||||
rule: MustRunAs
|
||||
ranges:
|
||||
# Forbid adding the root group.
|
||||
- min: 1
|
||||
max: 65535
|
||||
readOnlyRootFilesystem: true
|
||||
volumes:
|
||||
- '*'
|
||||
hostNetwork: false
|
||||
hostIPC: false
|
||||
hostPID: false
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-psp
|
||||
rules:
|
||||
- apiGroups:
|
||||
- policy
|
||||
resources:
|
||||
- podsecuritypolicies
|
||||
verbs:
|
||||
- use
|
||||
resourceNames:
|
||||
- {{ .Release.Name }}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-psp
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ .Release.Name }}-psp
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "teleport-kube-agent.serviceAccountName" . }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ .Values.roleName | default .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- if .Values.extraLabels.role }}
|
||||
labels:
|
||||
{{- toYaml .Values.extraLabels.role | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
# objects is "secrets"
|
||||
resources: ["secrets"]
|
||||
verbs: ["create", "get", "update","patch"]
|
||||
@@ -0,0 +1,17 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ .Values.roleBindingName | default .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- if .Values.extraLabels.roleBinding }}
|
||||
labels:
|
||||
{{- toYaml .Values.extraLabels.roleBinding | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ .Values.roleName | default .Release.Name }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "teleport-kube-agent.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
@@ -0,0 +1,19 @@
|
||||
{{- if .Values.joinTokenSecret.create }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ coalesce .Values.secretName .Values.joinTokenSecret.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:
|
||||
auth-token: |
|
||||
{{ coalesce .Values.joinParams.tokenName .Values.authToken }}
|
||||
{{- end}}
|
||||
@@ -0,0 +1,15 @@
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ template "teleport-kube-agent.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- if .Values.extraLabels.serviceAccount }}
|
||||
labels:
|
||||
{{- toYaml .Values.extraLabels.serviceAccount | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.annotations.serviceAccount }}
|
||||
annotations:
|
||||
{{- toYaml .Values.annotations.serviceAccount | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,239 @@
|
||||
#
|
||||
# Warning to maintainers, any changes to this file that are not specific to the StatefulSet need to also be duplicated
|
||||
# in the deployment.yaml file.
|
||||
#
|
||||
{{- $replicaCount := (coalesce .Values.replicaCount .Values.highAvailability.replicaCount "1") }}
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: {{ .Release.Name }}
|
||||
{{- if .Values.extraLabels.deployment }}
|
||||
{{- toYaml .Values.extraLabels.deployment | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
serviceName: {{ .Release.Name }}
|
||||
replicas: {{ $replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Release.Name }}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
# ConfigMap checksum, to recreate the pod on config changes.
|
||||
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
|
||||
{{- if .Values.annotations.pod }}
|
||||
{{- toYaml .Values.annotations.pod | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
app: {{ .Release.Name }}
|
||||
{{- if .Values.extraLabels.pod }}
|
||||
{{- toYaml .Values.extraLabels.pod | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.dnsConfig }}
|
||||
dnsConfig: {{- toYaml .Values.dnsConfig | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.dnsPolicy }}
|
||||
dnsPolicy: {{ .Values.dnsPolicy | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.hostAliases }}
|
||||
hostAliases: {{- toYaml .Values.hostAliases | nindent 8 }}
|
||||
{{- end }}
|
||||
securityContext:
|
||||
fsGroup: 9807
|
||||
{{- if or .Values.affinity (gt (int $replicaCount) 1) }}
|
||||
affinity:
|
||||
{{- if .Values.affinity }}
|
||||
{{- if .Values.highAvailability.requireAntiAffinity }}
|
||||
{{- fail "Cannot use highAvailability.requireAntiAffinity when affinity is also set in chart values - unset one or the other" }}
|
||||
{{- end }}
|
||||
{{- toYaml .Values.affinity | nindent 8 }}
|
||||
{{- else }}
|
||||
podAntiAffinity:
|
||||
{{- if .Values.highAvailability.requireAntiAffinity }}
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
- labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- {{ .Release.Name }}
|
||||
topologyKey: "kubernetes.io/hostname"
|
||||
{{- else if gt (int $replicaCount) 1 }}
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 50
|
||||
podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- {{ .Release.Name }}
|
||||
topologyKey: "kubernetes.io/hostname"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml .Values.tolerations | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml .Values.imagePullSecrets | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.initContainers }}
|
||||
initContainers: {{- toYaml .Values.initContainers | nindent 6 }}
|
||||
{{- if .Values.resources }}
|
||||
resources: {{- toYaml .Values.resources | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.initSecurityContext }}
|
||||
securityContext: {{- toYaml .Values.initSecurityContext | nindent 10 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- mountPath: /etc/teleport
|
||||
name: "config"
|
||||
readOnly: true
|
||||
- mountPath: /etc/teleport-secrets
|
||||
name: "auth-token"
|
||||
readOnly: true
|
||||
- mountPath: /var/lib/teleport
|
||||
name: "{{ .Release.Name }}-teleport-data"
|
||||
{{- if .Values.tls.existingCASecretName }}
|
||||
- mountPath: /etc/teleport-tls-ca
|
||||
name: "teleport-tls-ca"
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.extraVolumeMounts }}
|
||||
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{ .Values.priorityClassName }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "teleport-kube-agent.serviceAccountName" . }}
|
||||
{{- if .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml .Values.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: "teleport"
|
||||
image: {{ include "teleport-kube-agent.image" . | quote }}
|
||||
{{- if .Values.imagePullPolicy }}
|
||||
imagePullPolicy: {{ toYaml .Values.imagePullPolicy }}
|
||||
{{- end }}
|
||||
env:
|
||||
# This variable is set for telemetry purposes.
|
||||
# Telemetry is opt-in and controlled at the auth level.
|
||||
- name: TELEPORT_INSTALL_METHOD_HELM_KUBE_AGENT
|
||||
value: "true"
|
||||
- name: TELEPORT_REPLICA_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: KUBE_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: RELEASE_NAME
|
||||
value: {{ .Release.Name }}
|
||||
{{- if .Values.updater.enabled }}
|
||||
- name: TELEPORT_EXT_UPGRADER
|
||||
value: kube
|
||||
{{- end }}
|
||||
{{- if .Values.tls.existingCASecretName }}
|
||||
- name: SSL_CERT_FILE
|
||||
value: /etc/teleport-tls-ca/ca.pem
|
||||
{{- end }}
|
||||
{{- if .Values.extraEnv }}
|
||||
{{- toYaml .Values.extraEnv | nindent 10 }}
|
||||
{{- end }}
|
||||
args:
|
||||
- "--diag-addr=0.0.0.0:3000"
|
||||
{{- if .Values.insecureSkipProxyTLSVerify }}
|
||||
- "--insecure"
|
||||
{{- end }}
|
||||
{{- if .Values.extraArgs }}
|
||||
{{- toYaml .Values.extraArgs | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.securityContext }}
|
||||
securityContext: {{- toYaml .Values.securityContext | nindent 10 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: diag
|
||||
containerPort: 3000
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: diag
|
||||
initialDelaySeconds: 5 # wait 5s for agent to start
|
||||
periodSeconds: 5 # poll health every 5s
|
||||
failureThreshold: 6 # consider agent unhealthy after 30s (6 * 5s)
|
||||
timeoutSeconds: {{ .Values.probeTimeoutSeconds }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /readyz
|
||||
port: diag
|
||||
initialDelaySeconds: 5 # wait 5s for agent to register
|
||||
periodSeconds: 5 # poll health every 5s
|
||||
failureThreshold: 12 # consider agent unhealthy after 60s (12 * 5s)
|
||||
timeoutSeconds: {{ .Values.probeTimeoutSeconds }}
|
||||
{{- if .Values.resources }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 10 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- mountPath: /etc/teleport
|
||||
name: "config"
|
||||
readOnly: true
|
||||
- mountPath: /etc/teleport-secrets
|
||||
name: "auth-token"
|
||||
readOnly: true
|
||||
{{- if .Values.storage.enabled }}
|
||||
- mountPath: /var/lib/teleport
|
||||
name: "{{ .Release.Name }}-teleport-data"
|
||||
{{- else }}
|
||||
- mountPath: /var/lib/teleport
|
||||
name: "data"
|
||||
{{- end }}
|
||||
{{- if .Values.tls.existingCASecretName }}
|
||||
- mountPath: /etc/teleport-tls-ca
|
||||
name: "teleport-tls-ca"
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.extraVolumeMounts }}
|
||||
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: "config"
|
||||
configMap:
|
||||
name: {{ .Release.Name }}
|
||||
- name: "auth-token"
|
||||
secret:
|
||||
secretName: {{ coalesce .Values.secretName .Values.joinTokenSecret.name }}
|
||||
{{- if not .Values.storage.enabled }}
|
||||
- name: "data"
|
||||
emptyDir: {}
|
||||
{{- end}}
|
||||
{{- if .Values.tls.existingCASecretName }}
|
||||
- name: "teleport-tls-ca"
|
||||
secret:
|
||||
secretName: {{ .Values.tls.existingCASecretName }}
|
||||
{{- end }}
|
||||
{{- if .Values.extraVolumes }}
|
||||
{{- toYaml .Values.extraVolumes | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.storage.enabled }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: "{{ .Release.Name }}-teleport-data"
|
||||
spec:
|
||||
accessModes: [ "ReadWriteOnce" ]
|
||||
storageClassName: {{ .Values.storage.storageClassName }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.storage.requests }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,7 @@
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
if serviceAccount is not defined or serviceAccount.name is empty, use .Release.Name
|
||||
*/}}
|
||||
{{- define "teleport-kube-agent-updater.serviceAccountName" -}}
|
||||
{{- coalesce .Values.updater.serviceAccount.name (include "teleport-kube-agent.serviceAccountName" . | printf "%s-updater") -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,113 @@
|
||||
{{- if .Values.updater.enabled -}}
|
||||
{{- $updater := mustMergeOverwrite (mustDeepCopy .Values) .Values.updater -}}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-updater
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: {{ .Release.Name }}-updater
|
||||
{{- if $updater.extraLabels.deployment }}
|
||||
{{- toYaml $updater.extraLabels.deployment | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if $updater.annotations.deployment }}
|
||||
annotations: {{- toYaml $updater.annotations.deployment | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Release.Name }}-updater
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
{{- if $updater.annotations.pod }}
|
||||
{{- toYaml $updater.annotations.pod | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
app: {{ .Release.Name }}-updater
|
||||
{{- if $updater.extraLabels.pod }}
|
||||
{{- toYaml $updater.extraLabels.pod | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if $updater.affinity }}
|
||||
affinity: {{- toYaml $updater.affinity | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if $updater.tolerations }}
|
||||
tolerations: {{- toYaml $updater.tolerations | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if $updater.imagePullSecrets }}
|
||||
imagePullSecrets: {{- toYaml $updater.imagePullSecrets | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if $updater.nodeSelector }}
|
||||
nodeSelector: {{- toYaml $updater.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: "kube-agent-updater"
|
||||
image: "{{ $updater.image }}:{{ include "teleport-kube-agent.version" . }}"
|
||||
{{- if $updater.imagePullPolicy }}
|
||||
imagePullPolicy: {{ toYaml $updater.imagePullPolicy }}
|
||||
{{- end }}
|
||||
{{- if or $updater.extraEnv $updater.tls.existingCASecretName }}
|
||||
env:
|
||||
{{- if (gt (len $updater.extraEnv) 0) }}
|
||||
{{- toYaml $updater.extraEnv | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- 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-channel={{ $updater.releaseChannel }}"
|
||||
{{- if $updater.securityContext }}
|
||||
securityContext: {{- toYaml $updater.securityContext | nindent 10 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 8080
|
||||
protocol: TCP
|
||||
- name: healthz
|
||||
containerPort: 8081
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: healthz
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
failureThreshold: 6 # consider agent unhealthy after 30s (6 * 5s)
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /readyz
|
||||
port: healthz
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
failureThreshold: 6 # consider unready after 30s
|
||||
timeoutSeconds: 5
|
||||
{{- if $updater.resources }}
|
||||
resources: {{- toYaml $updater.resources | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if $updater.tls.existingCASecretName }}
|
||||
volumeMounts:
|
||||
- mountPath: /etc/teleport-tls-ca
|
||||
name: "teleport-tls-ca"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: "teleport-tls-ca"
|
||||
secret:
|
||||
secretName: {{ $updater.tls.existingCASecretName }}
|
||||
{{- end }}
|
||||
{{- if $updater.priorityClassName }}
|
||||
priorityClassName: {{ $updater.priorityClassName }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "teleport-kube-agent-updater.serviceAccountName" . }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,95 @@
|
||||
{{- if .Values.updater.enabled -}}
|
||||
{{- $updater := mustMergeOverwrite (mustDeepCopy .Values) .Values.updater -}}
|
||||
{{- if $updater.rbac.create -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-updater
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- if $updater.extraLabels.role }}
|
||||
labels: {{- toYaml $updater.extraLabels.role | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
# the updater needs to list pods to check their health
|
||||
# it also needs to delete pods to unstuck Statefulset rollouts
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
verbs:
|
||||
- get
|
||||
- watch
|
||||
- list
|
||||
- delete
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods/status
|
||||
verbs:
|
||||
- get
|
||||
- watch
|
||||
- list
|
||||
# the updater needs to get the secret created by the agent containing the
|
||||
# maintenance window
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- secrets
|
||||
verbs:
|
||||
- watch
|
||||
- list
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- secrets
|
||||
verbs:
|
||||
- get
|
||||
resourceNames:
|
||||
- {{ .Release.Name }}-shared-state
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- events
|
||||
verbs:
|
||||
- create
|
||||
- patch
|
||||
# the controller in the updater must be able to watch deployments and
|
||||
# statefulsets and get the one it should reconcile
|
||||
- apiGroups:
|
||||
- "apps"
|
||||
resources:
|
||||
- deployments
|
||||
- statefulsets
|
||||
- deployments/status
|
||||
- statefulsets/status
|
||||
verbs:
|
||||
- get
|
||||
- watch
|
||||
- list
|
||||
# However the updater should only update the agent it is watching
|
||||
- apiGroups:
|
||||
- "apps"
|
||||
resources:
|
||||
- deployments
|
||||
- statefulsets
|
||||
verbs:
|
||||
- update
|
||||
resourceNames:
|
||||
- {{ .Release.Name }}
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- create
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resourceNames:
|
||||
- {{ .Release.Name }}
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- get
|
||||
- update
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,22 @@
|
||||
{{- if .Values.updater.enabled -}}
|
||||
{{- $updater := mustMergeOverwrite (mustDeepCopy .Values) .Values.updater -}}
|
||||
{{- if $updater.rbac.create -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-updater
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- if $updater.extraLabels.roleBinding }}
|
||||
labels:
|
||||
{{- toYaml $updater.extraLabels.roleBinding | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ .Release.Name }}-updater
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "teleport-kube-agent-updater.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,16 @@
|
||||
{{- if .Values.updater.enabled -}}
|
||||
{{- $updater := mustMergeOverwrite (mustDeepCopy .Values) .Values.updater -}}
|
||||
{{- if $updater.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ template "teleport-kube-agent-updater.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- if $updater.extraLabels.serviceAccount }}
|
||||
labels: {{- toYaml $updater.extraLabels.serviceAccount | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if $updater.annotations.serviceAccount }}
|
||||
annotations: {{- toYaml $updater.annotations.serviceAccount | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user