cmd/{k8s-operator,k8s-proxy}: add kube-apiserver ProxyGroup type (#16266)
Adds a new k8s-proxy command to convert operator's in-process proxy to
a separately deployable type of ProxyGroup: kube-apiserver. k8s-proxy
reads in a new config file written by the operator, modelled on tailscaled's
conffile but with some modifications to ensure multiple versions of the
config can co-exist within a file. This should make it much easier to
support reading that config file from a Kube Secret with a stable file name.
To avoid needing to give the operator ClusterRole{,Binding} permissions,
the helm chart now optionally deploys a new static ServiceAccount for
the API Server proxy to use if in auth mode.
Proxies deployed by kube-apiserver ProxyGroups currently work the same as
the operator's in-process proxy. They do not yet leverage Tailscale Services
for presenting a single HA DNS name.
Updates #13358
Change-Id: Ib6ead69b2173c5e1929f3c13fb48a9a5362195d8
Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
# Copyright (c) Tailscale Inc & AUTHORS
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
{{ if eq .Values.apiServerProxyConfig.mode "true" }}
|
||||
# If old setting used, enable both old (operator) and new (ProxyGroup) workflows.
|
||||
# If new setting used, enable only new workflow.
|
||||
{{ if or (eq .Values.apiServerProxyConfig.mode "true")
|
||||
(eq .Values.apiServerProxyConfig.allowImpersonation "true") }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: kube-apiserver-auth-proxy
|
||||
namespace: {{ .Release.Namespace }}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -16,9 +25,14 @@ kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: tailscale-auth-proxy
|
||||
subjects:
|
||||
{{- if eq .Values.apiServerProxyConfig.mode "true" }}
|
||||
- kind: ServiceAccount
|
||||
name: operator
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end }}
|
||||
- kind: ServiceAccount
|
||||
name: kube-apiserver-auth-proxy
|
||||
namespace: {{ .Release.Namespace }}
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: tailscale-auth-proxy
|
||||
|
||||
@@ -92,6 +92,13 @@ ingressClass:
|
||||
# If you need more configuration options, take a look at ProxyClass:
|
||||
# https://tailscale.com/kb/1445/kubernetes-operator-customization#cluster-resource-customization-using-proxyclass-custom-resource
|
||||
proxyConfig:
|
||||
# Configure the proxy image to use instead of the default tailscale/tailscale:latest.
|
||||
# Applying a ProxyClass with `spec.statefulSet.pod.tailscaleContainer.image`
|
||||
# set will override any defaults here.
|
||||
#
|
||||
# Note that ProxyGroups of type "kube-apiserver" use a different default image,
|
||||
# tailscale/k8s-proxy:latest, and it is currently only possible to override
|
||||
# that image via the same ProxyClass field.
|
||||
image:
|
||||
# Repository defaults to DockerHub, but images are also synced to ghcr.io/tailscale/tailscale.
|
||||
repository: tailscale/tailscale
|
||||
@@ -115,6 +122,15 @@ proxyConfig:
|
||||
# Kubernetes API server.
|
||||
# https://tailscale.com/kb/1437/kubernetes-operator-api-server-proxy
|
||||
apiServerProxyConfig:
|
||||
# Set to "true" to create the ClusterRole permissions required for the API
|
||||
# server proxy's auth mode. In auth mode, the API server proxy impersonates
|
||||
# groups and users based on tailnet ACL grants. Required for ProxyGroups of
|
||||
# type "kube-apiserver" running in auth mode.
|
||||
allowImpersonation: "false" # "true", "false"
|
||||
|
||||
# If true or noauth, the operator will run an in-process API server proxy.
|
||||
# You can deploy a ProxyGroup of type "kube-apiserver" to run a high
|
||||
# availability set of API server proxies instead.
|
||||
mode: "false" # "true", "false", "noauth"
|
||||
|
||||
imagePullSecrets: []
|
||||
|
||||
@@ -1379,12 +1379,21 @@ spec:
|
||||
type: string
|
||||
image:
|
||||
description: |-
|
||||
Container image name. By default images are pulled from
|
||||
docker.io/tailscale/tailscale, but the official images are also
|
||||
available at ghcr.io/tailscale/tailscale. Specifying image name here
|
||||
will override any proxy image values specified via the Kubernetes
|
||||
operator's Helm chart values or PROXY_IMAGE env var in the operator
|
||||
Deployment.
|
||||
Container image name. By default images are pulled from docker.io/tailscale,
|
||||
but the official images are also available at ghcr.io/tailscale.
|
||||
|
||||
For all uses except on ProxyGroups of type "kube-apiserver", this image must
|
||||
be either tailscale/tailscale, or an equivalent mirror of that image.
|
||||
To apply to ProxyGroups of type "kube-apiserver", this image must be
|
||||
tailscale/k8s-proxy or a mirror of that image.
|
||||
|
||||
For "tailscale/tailscale"-based proxies, specifying image name here will
|
||||
override any proxy image values specified via the Kubernetes operator's
|
||||
Helm chart values or PROXY_IMAGE env var in the operator Deployment.
|
||||
For "tailscale/k8s-proxy"-based proxies, there is currently no way to
|
||||
configure your own default, and this field is the only way to use a
|
||||
custom image.
|
||||
|
||||
https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#image
|
||||
type: string
|
||||
imagePullPolicy:
|
||||
@@ -1655,7 +1664,9 @@ spec:
|
||||
PodSecurityContext, the value specified in SecurityContext takes precedence.
|
||||
type: string
|
||||
tailscaleInitContainer:
|
||||
description: Configuration for the proxy init container that enables forwarding.
|
||||
description: |-
|
||||
Configuration for the proxy init container that enables forwarding.
|
||||
Not valid to apply to ProxyGroups of type "kube-apiserver".
|
||||
type: object
|
||||
properties:
|
||||
debug:
|
||||
@@ -1709,12 +1720,21 @@ spec:
|
||||
type: string
|
||||
image:
|
||||
description: |-
|
||||
Container image name. By default images are pulled from
|
||||
docker.io/tailscale/tailscale, but the official images are also
|
||||
available at ghcr.io/tailscale/tailscale. Specifying image name here
|
||||
will override any proxy image values specified via the Kubernetes
|
||||
operator's Helm chart values or PROXY_IMAGE env var in the operator
|
||||
Deployment.
|
||||
Container image name. By default images are pulled from docker.io/tailscale,
|
||||
but the official images are also available at ghcr.io/tailscale.
|
||||
|
||||
For all uses except on ProxyGroups of type "kube-apiserver", this image must
|
||||
be either tailscale/tailscale, or an equivalent mirror of that image.
|
||||
To apply to ProxyGroups of type "kube-apiserver", this image must be
|
||||
tailscale/k8s-proxy or a mirror of that image.
|
||||
|
||||
For "tailscale/tailscale"-based proxies, specifying image name here will
|
||||
override any proxy image values specified via the Kubernetes operator's
|
||||
Helm chart values or PROXY_IMAGE env var in the operator Deployment.
|
||||
For "tailscale/k8s-proxy"-based proxies, there is currently no way to
|
||||
configure your own default, and this field is the only way to use a
|
||||
custom image.
|
||||
|
||||
https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#image
|
||||
type: string
|
||||
imagePullPolicy:
|
||||
|
||||
@@ -77,6 +77,22 @@ spec:
|
||||
must not start with a dash and must be between 1 and 62 characters long.
|
||||
type: string
|
||||
pattern: ^[a-z0-9][a-z0-9-]{0,61}$
|
||||
kubeAPIServer:
|
||||
description: |-
|
||||
KubeAPIServer contains configuration specific to the kube-apiserver
|
||||
ProxyGroup type. This field is only used when Type is set to "kube-apiserver".
|
||||
type: object
|
||||
properties:
|
||||
mode:
|
||||
description: |-
|
||||
Mode to run the API server proxy in. Supported modes are auth and noauth.
|
||||
In auth mode, requests from the tailnet proxied over to the Kubernetes
|
||||
API server are additionally impersonated using the sender's tailnet identity.
|
||||
If not specified, defaults to auth mode.
|
||||
type: string
|
||||
enum:
|
||||
- auth
|
||||
- noauth
|
||||
proxyClass:
|
||||
description: |-
|
||||
ProxyClass is the name of the ProxyClass custom resource that contains
|
||||
@@ -106,12 +122,13 @@ spec:
|
||||
pattern: ^tag:[a-zA-Z][a-zA-Z0-9-]*$
|
||||
type:
|
||||
description: |-
|
||||
Type of the ProxyGroup proxies. Supported types are egress and ingress.
|
||||
Type of the ProxyGroup proxies. Supported types are egress, ingress, and kube-apiserver.
|
||||
Type is immutable once a ProxyGroup is created.
|
||||
type: string
|
||||
enum:
|
||||
- egress
|
||||
- ingress
|
||||
- kube-apiserver
|
||||
x-kubernetes-validations:
|
||||
- rule: self == oldSelf
|
||||
message: ProxyGroup type is immutable
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
# Copyright (c) Tailscale Inc & AUTHORS
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: kube-apiserver-auth-proxy
|
||||
namespace: tailscale
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -18,6 +24,9 @@ subjects:
|
||||
- kind: ServiceAccount
|
||||
name: operator
|
||||
namespace: tailscale
|
||||
- kind: ServiceAccount
|
||||
name: kube-apiserver-auth-proxy
|
||||
namespace: tailscale
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: tailscale-auth-proxy
|
||||
|
||||
@@ -1852,12 +1852,21 @@ spec:
|
||||
type: array
|
||||
image:
|
||||
description: |-
|
||||
Container image name. By default images are pulled from
|
||||
docker.io/tailscale/tailscale, but the official images are also
|
||||
available at ghcr.io/tailscale/tailscale. Specifying image name here
|
||||
will override any proxy image values specified via the Kubernetes
|
||||
operator's Helm chart values or PROXY_IMAGE env var in the operator
|
||||
Deployment.
|
||||
Container image name. By default images are pulled from docker.io/tailscale,
|
||||
but the official images are also available at ghcr.io/tailscale.
|
||||
|
||||
For all uses except on ProxyGroups of type "kube-apiserver", this image must
|
||||
be either tailscale/tailscale, or an equivalent mirror of that image.
|
||||
To apply to ProxyGroups of type "kube-apiserver", this image must be
|
||||
tailscale/k8s-proxy or a mirror of that image.
|
||||
|
||||
For "tailscale/tailscale"-based proxies, specifying image name here will
|
||||
override any proxy image values specified via the Kubernetes operator's
|
||||
Helm chart values or PROXY_IMAGE env var in the operator Deployment.
|
||||
For "tailscale/k8s-proxy"-based proxies, there is currently no way to
|
||||
configure your own default, and this field is the only way to use a
|
||||
custom image.
|
||||
|
||||
https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#image
|
||||
type: string
|
||||
imagePullPolicy:
|
||||
@@ -2129,7 +2138,9 @@ spec:
|
||||
type: object
|
||||
type: object
|
||||
tailscaleInitContainer:
|
||||
description: Configuration for the proxy init container that enables forwarding.
|
||||
description: |-
|
||||
Configuration for the proxy init container that enables forwarding.
|
||||
Not valid to apply to ProxyGroups of type "kube-apiserver".
|
||||
properties:
|
||||
debug:
|
||||
description: |-
|
||||
@@ -2182,12 +2193,21 @@ spec:
|
||||
type: array
|
||||
image:
|
||||
description: |-
|
||||
Container image name. By default images are pulled from
|
||||
docker.io/tailscale/tailscale, but the official images are also
|
||||
available at ghcr.io/tailscale/tailscale. Specifying image name here
|
||||
will override any proxy image values specified via the Kubernetes
|
||||
operator's Helm chart values or PROXY_IMAGE env var in the operator
|
||||
Deployment.
|
||||
Container image name. By default images are pulled from docker.io/tailscale,
|
||||
but the official images are also available at ghcr.io/tailscale.
|
||||
|
||||
For all uses except on ProxyGroups of type "kube-apiserver", this image must
|
||||
be either tailscale/tailscale, or an equivalent mirror of that image.
|
||||
To apply to ProxyGroups of type "kube-apiserver", this image must be
|
||||
tailscale/k8s-proxy or a mirror of that image.
|
||||
|
||||
For "tailscale/tailscale"-based proxies, specifying image name here will
|
||||
override any proxy image values specified via the Kubernetes operator's
|
||||
Helm chart values or PROXY_IMAGE env var in the operator Deployment.
|
||||
For "tailscale/k8s-proxy"-based proxies, there is currently no way to
|
||||
configure your own default, and this field is the only way to use a
|
||||
custom image.
|
||||
|
||||
https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#image
|
||||
type: string
|
||||
imagePullPolicy:
|
||||
@@ -2904,6 +2924,22 @@ spec:
|
||||
must not start with a dash and must be between 1 and 62 characters long.
|
||||
pattern: ^[a-z0-9][a-z0-9-]{0,61}$
|
||||
type: string
|
||||
kubeAPIServer:
|
||||
description: |-
|
||||
KubeAPIServer contains configuration specific to the kube-apiserver
|
||||
ProxyGroup type. This field is only used when Type is set to "kube-apiserver".
|
||||
properties:
|
||||
mode:
|
||||
description: |-
|
||||
Mode to run the API server proxy in. Supported modes are auth and noauth.
|
||||
In auth mode, requests from the tailnet proxied over to the Kubernetes
|
||||
API server are additionally impersonated using the sender's tailnet identity.
|
||||
If not specified, defaults to auth mode.
|
||||
enum:
|
||||
- auth
|
||||
- noauth
|
||||
type: string
|
||||
type: object
|
||||
proxyClass:
|
||||
description: |-
|
||||
ProxyClass is the name of the ProxyClass custom resource that contains
|
||||
@@ -2933,11 +2969,12 @@ spec:
|
||||
type: array
|
||||
type:
|
||||
description: |-
|
||||
Type of the ProxyGroup proxies. Supported types are egress and ingress.
|
||||
Type of the ProxyGroup proxies. Supported types are egress, ingress, and kube-apiserver.
|
||||
Type is immutable once a ProxyGroup is created.
|
||||
enum:
|
||||
- egress
|
||||
- ingress
|
||||
- kube-apiserver
|
||||
type: string
|
||||
x-kubernetes-validations:
|
||||
- message: ProxyGroup type is immutable
|
||||
|
||||
Reference in New Issue
Block a user