Guides for running Teleport using Helm via ArgoCD
Teleport can provide secure, unified access to your Kubernetes clusters. This guide will show you how to deploy Teleport Kubernetes agent on a Kubernetes cluster using Helm and ArgoCD.
How it works
Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. This is used to orchestrate large deployments, and avoid the Kubernetes resources to drift from the desired deployment.
Teleport has an official Helm chart (teleport-kube-agent) that deploys a Teleport Agent in a Kubernetes cluster. The agent can be configured to run several services, but by default it runs the kubernetes_service to provide access to the Kubernetes API via Teleport.
This guide leverages ArgoCD's native Helm support to deploy the Teleport Agent using the teleport-kube-agent Helm chart.
Prerequisites
- An existing Kubernetes cluster you wish to provide access to via Teleport.
- To check that you can connect to your Teleport cluster, sign in with
tsh login, then verify that you can runtctlcommands using your current credentials. For example, run the following command, assigning teleport.example.com to the domain name of the Teleport Proxy Service in your cluster and [email protected] to your Teleport username:If you can connect to the cluster and run thetsh login --proxy=teleport.example.com --user=[email protected]tctl statusCluster teleport.example.com
Version 19.0.0-dev
CA pin sha256:abdc1245efgh5678abdc1245efgh5678abdc1245efgh5678abdc1245efgh5678
tctl statuscommand, you can use your current credentials to run subsequenttctlcommands from your workstation. If you host your own Teleport cluster, you can also runtctlcommands on the computer that hosts the Teleport Auth Service for full permissions. - An existing ArgoCD instance (version 2.10 or greater) that can deploy to the above Kubernetes cluster.
- The
tshclient tool v19.0.0-dev+ installed on your workstation. You can download this from our installation page.
Step 1/3. Generate a join token
Teleport agents use a join token to obtain certificates and connect to Teleport. See joining docs for more information. The token is only used to join initially, the Teleport Kube agent will store its certificates in Kubernetes and won't need a token to join again in the future. In this section, we will create a token for the agent to join the Teleport cluster.
tctl tokens add --type=kube,app --ttl=5m
You can specify the following token types:
| Role | Teleport Service |
|---|---|
app | Application Service |
auth | Auth Service |
bot | Machine ID |
db | Database Service |
discovery | Discovery Service |
kube | Kubernetes Service |
node | SSH Service |
proxy | Proxy Service |
windowsdesktop | Windows Desktop Service |
See the teleport-kube-agent chart
reference for the
roles and token types that the chart supports.
Step 2/3. Configure and deploy the teleport-kube-agent Helm chart via ArgoCD
-
Create a namespace for Teleport and configure its Pod Security Admission, which enforces security standards on pods in the namespace:
kubectl create namespace teleportnamespace/teleport createdkubectl label namespace teleport 'pod-security.kubernetes.io/enforce=baseline'namespace/teleport labeled -
Create a new ArgoCD application using the following as a template.
project: default
source:
repoURL: 'https://charts.releases.teleport.dev'
targetRevision: 19.0.0-dev
helm:
values: |-
roles: kube,app
authToken: $YOUR_AUTH_TOKEN
proxyAddr: $YOUR_PROXY_ADDRESS
kubeClusterName: $YOUR_KUBE_CLUSTER_NAME
highAvailability:
replicaCount: 2
podDisruptionBudget:
enabled: true
minAvailable: 1
chart: teleport-kube-agent
destination:
server: 'https://kubernetes.default.svc'
namespace: teleport
# This section is used to allow the teleport-kube-agent-updater to update the agent
# without ArgoCD reverting the update.
ignoreDifferences:
- group: apps
kind: StatefulSet
name: $YOUR_APPLICATION_NAME
namespace: teleport
jqPathExpressions:
- '.spec.template.spec.containers[] | select(.name == "teleport").image'
- Sync your changes to apply the configuration using the following command:
$ argocd app sync $YOUR_APPLICATION_NAME
- To verify setup check the readiness of the pods in the teleport namespace.
kubectl -n teleport get pods
NAME READY STATUS RESTARTS AGE<your-agent-release>-0 1/1 Running 0 14m<your-agent-release>-1 1/1 Running 0 14m<your-agent-release>-updater-d9f97f5dd-v57g9 1/1 Running 0 16m
Step 3/3. Manage access to your new resource
In this step, we'll create a Teleport role called kube-access
that allows users to send requests to any Teleport-protected Kubernetes
cluster as a member of the viewers group. The Teleport Kubernetes Service
will impersonate the viewers group when proxying requests from those users.
-
Create a file called
kube-access.yamlwith the following content:kind: role metadata: name: kube-access version: v7 spec: allow: kubernetes_labels: '*': '*' kubernetes_resources: - kind: '*' namespace: '*' name: '*' verbs: ['*'] kubernetes_groups: - viewers deny: {} -
Apply your changes:
tctl create -f kube-access.yamltipYou can also create and edit roles using the Web UI. Go to Access -> Roles and click Create New Role or pick an existing role to edit.
-
Assign the
kube-accessrole to your Teleport user by running the appropriate commands for your authentication provider:- Local User
- GitHub
- SAML
- OIDC
-
Retrieve your local user's roles as a comma-separated list:
ROLES=$(tsh status -f json | jq -r '.active.roles | join(",")') -
Edit your local user to add the new role:
tctl users update $(tsh status -f json | jq -r '.active.username') \ --set-roles "${ROLES?},kube-access" -
Sign out of the Teleport cluster and sign in again to assume the new role.
-
Open your
githubauthentication connector in a text editor:tctl edit github/github -
Edit the
githubconnector, addingkube-accessto theteams_to_rolessection.The team you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the team must include your user account and should be the smallest team possible within your organization.
Here is an example:
teams_to_roles: - organization: octocats team: admins roles: - access + - kube-access -
Apply your changes by saving closing the file in your editor.
-
Sign out of the Teleport cluster and sign in again to assume the new role.
-
Retrieve your
samlconfiguration resource:tctl get --with-secrets saml/mysaml > saml.yamlNote that the
--with-secretsflag adds the value ofspec.signing_key_pair.private_keyto thesaml.yamlfile. Because this key contains a sensitive value, you should remove the saml.yaml file immediately after updating the resource. -
Edit
saml.yaml, addingkube-accessto theattributes_to_rolessection.The attribute you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the group must include your user account and should be the smallest group possible within your organization.
Here is an example:
attributes_to_roles: - name: "groups" value: "my-group" roles: - access + - kube-access -
Apply your changes:
tctl create -f saml.yaml -
Sign out of the Teleport cluster and sign in again to assume the new role.
-
Retrieve your
oidcconfiguration resource:tctl get oidc/myoidc --with-secrets > oidc.yamlNote that the
--with-secretsflag adds the value ofspec.signing_key_pair.private_keyto theoidc.yamlfile. Because this key contains a sensitive value, you should remove the oidc.yaml file immediately after updating the resource. -
Edit
oidc.yaml, addingkube-accessto theclaims_to_rolessection.The claim you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the group must include your user account and should be the smallest group possible within your organization.
Here is an example:
claims_to_roles: - name: "groups" value: "my-group" roles: - access + - kube-access -
Apply your changes:
tctl create -f oidc.yaml -
Sign out of the Teleport cluster and sign in again to assume the new role.
While you have authorized the kube-access role to access Kubernetes clusters
as a member of the viewers group, this group does not yet have permissions
within its Kubernetes cluster. To assign these permissions, create a Kubernetes
RoleBinding or ClusterRoleBindings that grants permission to the viewers
group.
-
Create a file called
viewers-bind.yamlwith the following contents:apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: viewers-crb subjects: - kind: Group # Bind the group "viewers" to the kubernetes_groups assigned in the "kube-access" role name: viewers apiGroup: rbac.authorization.k8s.io roleRef: kind: ClusterRole # "view" is a default ClusterRole that grants read-only access to resources # See: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles name: view apiGroup: rbac.authorization.k8s.io -
Apply the
ClusterRoleBindingwithkubectl:kubectl apply -f viewers-bind.yaml
Now any Teleport user you grant the kube-access role to will be able to see the
Kubernetes cluster and view its content as a member of the viewers group.
Next steps
- Further configure the Helm chart values: For more information on configuring the kube-agent Helm chart see the kube-agent reference.
- Set up RBAC for Kubernetes access: For more in depth information on configuring access see the Kubernetes RBAC docs.
- Learn more about working with ArgoCD: To learn more about managing Helm charts via ArgoCD visit the official docs.