This commit contains the Kubernetes implementation of peer relays via the new `PeerRelay` CRD. It's a mega branch consisting of the commits of other PRs gone into this work: 1. https://github.com/tailscale/tailscale/pull/20211 2. https://github.com/tailscale/tailscale/pull/20329 3. https://github.com/tailscale/tailscale/pull/20423 4. https://github.com/tailscale/tailscale/pull/20503 An instance of the `PeerRelay` CRD deploys a `StatefulSet` of containerboot instances configured to advertise themselves as peer relays using the IP addresses configured via `LoadBalancer` services on each cloud provider (with some AWS specifics as it's less automatic than its competing cloud providers). Per replica, a `LoadBalancer` type `Service` resource is provisioned and its IP address is used to configure the respective relay. This has been tested with success in AWS, GCP & Azure and provides additional modification to `Service` resources via the CRD for any other kinds of deployment environments. It also contains some work that may appear to be duplication of what already exists within `cmd/k8s-operator` so we can start building an appropriate migration path for `Connector`, `ProxyGroup` etc into respective `k8s-operator/reconciler/*` packages. Closes https://github.com/tailscale/corp/issues/34524
118 lines
3.8 KiB
YAML
118 lines
3.8 KiB
YAML
# Copyright (c) Tailscale Inc & contributors
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: operator
|
|
namespace: {{ .Release.Namespace }}
|
|
{{- with .Values.operatorConfig.serviceAccountAnnotations }}
|
|
annotations:
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: ClusterRole
|
|
metadata:
|
|
name: tailscale-operator
|
|
rules:
|
|
- apiGroups: [""]
|
|
resources: ["nodes"]
|
|
verbs: ["get", "list", "watch"]
|
|
- apiGroups: [""]
|
|
resources: ["events", "services", "services/status"]
|
|
verbs: ["create","delete","deletecollection","get","list","patch","update","watch"]
|
|
- apiGroups: ["networking.k8s.io"]
|
|
resources: ["ingresses", "ingresses/status"]
|
|
verbs: ["create","delete","deletecollection","get","list","patch","update","watch"]
|
|
- apiGroups: ["networking.k8s.io"]
|
|
resources: ["ingressclasses"]
|
|
verbs: ["get", "list", "watch"]
|
|
- apiGroups: ["discovery.k8s.io"]
|
|
resources: ["endpointslices"]
|
|
verbs: ["get", "list", "watch"]
|
|
- apiGroups: ["tailscale.com"]
|
|
resources: ["connectors", "connectors/status", "proxyclasses", "proxyclasses/status", "proxygroups", "proxygroups/status"]
|
|
verbs: ["get", "list", "watch", "update"]
|
|
- apiGroups: ["tailscale.com"]
|
|
resources: ["dnsconfigs", "dnsconfigs/status"]
|
|
verbs: ["get", "list", "watch", "update"]
|
|
- apiGroups: ["tailscale.com"]
|
|
resources: ["tailnets", "tailnets/status"]
|
|
verbs: ["get", "list", "watch", "update"]
|
|
- apiGroups: ["tailscale.com"]
|
|
resources: ["peerrelays", "peerrelays/status"]
|
|
verbs: ["get", "list", "watch", "update"]
|
|
- apiGroups: ["tailscale.com"]
|
|
resources: ["proxygrouppolicies", "proxygrouppolicies/status"]
|
|
verbs: ["get", "list", "watch", "update"]
|
|
- apiGroups: ["tailscale.com"]
|
|
resources: ["recorders", "recorders/status"]
|
|
verbs: ["get", "list", "watch", "update"]
|
|
- apiGroups: ["apiextensions.k8s.io"]
|
|
resources: ["customresourcedefinitions"]
|
|
verbs: ["get", "list", "watch"]
|
|
resourceNames: ["servicemonitors.monitoring.coreos.com"]
|
|
- apiGroups: ["admissionregistration.k8s.io"]
|
|
resources: ["validatingadmissionpolicies", "validatingadmissionpolicybindings"]
|
|
verbs: ["list", "create", "delete", "update", "get", "watch"]
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: ClusterRoleBinding
|
|
metadata:
|
|
name: tailscale-operator
|
|
subjects:
|
|
- kind: ServiceAccount
|
|
name: operator
|
|
namespace: {{ .Release.Namespace }}
|
|
roleRef:
|
|
kind: ClusterRole
|
|
name: tailscale-operator
|
|
apiGroup: rbac.authorization.k8s.io
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: Role
|
|
metadata:
|
|
name: operator
|
|
namespace: {{ .Release.Namespace }}
|
|
rules:
|
|
- apiGroups: [""]
|
|
resources: ["secrets", "serviceaccounts", "configmaps"]
|
|
verbs: ["create","delete","deletecollection","get","list","patch","update","watch"]
|
|
- apiGroups: [""]
|
|
resources: ["serviceaccounts/token"]
|
|
resourceNames: ["operator"]
|
|
verbs: ["create"]
|
|
- apiGroups: [""]
|
|
resources: ["pods"]
|
|
verbs: ["get","list","watch", "update"]
|
|
- apiGroups: [""]
|
|
resources: ["pods/status"]
|
|
verbs: ["update"]
|
|
- apiGroups: ["apps"]
|
|
resources: ["statefulsets", "deployments"]
|
|
verbs: ["create","delete","deletecollection","get","list","patch","update","watch"]
|
|
- apiGroups: ["discovery.k8s.io"]
|
|
resources: ["endpointslices"]
|
|
verbs: ["get", "list", "watch", "create", "update", "deletecollection"]
|
|
- apiGroups: ["rbac.authorization.k8s.io"]
|
|
resources: ["roles", "rolebindings"]
|
|
verbs: ["get", "create", "patch", "update", "list", "watch", "deletecollection"]
|
|
- apiGroups: ["monitoring.coreos.com"]
|
|
resources: ["servicemonitors"]
|
|
verbs: ["get", "list", "update", "create", "delete"]
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: RoleBinding
|
|
metadata:
|
|
name: operator
|
|
namespace: {{ .Release.Namespace }}
|
|
subjects:
|
|
- kind: ServiceAccount
|
|
name: operator
|
|
namespace: {{ .Release.Namespace }}
|
|
roleRef:
|
|
kind: Role
|
|
name: operator
|
|
apiGroup: rbac.authorization.k8s.io
|